Win a copy of Re-engineering Legacy Software this week in the Refactoring forum
or Docker in Action in the Cloud/Virtualization forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

How to use struts custom tags to handle this scenario?

 
Ajay Xavier
Ranch Hand
Posts: 109
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 425
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 109
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 425
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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 ]
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic