File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
The moose likes Struts and the fly likes To Tag or Not to Tag Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Frameworks » Struts
Bookmark "To Tag or Not to Tag" Watch "To Tag or Not to Tag" New topic

To Tag or Not to Tag

Dale DeMott
Ranch Hand

Joined: Nov 02, 2000
Posts: 515
Do I have to use the struts tags in my action forms in order to have it work? If so or if not, please refer me to some sites that can help me understand why.

Example ...

<struts:text property="amount" />

Lets exclude the validation part of struts and assume a simple web page.

By failing to prepare, you are preparing to fail.<br />Benjamin Franklin (1706 - 1790)
Merrill Higginson
Ranch Hand

Joined: Feb 15, 2005
Posts: 4864
Originally posted by Dale DeMott:
Do I have to use the struts tags in my action forms in order to have it work?

My answer to this question is "no, but you have to do more work if you don't". Since struts utilities that populate the form bean operate solely on the name of the item, you could code: <input name="amount" > and struts would still populate the "amount" property of your form bean when the form is submitted. However, if you have to redisplay the form , the field will be blank unless you code it:

<input name="amount" value='<cut value="${myform.amount}"/>' >

The html:text tag takes care of this automatically.

In my view it's worth the effort to learn how to use the html:xxxx tags in your struts applications. They will save you a lot of work in the long run.

However, since JSTL has equivalent tags for the logic:xxx and bean:xxx tags, I prefer to use the JSTL tags as they are more standard and more powerful.
[ December 13, 2005: Message edited by: Merrill Higginson ]

Consultant, Sima Solutions
I agree. Here's the link:
subject: To Tag or Not to Tag
It's not a secret anymore!