File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
http://aspose.com/file-tools
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

JSP in Struts

 
Anurag Mishra
Ranch Hand
Posts: 121
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi All I have a basic question how do we define buttons and dropdown in jsp when we are using struts.

Do I need to define form fields like button,textbox and dropdown in struts-config.xml file also if we are validating the actions.

One more question can anyone point to a good tutorial for taglib.


thanks
Anurag
 
Nicholas Cheung
Ranch Hand
Posts: 4982
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator

Do I need to define form fields like button,textbox and dropdown in struts-config.xml file also if we are validating the actions.

NO. All form components are already defined by Struts' custom tags.

Validation of the form data are defined in validator.xml, not struts-config.xml.


Hi All I have a basic question how do we define buttons and dropdown in jsp when we are using struts.

You can use Struts' custom tag. For example, if you want to define the textfield, you cau put this in your JSP:


And in your action form, you have the corresponding variable, and its getter and setter:


Then, the Struts engine will know how to set the value from the JSP form to the Struts action form.


One more question can anyone point to a good tutorial for taglib.

Here is the Struts' tag reference.
http://jakarta.apache.org/struts/api/org/apache/struts/taglib/html/package-summary.html#package_description

Nick
thanks
Anurag[/QB]
 
Nicholas Cheung
Ranch Hand
Posts: 4982
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Forget to mention, about the validation.

The action form should be either ValidatorForm or DynaValidatorForm.


Then, Struts engine will display the errors in this form found.

Nick
 
Lasse Koskela
author
Sheriff
Posts: 11962
5
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Originally posted by Nicholas Cheung:
...
Then, Struts engine will display the errors in this form found.

...assuming that you have placed <html:errors/> tags into the JSP generating the form's HTML
 
Surasak Leenapongpanit
Ranch Hand
Posts: 341
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator

Originally posted by Lasse Koskela

...assuming that you have placed <html:errors/> tags into the JSP generating the form's HTML


You can use the below code instead of <html:errors/> tag.

 
Lasse Koskela
author
Sheriff
Posts: 11962
5
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Yep. The <html:messages/> is actually preferred over the older <html:errors/>
 
Anurag Mishra
Ranch Hand
Posts: 121
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi All,

Thanks a lot for your response, it will be really helpful for me.


thanks
Anurag
 
Nicholas Cheung
Ranch Hand
Posts: 4982
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi Lasse,


The <html:messages/> is actually preferred over the older <html:errors/>

What is the major different between the 2 tags?

Besides the general consideration that <html:messages/> can contain any messages, while <html:errors/> focus on error messages, other reasons for such recommendation?

Nick
 
Lasse Koskela
author
Sheriff
Posts: 11962
5
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Originally posted by Nicholas Cheung:
What is the major different between the 2 tags?

Besides the general consideration that <html:messages/> can contain any messages, while <html:errors/> focus on error messages, other reasons for such recommendation?

This is the one reason I'm aware of. I remember hearing the "recommendation" from a Struts trainer but I can't remember whether he presented any arguments for that recommendation...
 
I agree. Here's the link: http://aspose.com/file-tools
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic