I have been noticing that it appears that the "value"
attribute of select never takes a run time expression.  
I have the following:

<html:select property="<%= OrganizationForm.PARENT_ORG_ID %>" 
        
value="<%=OrganizationForm.PARENT_ORG_ID %>">
        <html:options collection="<%= Constants.ORG_LIST %>" 
                        property="<%= Constants.SELECT_VALUE %>"
                        labelProperty="<%= Constants.SELECT_LONG_NAME %>"/>
</html:select>

where I want to use the same variable both to initialize the select
statement,
and to have it set by the selected value after the user makes a selection.
In OrganizationForm I have:

public static final String PARENT_ORG_ID = "parentOrgId";

OrganizationForm declares parentOrgId, and has appropriate
getters and setters for it.  I have it declared it as a string.  
Could this be the problem?  I always get the first item in the 
list when I do it this way.  However, if I substitute in this:

<html:select property="<%= OrganizationForm.PARENT_ORG_ID %>" value="24">
        <html:options collection="<%= Constants.ORG_LIST %>" 
                        property="<%= Constants.SELECT_VALUE %>"
labelProperty="<%= Constants.SELECT_LONG_NAME %>"/>
</html:select>

where 24 is one of the valid ids, it correctly selects the option that
corresponds to 24.

Is this a bug in the select tag, a bug in the select tag documentation,
or am I misunderstanding something?

-- Larry Maturo
   [EMAIL PROTECTED]

-----Original Message-----
From: Jakkampudi, ChandraseKhar [mailto:[EMAIL PROTECTED]]
Sent: Wednesday, January 30, 2002 2:12 PM
To: 'Struts Users Mailing List'
Subject: RE: initializing html:select


You can set the value paramater like this

<html:select property="selectProperty" value="two">
        <html:options property="values" labelProperty="names"/>
</html:select>

Value can take a real time expression. Unfortunately, it currently works
only if you dont have multiple set to true. It should work in your case.

-----Original Message-----
From: Robert Tyler Retzlaff [mailto:[EMAIL PROTECTED]]
Sent: Wednesday, January 30, 2002 2:01 PM
To: [EMAIL PROTECTED]
Subject: initializing html:select


How do you initialize the <html:select> to a particular option
so that it appears to be the default when the form is loaded.


.. my ActionForm class

        private String selectProperty;
        private String[] values = { ""+1, ""+2 };
        private String[] names  = { "One", "Two" };

.. setter/getters

public void reset( .., ..)
{
        selectProperty = values[1];
}

.. my form.jsp

<html:select property="selectProperty">
        <html:options property="values" labelProperty="names"/>
</html:select>


When the form loads I still end up with the selection box
displaying "One" as opposed to "Two" is there a way to do
what I would like to accomplish?

Also, I've hard coded the arrays of values and names into the form
which I don't like I would like to extract them from an object I
have stored in the request how might that be achieved?


Thanks

rob

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