aspose file tools*
The moose likes Struts and the fly likes How to use struts custom tags to handle this scenario? Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Spring in Action this week in the Spring forum!
JavaRanch » Java Forums » Frameworks » Struts
Bookmark "How to use struts custom tags to handle this scenario?" Watch "How to use struts custom tags to handle this scenario?" New topic
Author

How to use struts custom tags to handle this scenario?

Ajay Xavier
Ranch Hand

Joined: Jan 03, 2005
Posts: 109
I have a form bean which resembles the following class

There is a constants file which has the following values


In JSP, based on the value of "type" in MyForm its corresponding value from the types[] should be displayed. (like "one" when type is "1" and so on).

How to use struts custom tags to display in this way?

Thanks,
Ajay.
Purushoth Thambu
Ranch Hand

Joined: May 24, 2003
Posts: 425
You can define a Map collection in struts form, with constant as key and value as literals.


Then you can use logic:iterate or html : optionCollections to retrieve the value.

Ajay Xavier
Ranch Hand

Joined: Jan 03, 2005
Posts: 109
Hi Purushothaman,

Thanks for your reply. But my requirement is bit different.

i don't want it to be displayed in "select" box. User selects some value at the front end and i populate the form bean appropriately. In JSP, i will be displaying the values in form bean in a tabular format where it needs to be replaced with the value in the constants file.

Thanks,
Ajay.
Purushoth Thambu
Ranch Hand

Joined: May 24, 2003
Posts: 425
How many values you expect to be displayed in the JSP page? Anyway once user selects a value you need to populate the hashmap with int,string values and in the final jsp page you can use logic:iterate tag to iterate and display in any format you want. Take a look at logic iterate taglib

This link should help http://struts.apache.org/1.x/struts-taglib/tlddoc/logic/iterate.html
[ November 15, 2006: Message edited by: Purushothaman Thambu ]
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: How to use struts custom tags to handle this scenario?