File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
http://aspose.com/file-tools
The moose likes Struts and the fly likes form-bean with DynaValidatorForm Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of EJB 3 in Action this week in the EJB and other Java EE Technologies forum!
JavaRanch » Java Forums » Frameworks » Struts
Bookmark "form-bean with DynaValidatorForm" Watch "form-bean with DynaValidatorForm" New topic
Author

form-bean with DynaValidatorForm

Anurag Mishra
Ranch Hand

Joined: Jun 16, 2003
Posts: 121
Hi Guys,

in the struts-config.xml file the tage <form-bean> is used
for eg

<form-bean name="testTableForm" type="org.apache.struts.validator.DynaValidatorForm">
<form-property name="addButton" type="java.lang.String"/>
<form-property name="saveButton" type="java.lang.String"/>
<form-property name="deleteButton" type="java.lang.String"/>
</form-bean>

here form-bean definition which i got is....
When a user clicks the Submit button on an HTML form built with Struts, the data from that form is populated into a Java bean called a form bean

so in form-bean(<form-bean name="testTableForm") are we giving the name
"testTableForm" name as javabean name or its just a from name defined in a JSP?

And is it mandatory to define a formbean in struts where we need to do get and set(or its ok if i don't define a FormBean)?

I may be wrong here while asking this question so anyone can just explain the use of <form-bean>

thanks in Advance
Anurag


SCJP 1.2
Nicholas Cheung
Ranch Hand

Joined: Nov 07, 2003
Posts: 4982

so in form-bean(<form-bean name="testTableForm") are we giving the name
"testTableForm" name as javabean name or its just a from name defined in a JSP?

In your struts-config.xml, you have define the a dyna form named testTableForm. But you also need to specify, which ACTION you want the form to be served, so, you need:




And is it mandatory to define a formbean in struts where we need to do get and set(or its ok if i don't define a FormBean)?

For DynaForm, if you dont have your own FormBean class, you can use:

to set values into the DynaForm, and you can use:

to get values from the DynaForm.

Thus, without getters and setters, and the *real* Form object, you can still do the get/set.

Nick


SCJP 1.2, OCP 9i DBA, SCWCD 1.3, SCJP 1.4 (SAI), SCJD 1.4, SCWCD 1.4 (Beta), ICED (IBM 287, IBM 484, IBM 486), SCMAD 1.0 (Beta), SCBCD 1.3, ICSD (IBM 288), ICDBA (IBM 700, IBM 701), SCDJWS, ICSD (IBM 348), OCP 10g DBA (Beta), SCJP 5.0 (Beta), SCJA 1.0 (Beta), MCP(70-270), SCBCD 5.0 (Beta), SCJP 6.0, SCEA for JEE5 (in progress)
Nicholas Cheung
Ranch Hand

Joined: Nov 07, 2003
Posts: 4982
I cannot edit the topmost part, so I post it here:

In your struts-config.xml, you have defined the a dyna form named testTableForm. But you also need to specify, which ACTION you want the form to be served, so, you need:


In this case, when your JSP, say testTableForm0.jsp, contains an action that named "testTableAction", the data inside the JSP (if specified correctly using Struts Tags) will be copied into the DynaForm, and the corresponding method() will be called to process this request with the dyna form.

Nick
Anurag Mishra
Ranch Hand

Joined: Jun 16, 2003
Posts: 121
Hi Nicholas ,

Thanks a lot for your reply it cleared a lot for me,

I have a question what we get when we set JSP form properties
in Dyna form, how does this validate the form fields?

pls reply.

thanks
Anurag
Nicholas Cheung
Ranch Hand

Joined: Nov 07, 2003
Posts: 4982

I have a question what we get when we set JSP form properties
in Dyna form,

The Struts engine will put the corresponding value of the variables into the Sturts by the DynaForm's getter and setter method:

You need not to do anything, all these actions are performed by the Struts engine.


how does this validate the form fields?

As you can see the <action> tag, the value of the attribute validate must be set to true!


By doing so, the validate(ActionMapping mapping, HttpServletRequest request) method will be called automatically by the Struts engine.

And, all checking logics are located inside this method.



In such case, if the errors contains elements, the Struts engine will redirect the request back to the caller page, and you can see the errors inside ActionErrors.

Nick
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: form-bean with DynaValidatorForm
 
Similar Threads
Struts custom form question.....
Struts DynaActionForm
significance of id and property in <bean:define />
dynaValidatorForm Bean Parent/children config question
I am getting error when starting Tomcat .How can I rectify it?