You are viewing a plain text version of this content. The canonical link for it is here.
Posted to user@struts.apache.org by Jino Morgan <jp...@yahoo.com> on 2004/02/02 18:47:31 UTC
Re: ... question? SELECTED ATTRIBUTE
How does one add selected attribute if I want one the
option to have the SELECTED attribute
--- Jiin-Her Lu <JN...@kcc.usda.gov> wrote:
> you can do as following.
> countryCollection is an ArryList with object of
> struts' LabelValueBean. The value is the country
> code and label is the country name for example.
> Once the user changes the country selection, it will
> submit the change to server so that the action can
> generate the city list based on the selected county.
> Once it's done, forward to itself. The list of city
> will be populated accordingly. If you want use
> javascript, then it's a different story.
>
> Hope this can help!
>
> <html:select property="selectedCountry" >
> <html:options collection="countryCollection"
> property="value" labelProperty="label"
> onchange="submit()" />
> </html:select>
>
> <html:select property="selectedCity" >
> <html:options collection="cityCollection"
> property="value" labelProperty="label" />
> </html:select>
>
>
>
> Jiin-Her Lu
> (816) 926-2145
>
> >>> derek@netsimple.net 02/02/04 09:49AM >>>
> Apologies for this newbie question...
>
> I have 2 selections: Country and City
> I have 2 collections in session (CityList contains a
> reference to Country)
> I don't want the user to select a City before
> selecting a Country and I want
> to display a list of Cities that relate to the
> selected Country...
>
> Can anyone please help with this code:
>
> ...
> <tr>
> <td>Country</td>
> <td>
> <html:select property="country"
> onchange="document.forms['myForm'].city.value='';
>
> document.forms['myForm'].submit();">
> <html:option value="">Select a
> country...</html:option>
> <html:options collection="CountryList"
> property="country"
> labelProperty="description" />
> </html:select>
> <font color="red"><html:errors
> property="country" /></font>
> </td>
> </tr>
> <tr>
> <td>City</td>
> <td>
> <html:select property="city">
> <html:option value="">Select a
> city...</html:option>
> <logic:iterate id="City" name="CityList"
> property="list"
> type="City">
>
<<<<<-----------------------------------------------------------------------
> ------
> <logic:equal name="City"
> property="country" value="">
> !!! This is where I'm stumped. How do I get the
> comparison to work between 2
> beans?
>
>>>>>-----------------------------------------------------------------------
> ------
> <html:option name="City" property="city"
> labelProperty="description" />
> </logic:equals >
>
> </logic:iterate>
> </html:select>
> <font color="red"><html:errors property="city"
> /></font>
> </td>
> </tr>
> ...
>
> Any help much appreciated!
> Derek
>
>
>
>
---------------------------------------------------------------------
> To unsubscribe, e-mail:
> struts-user-unsubscribe@jakarta.apache.org
> For additional commands, e-mail:
> struts-user-help@jakarta.apache.org
>
>
>
>
---------------------------------------------------------------------
> To unsubscribe, e-mail:
> struts-user-unsubscribe@jakarta.apache.org
> For additional commands, e-mail:
> struts-user-help@jakarta.apache.org
>
__________________________________
Do you Yahoo!?
Yahoo! SiteBuilder - Free web site building tool. Try it!
http://webhosting.yahoo.com/ps/sb/
---------------------------------------------------------------------
To unsubscribe, e-mail: struts-user-unsubscribe@jakarta.apache.org
For additional commands, e-mail: struts-user-help@jakarta.apache.org
RE: ... question? SELECTED ATTRIBUTE
Posted by Derek Colley <de...@netsimple.net>.
Struts does this for you if the value of the <SELECT> parameter equals the
<OPTION>...
Derek
> -----Original Message-----
> From: Jino Morgan [mailto:jpmorganh@yahoo.com]
> Sent: 02 February 2004 17:48
> To: Struts Users Mailing List
> Subject: Re: <logic:iterate> ... <logic:equal> question?
> SELECTED ATTRIBUTE
>
>
> How does one add selected attribute if I want one the
> option to have the SELECTED attribute
> --- Jiin-Her Lu <JN...@kcc.usda.gov> wrote:
> > you can do as following.
> > countryCollection is an ArryList with object of
> > struts' LabelValueBean. The value is the country
> > code and label is the country name for example.
> > Once the user changes the country selection, it will
> > submit the change to server so that the action can
> > generate the city list based on the selected county.
> > Once it's done, forward to itself. The list of city
> > will be populated accordingly. If you want use
> > javascript, then it's a different story.
> >
> > Hope this can help!
> >
> > <html:select property="selectedCountry" >
> > <html:options collection="countryCollection"
> > property="value" labelProperty="label"
> > onchange="submit()" />
> > </html:select>
> >
> > <html:select property="selectedCity" >
> > <html:options collection="cityCollection"
> > property="value" labelProperty="label" />
> > </html:select>
> >
> >
> >
> > Jiin-Her Lu
> > (816) 926-2145
> >
> > >>> derek@netsimple.net 02/02/04 09:49AM >>>
> > Apologies for this newbie question...
> >
> > I have 2 selections: Country and City
> > I have 2 collections in session (CityList contains a
> > reference to Country)
> > I don't want the user to select a City before
> > selecting a Country and I want
> > to display a list of Cities that relate to the
> > selected Country...
> >
> > Can anyone please help with this code:
> >
> > ...
> > <tr>
> > <td>Country</td>
> > <td>
> > <html:select property="country"
> > onchange="document.forms['myForm'].city.value='';
> >
> > document.forms['myForm'].submit();">
> > <html:option value="">Select a
> > country...</html:option>
> > <html:options collection="CountryList"
> > property="country"
> > labelProperty="description" />
> > </html:select>
> > <font color="red"><html:errors
> > property="country" /></font>
> > </td>
> > </tr>
> > <tr>
> > <td>City</td>
> > <td>
> > <html:select property="city">
> > <html:option value="">Select a
> > city...</html:option>
> > <logic:iterate id="City" name="CityList"
> > property="list"
> > type="City">
> >
> <<<<<---------------------------------------------------------
> --------------
> > ------
> > <logic:equal name="City"
> > property="country" value="">
> > !!! This is where I'm stumped. How do I get the
> > comparison to work between 2
> > beans?
> >
> >>>>>---------------------------------------------------------
> --------------
> > ------
> > <html:option name="City" property="city"
> > labelProperty="description" />
> > </logic:equals >
> >
> > </logic:iterate>
> > </html:select>
> > <font color="red"><html:errors property="city"
> > /></font>
> > </td>
> > </tr>
> > ...
> >
> > Any help much appreciated!
> > Derek
> >
> >
> >
> >
> ---------------------------------------------------------------------
> > To unsubscribe, e-mail:
> > struts-user-unsubscribe@jakarta.apache.org
> > For additional commands, e-mail:
> > struts-user-help@jakarta.apache.org
> >
> >
> >
> >
> ---------------------------------------------------------------------
> > To unsubscribe, e-mail:
> > struts-user-unsubscribe@jakarta.apache.org
> > For additional commands, e-mail:
> > struts-user-help@jakarta.apache.org
> >
>
>
> __________________________________
> Do you Yahoo!?
> Yahoo! SiteBuilder - Free web site building tool. Try it!
> http://webhosting.yahoo.com/ps/sb/
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: struts-user-unsubscribe@jakarta.apache.org
> For additional commands, e-mail: struts-user-help@jakarta.apache.org
>
>
---------------------------------------------------------------------
To unsubscribe, e-mail: struts-user-unsubscribe@jakarta.apache.org
For additional commands, e-mail: struts-user-help@jakarta.apache.org