This week's book giveaways are in the Java EE and JavaScript forums.
We're giving away four copies each of The Java EE 7 Tutorial Volume 1 or Volume 2(winners choice) and jQuery UI in Action and have the authors on-line!
See this thread and this one for details.
The moose likes Struts and the fly likes Different Types of Form beans in struts Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of The Java EE 7 Tutorial Volume 1 or Volume 2 this week in the Java EE forum
or jQuery UI in Action in the JavaScript forum!
JavaRanch » Java Forums » Frameworks » Struts
Bookmark "Different Types of Form beans in struts" Watch "Different Types of Form beans in struts" New topic
Author

Different Types of Form beans in struts

Arjun Reddy
Ranch Hand

Joined: Nov 10, 2007
Posts: 627
Hi All,

I keep getting confused with all the different types of forms beans available in struts and this is what I have finally understood. Can someone please tell me if I m correct or wrong ?

1).ActionForm
2).DynaActionForm
DynaActionForm--> No form bean is created. No Validations are done here. Form bean properties are specified in struts-config.xml file

3).ValidatorForm
4).ValidatorActionForm

ValidatorActionForm
--> validations are done according to the action class name and not according to the form bean name as in ValidatorForm. Form bean is still created.

5).DynaValidatorForm
6).DynaValidatorActionForm

DynaValidatorForm--> Similar to the ValidatorForm but form bean is not created and form bean properties are specified in the struts config.xml file. Validations here are done according to the to the formbean name unlike in DynaValidatorActionForm where validations are done according to the Action class name.

In shortcut to remember these:

Dyna--> formbean is not created and form bean properties are specified in struts config.xml file
Validator--> performs validations on formbean name
Validator and Action words together--> Validations are performed based on the Action class name and not according to the form bean name.

Thanks.
[ December 20, 2008: Message edited by: Arjun Reddy ]

Be Humble... Be Nice.
Jimmy Clark
Ranch Hand

Joined: Apr 16, 2008
Posts: 2187
You are missing one or more comments about the role of the Validator framework and the role of the validation.xml configuration file.
Arjun Reddy
Ranch Hand

Joined: Nov 10, 2007
Posts: 627
Originally posted by James Clark:
You are missing one or more comments about the role of the Validator framework and the role of the validation.xml configuration file.


Um...yeah we can use validation framework using ValidatorForm, DynaValidatorForm, ValidatorActionForm, DynaValidatorActionForm. What ever I Said above is correct right?/

Thanks.
Jimmy Clark
Ranch Hand

Joined: Apr 16, 2008
Posts: 2187
I don't see any mention of the validation.xml file and what it is used for. You mention the struts-config.xml file however.

What is the relationship of the validation.xml file and the ActionForm fields?
Arjun Reddy
Ranch Hand

Joined: Nov 10, 2007
Posts: 627
Originally posted by James Clark:
I don't see any mention of the validation.xml file and what it is used for. You mention the struts-config.xml file however.

What is the relationship of the validation.xml file and the ActionForm fields?


validation.xml file is used to validate particular ActionForm's fields. It consists of form parameters as keys and if they are required and stuff, say a field values are missing, then the key is checked with the key in resources.xml file and it's value which is an error message is printed. We can use logic:messagespresent tag in our Jsp to print the error messages.
Am I correct??

Thanks.
 
With a little knowledge, a cast iron skillet is non-stick and lasts a lifetime.
 
subject: Different Types of Form beans in struts