aspose file tools*
The moose likes Struts and the fly likes html:select default select label and value Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Spring in Action this week in the Spring forum!
JavaRanch » Java Forums » Frameworks » Struts
Bookmark "html:select default select label and value" Watch "html:select default select label and value" New topic
Author

html:select default select label and value

ameya n
Greenhorn

Joined: May 14, 2007
Posts: 17
Following code i got from Struts Survival Guide .........but it does not work.
is it possible it ll work ?

<html:select property="address.state">
<html ption property=�NA�
labelProperty=�--Select One--� />
</html:select>
Nick Williamson
Ranch Hand

Joined: Jan 06, 2007
Posts: 73
yes the html:select works... otherwise I wouldn't think they have it in their release. what errors are you getting?
From your code you should have an Address object with name of 'address' in the request that has a string property called state.
ameya n
Greenhorn

Joined: May 14, 2007
Posts: 17
<html:select property="address.state">
<html ption property=�NA�
labelProperty=�--Select One--� />
</html:select>

it says property "NA" invalid ........please anyone try the same and let me know

i want to make the default select option here "--Select One--"
Nick Williamson
Ranch Hand

Joined: Jan 06, 2007
Posts: 73
you could do this:
<html ption value="NA">--Select One--</html ption>
or this:
<option value="NA" selected="selected">--Select One--</option>

if you put 'property' as an attribute it will look for a property with that name in your form or in the request. The way you have it you're saying you have a bean with an attribute filed called NA (mybean.getNA())... If this is on a form the easiest way to have it auto select is set the default value of your select to "NA" (on your form/bean have address.state = "NA" by default).
Nick Williamson
Ranch Hand

Joined: Jan 06, 2007
Posts: 73
if you have questions about the tag lib you should check out

http://struts.apache.org/1.x/struts-taglib/tagreference.html

*note this is for 1.x
ameya n
Greenhorn

Joined: May 14, 2007
Posts: 17
hey Nick Williamson
thanks a lot dude ............your help was great ..........i just copy pasted the code earlier from a book....thinking it would be perfect....thanks
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: html:select default select label and value