You do not set the 'value' attribute of the <html:select>.

<html:select name="device" property="deviceID"> 
  <html:option value="1">one</html:option>
  <html:option value="2">two</html:option>
</html:select>

Set the value of the property 'deviceID' of the bean 'device' to '2' and you'll see 
"two" displayed (selected) by default automagically.

As you can see this set up handles the dynamism that you require in the default 
selection.

Sri

-----Original Message-----
From: Kavitha Ranga [mailto:[EMAIL PROTECTED]] 
Sent: Tuesday, October 08, 2002 9:12 PM
To: 'Struts Users Mailing List'
Subject: RE: Pre-popluating the select dropdown.


Am I missing something?Let me try to explain what I am trying to accomplish.I have a 
jsp page with a dropdown .I have a list of option  and only one of the option from 
that list has to be displayed as selected .The selected option is not the same all the 
time.It depends on what gets pulled from the database.So how do i set the specific 
option as "selected" dynamically each time? I did not see any "selected" attribute 
with either the <html:select> or the <html:option>.

I tried something like this in my jsp.
<html:select name="device" property="deviceID" value='<bean:write name="device" 
property="deviceType">'> <html:option value="1">one</html:option> <html:option 
value="2">two</html:option> </html:select>

But the value attribute does not work.

Any help is highly appreciated.
Kavitha

-----Original Message-----
From: Jacob Hookom [mailto:[EMAIL PROTECTED]]
Sent: Tuesday, October 08, 2002 8:59 PM
To: 'Struts Users Mailing List'
Subject: RE: Pre-popluating the select dropdown.


That's because they usually end in "RTFM"

http://jakarta.apache.org/struts/doc-1.0.2/struts-html.html#options


| -----Original Message-----
| From: Kavitha Ranga [mailto:[EMAIL PROTECTED]]
| Sent: Tuesday, October 08, 2002 7:50 PM
| To: 'Struts Users Mailing List'
| Subject: RE: Pre-popluating the select dropdown.
|
| I did not see any which solves my problem.I have also gone through the 
| sample jsp which comes with Struts. Since my selected option is not
going
| to
| be the same all the time,I cannot set the value .It has to be
dyanamic.I
| have seen many people ask the same question but so far I have not seen
any
| answer.
|
| Kavitha
|
| -----Original Message-----
| From: Eddie Bush [mailto:[EMAIL PROTECTED]]
| Sent: Tuesday, October 08, 2002 8:46 PM
| To: Struts Users Mailing List
| Subject: Re: Pre-popluating the select dropdown.
|
|
| Kavitha Ranga wrote:
|
| >I have a select dropdown in my JSP page.I retrieve the
| >data from the database and depending on the value I get back I have 
| >to make that option as selected in my select dropdown.So the selected 
| >option cannot be hardcoded.It has to be dynamic. I could not see any
of
| >the select attributes which can accomplish this.
| >Has anyone tried to do this on the jsp using Struts ?
| >
| Yes.  At least 3 people in the last two days have asked this question.  
| It's a popular one.  Did you try searching the archive?  Google?  Oh 
| ... here's a fair one, I think:
|
|
http://www.mail-archive.com/struts-user@jakarta.apache.org/msg44110.html
|
| There are others:
|
| http://www.google.com/search?hl=en&ie=UTF-8&oe=UTF-
| 8&q=Struts+Default+Option
|
| Google does wonderous magic with the mail archive.  I have no clue how 
| it finds such relevant posts, but it does a beautiful job of doing so.
|
| Hope that helps.
|
| --
| Eddie Bush
|
|
|
|
| --
| To unsubscribe, e-mail: 
| <mailto:[EMAIL PROTECTED]>
| For additional commands, e-mail: 
| <mailto:[EMAIL PROTECTED]>
|
|
| --
| To unsubscribe, e-mail:   <mailto:struts-user-
| [EMAIL PROTECTED]>
| For additional commands, e-mail: <mailto:struts-user- 
| [EMAIL PROTECTED]>


--
To unsubscribe, e-mail: <mailto:[EMAIL PROTECTED]>
For additional commands, e-mail: <mailto:[EMAIL PROTECTED]>


--
To unsubscribe, e-mail:   <mailto:[EMAIL PROTECTED]>
For additional commands, e-mail: <mailto:[EMAIL PROTECTED]>


--
To unsubscribe, e-mail:   <mailto:[EMAIL PROTECTED]>
For additional commands, e-mail: <mailto:[EMAIL PROTECTED]>

Reply via email to