Win a copy of Svelte and Sapper in Action this week in the JavaScript forum!
  • 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 all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Ron McLeod
  • Paul Clapham
  • Bear Bibeault
  • Junilu Lacar
Sheriffs:
  • Jeanne Boyarsky
  • Tim Cooke
  • Henry Wong
Saloon Keepers:
  • Tim Moores
  • Stephan van Hulst
  • Tim Holloway
  • salvin francis
  • Frits Walraven
Bartenders:
  • Scott Selikoff
  • Piet Souris
  • Carey Brown

html:select default select label and value

 
Greenhorn
Posts: 17
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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>
 
Ranch Hand
Posts: 73
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 17
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
<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
Posts: 73
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 73
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 17
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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'm THIS CLOSE to ruling the world! Right after reading this tiny ad:
Building a Better World in your Backyard by Paul Wheaton and Shawn Klassen-Koop
https://coderanch.com/wiki/718759/books/Building-World-Backyard-Paul-Wheaton
    Bookmark Topic Watch Topic
  • New Topic