• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

html:select and html:options or html:optionsCollection

 
Greenhorn
Posts: 4
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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
 
Author
Posts: 12617
IntelliJ IDE Ruby
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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
    Number of slices to send:
    Optional 'thank-you' note:
  • 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
Posts: 12617
IntelliJ IDE Ruby
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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.
 
Don't get me started about those stupid light bulbs.
reply
    Bookmark Topic Watch Topic
  • New Topic