aspose file tools*
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
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
 
Consider Paul's rocket mass heater.
 
subject: Not able set the different values for the html:option using EL