This topic has been addressed *numerous* times on this list.  However, I understand 
what a PITA searching on mail-archive is, so here goes:

Firstly take a look at the html-select.jsp that is part of the struts-exercise-taglib 
application that ships with struts.  It should answer all your questions.

In summary, the value that you see selected by default corresponds to the current 
value of the property identified by the 'property' attribute.  So, if you have 

<html:select name="foo" property="role">
  <html:option value="emp">Employee</html:option>
  <html:option value="mgr">Manager</html:option>
  <html:option value="stu">Student</html:option>
  <html:option value="sec">Security</html:option>
</html:select>

and the value of the property 'role' in the bean 'foo' is set to 'stu', then when the 
page displays the displayed (in the case of select of size 1) value will be 'Student'.

HTH

Sri

-----Original Message-----
From: Rademacher Tobias [mailto:[EMAIL PROTECTED]] 
Sent: Friday, September 27, 2002 6:55 AM
To: '[EMAIL PROTECTED]'
Subject: [Cust-Taglibs] How to mark a option using html:select?


I'm currently struggling with the fine custom taglibs of struts. 

I have question about the selection tag. I'm currently using:

  <html:select property="role" 
                 style="margin-left:25%"
    >
      <html:options collection="roles" 
                            labelProperty="name" 
                            property="name"
       />
    </html:select>

Works fine. But anyway I want to get a specfic option marked, how do I do this?

The following code fails in Catalina 4.0.3

  <html:select property="role" 
                 style="margin-left:25%"
                   value="<bean:write name="user" property="company"/>"
    >
      <html:options collection="roles" 
                            labelProperty="name" 
                            property="name"
       />
    </html:select>

What did I wrong? Assing fix string to value attrib works fine. But not a dynamically 
assinged value? How can I achive that?

Thx for any help.

Bye
Toby

PS: What is the difference of html:options and html:optionsCollection? The docu of the 
last metioned tag  is fairly poor.


--
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