struts-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Jiin-Her Lu" <J...@kcc.usda.gov>
Subject Re: <logic:iterate> ... <logic:equal> question?
Date Mon, 02 Feb 2004 17:21:24 GMT
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


Mime
View raw message