This week's book giveaways are in the Refactoring and Agile forums.
We're giving away four copies each of Re-engineering Legacy Software and Docker in Action and have the authors on-line!
See this thread and this one for details.
Win a copy of Re-engineering Legacy Software this week in the Refactoring forum
or Docker in Action in the Cloud/Virtualization forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

html:select and html:options or html:optionsCollection

 
casinova guy
Greenhorn
Posts: 4
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi all,
I tiered of html:select and html ptions or html ptionsCollection tags...

I have FORMBEAN

for example

TestFormBean
{
String name:
int id;

getter and setter methods
}

ACTION CLASS
{
ArrayList testList = DaoClass.getArrayList();
request.setAttribute("testList",testList);

}

DAO CLASS
{
ArrayList testList;
TestFormBean testFormBean;

while(next)
{
testFormBean = new TestFormBean();
testFormBean.setName(rs.get('name'));
testFormBean.setId(rs.get('id'));

testList.add(testFormBean);

}
return testList
}


so arrayList contains objects of formbean.
i am not getting what to write in all thease props..which make drop down list of db values
and when user submit this dropdown it will automatically sets the formbeans values so we can get the user selected value...



now in jsp

<html:select property='???'>
<html ptions collection='?' name='???' value='???'/>
</html:select>



please help me..

thanks in advance
 
David Newton
Author
Rancher
Posts: 12617
IntelliJ IDE Ruby
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Please use the UBB "code" tag wen posting code; makes it much easier to read.

Did the options documentation not help?

The "collection" attribute is the name of the collection bean, in your case, "testList". It's not clear to me what values are in that array list, which make the remaining attributes somewhat suspicious: when using the "collection" attribute normally you'd use the "property" and "labelProperty" to identify the value and text for each option.

I didn't even know the options tag had a "value" attribute; are you sure that it does? The "name" attribute is (IIRC) only used if you're not using the ActionForm to hold the selected values.

The html:select tag "property" attribute generally identifies the ActionForm property corresponding to the input tag (again, IIRC).

I'd probably check out the documentation a little bit, also searching the web for something like "struts 1 html options tag" will show several tutorials.
 
casinova guy
Greenhorn
Posts: 4
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
thanks for reply..

arraylist contain the the object of formbean ...and form bean has different attributes..

FormBean formBean = new FormBean();
formBean.setHealthSupplyCode(rs.getInt("db_column_1"));
testArrayList.add(formBean);

return testArrayList;
 
David Newton
Author
Rancher
Posts: 12617
IntelliJ IDE Ruby
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
If that was intended to give me more information with which to help, it really didn't. I believe between what I supplied and the documentation I linked to (it's more or less the same in S1.3, IIRC) there should be enough to accomplish what you need to get done.
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic