Win a copy of The Java Performance Companion this week in the Performance forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Select in Struts

 
Mary Cole
Ranch Hand
Posts: 362
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi All,

I need a select box which displays the values in it. Basically I have a bean called KeyWord which implements Serializable.
The KeyWord bean has methods called

getKeyWords and SetKeyWords

which returns and accepts an ArrayList( it can be a String[] too....depends which one is comfortable).

How do I code this in my Action class and how do i display it on the frontend using input "Select".

Pls provide me an idea how to go abt this ....thx in advance
 
Andy Hahn
Ranch Hand
Posts: 225
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I just figured out how to do this using a struts options tag:


<html:select property="number">
<html ptions collection="numberList" property="description" labelProperty="description"/>
</html:select>


Basically I want to display a list of phone numbers in a select list. So I have a phone numbers bean named "numbers". I also have a bean named "NumberListBean" which has a "public List getList() {" method which returns a collection of numbers.

One last thing I had to do was add the following to the top of my JSP:


<jsp:useBean id="NumberListBean" class="com.mycompany.Beans.NumberListBean" scope="page" />
<bean efine id="numberList" name="NumberListBean" property="list" type="java.util.ArrayList" />
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic