This week's giveaway is in the EJB and other Java EE Technologies forum.
We're giving away four copies of EJB 3 in Action and have Debu Panda, Reza Rahman, Ryan Cuprak, and Michael Remijan on-line!
See this thread for details.
The moose likes Struts and the fly likes Not able set the different values for the html:option using EL Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of EJB 3 in Action this week in the EJB and other Java EE Technologies forum!
JavaRanch » Java Forums » Frameworks » Struts
Bookmark "Not able set the different values for the html:option using EL " Watch "Not able set the different values for the html:option using EL " New topic
Author

Not able set the different values for the html:option using EL

akkina sathish
Greenhorn

Joined: Apr 19, 2006
Posts: 24
Hi look at my sample code jsp.

<html:select property="dd" >
<c:forEach items="${students}" var="student">
<html ption value="${student.RollNo}">${student.Name}</html ption>
</c:forEach>
</html:select>

Only for the selected option value is not generating properly

see the generated servlet code:

<select name="dd" ">
<option value=" ">Name1</option>

<option value="11">Name2</option>

<option value="26">Name3</option>

<option value="51">Name4</option>
</select>

Why only for the first option it is saving as empty string
Other students (options) have proper student numbers.?.

Can anyone suggest some solution for this problem? Or Give any other way to do, I want to set roll nmbers as their option values.
Merrill Higginson
Ranch Hand

Joined: Feb 15, 2005
Posts: 4864
One way to do it would be to remove the c:forEach tag and use the htmlptionsCollection tag. Example:

I also noticed that your properties start with upper-case letters, which goes against the JavaBean convention. The property "rollNo" causes Struts to call the method "getRollNo".


Merrill
Consultant, Sima Solutions
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: Not able set the different values for the html:option using EL
 
Similar Threads
how to set option to default ?
bean:message tag in option tag. is there a solution?
JSP 2.0 EL and html:options issue
struts and jstl html:option
drop down list validation