Logo 
Search:

Java Answers

Ask Question   UnAnswered
Home » Forum » Java       RSS Feeds
  Question Asked By: Francisca Perez   on Mar 26 In Java Category.

  
Question Answered By: Neil Turner   on Mar 26

You'll have to specify the type attribute of the iterate tag or the scriptlet will fail.
There is a much nicer solution, however:
<html:select property="control" size="2">
<html:options collection="customers" property="id" labelProperty="fullName"/>
</html:select>
This time we use the options tag, where the collection attribute gives the name of the Collection of beans, and property gives the name of the property in the bean whose value will be returned when the form is submitted. labelProperty is the bean property that will be displayed. I've created  a pseudo-property, fullName, in the Customer bean with a getter-method that returns the firstName and the lastName. In the browser we could have this presented:


The generated HTML looks like this:
<select name="control" size="2">
<option value="001">John Doe</option>
<option value="002" selected="selected">Peter Smith</option>
</select>

Share: 

 
 
Didn't find what you were looking for? Find more on about JSP reset function Or get search suggestion and latest updates.


Tagged: