This week's book giveaway is in the OO, Patterns, UML and Refactoring forum. We're giving away four copies of Refactoring for Software Design Smells: Managing Technical Debt and have Girish Suryanarayana, Ganesh Samarthyam & Tushar Sharma on-line! See this thread for details.
I need to display a list of values in selected tag. The values are from a Form Bean. I am able to display two other columns correctly, but i am getting confused using the selected field. I am adding the coding part here. Please help me in correcly using the Selected tag.
Action Form class =============================== package code;
You need a property on your form to hold the value of the selected item. Depending on your list, this could be about any type. I would typically use a long but some cases might be a String or other type. Since I don't know what you are getting at with the name "coll" I picked a name that made sense to me. Say the user needs to select a server, then you would add these properties to your form.
private long serverId; private List serverValuesList;
The JSP code would then look like this. I really like using htmlptionsCollection. This is mostly because the names of the properties matches up with the other html tags.
As far as the value and label attributes...that depends on what type the objects you are adding to serverValuesList. If you are using LabelValueBean, then you do not need to specify these attributes (the default for value is "value" and the default for label is "label"). If I was adding more complex objects to the list, then I might have a value setting of "serverId" and a label setting of "serverName".
I am bit confused here the way i can use the Selected tag.
my requirement behind this is based on a user name i entered, we create a list and that list will be selected in select box tag.
So for that i am creating the ArryList in Action class and set the list to form bean. I am facing the problem getting this list to JSP. As i am using the selected tag, i am confused with the values i need to give to selected tag and options tag. Can you explain me what are these tags stand for, from my problem perspective?
I’ve looked at a lot of different solutions, and in my humble opinion Aspose is the way to go. Here’s the link: http://aspose.com