Win a copy of Design for the Mind this week in the Design forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Struts Select Tag

 
paul pavlentey
Greenhorn
Posts: 10
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I am new to Struts
I have the following code:

Code is executing correctly,but I dont get how selected option is getting selected based on the code above. I have a question about SELECTED value in HTML Select. How does SELECTED gets selected ( selected="selected" as appears on html)

Thank you in advance.
[ December 13, 2006: Message edited by: Bear Bibeault ]
 
Bear Bibeault
Author and ninkuma
Marshal
Pie
Posts: 64700
86
IntelliJ IDE Java jQuery Mac Mac OS X
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
"pavlentey",

There aren't many rules that you need to worry about here on the Ranch, but one that we take very seriously regards the use of proper names. Please take a look at the JavaRanch Naming Policy and adjust your display name to match it.

In particular, your display name must be a first and a last name separated by a space character, and must not be obviously fictitious.

Thanks!
bear
JavaRanch Sheriff
 
Prabhu Venkatachalam
Ranch Hand
Posts: 502
Java jQuery Spring
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I guess, your question is " How Struts TLD works?"

If you say <html:select multiple="true">, container calls the TLD class, and according to the attribute values and child elements you give, it produces equivalent HTML output in the place you called.

hth,
 
paul pavlentey
Greenhorn
Posts: 10
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Thank you for your reply.
but my question was how do you set selected value for a child element inside of select or doest it get set by Struts?
 
Prabhu Venkatachalam
Ranch Hand
Posts: 502
Java jQuery Spring
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
It seems like struts not supporting this attribute.

You can try by using below tag with iteration,

<htmlption key="" value="" selected>blah</htmlption>
 
Brent Sterling
Ranch Hand
Posts: 948
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
It is based on the property attribute of your html:select tag. If you do not specify the name attribute, then that tag defaults to using the form of the enclosing html:form tag for the name. Based on your example, Struts will call the getFa() method on your form. It will iterate over your collection and mark as selected the item that has a matching property value.

Is this working for you?

- Brent
 
paul pavlentey
Greenhorn
Posts: 10
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Thank you. it makes sense because I didnt have method getFa().
When select tag was getting loaded on html page it was showing selected="selected" for option values with "".
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic