File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
http://aspose.com/file-tools
The moose likes Struts and the fly likes html:select and html:options or html:optionsCollection Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Frameworks » Struts
Bookmark "html:select and html:options or html:optionsCollection" Watch "html:select and html:options or html:optionsCollection" New topic
Author

html:select and html:options or html:optionsCollection

casinova guy
Greenhorn

Joined: Dec 04, 2008
Posts: 4
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

Joined: Sep 29, 2008
Posts: 12617

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

Joined: Dec 04, 2008
Posts: 4
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

Joined: Sep 29, 2008
Posts: 12617

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.
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: html:select and html:options or html:optionsCollection