|
|
hi all...
i'm trying to use ajaxEvent on a page to populate a drop down (selectOneMenu) when another drop down value changes. I have it working with the exception of rendering the second drop down.
here's my first drop down:Code:
lt;div class=quot;inputquot;gt;
lt;sf:ajaxEvent action=quot;updateCitiesquot; event=quot;onchangequot;gt;
lt;h:selectOneMenu
id=quot;statequot;
value=quot;#{address.state}quot;gt;
lt;f:selectItems value=quot;#{dataService.states}quot;/gt;
lt;/h:selectOneMenugt;
lt;/sf:ajaxEventgt;
lt;/divgt;
Here's my work flow def:Code:
lt;transition on=quot;updateCitiesquot;gt; lt;evaluate expression=quot;addressService.populateCity()quot;gt;lt;/evaluategt; lt;render fragments=quot;createAddressForm:cityquot;gt;lt;/rendergt; lt;/transitiongt;
I'm not sure how to pass the value of the state to the populateCity operation and how to update the city list correctly.
here's my city element:Code:
lt;div class=quot;fieldquot;gt;
lt;div class=quot;labelquot;gt;City:lt;/divgt;
lt;div class=quot;inputquot;gt;
lt;h:selectOneMenu
id=quot;cityquot;
value=quot;#{address.city}quot;gt;
lt;f:selectItems value=quot;#{citiesList}quot;/gt;
lt;/h:selectOneMenugt;
lt;/divgt;
lt;/divgt;
advise would be great...thanks
It really depends on what your classes look like. From a higher-level perspective, here's my take on it:
populateCity() likely needs a state parameter. You'll need some way to pass this in. You might do something like populateCity(address.state), but you'll need a way to set the return value in scope. If populateCity() returns a list of cities (your 'citiesList' used in the second drop down), you can do something like:Code:
lt;evaluate expression=quot;addressService.populateCity(address.state)quot; result=quot;viewScope.citiesListquot;/gt;
...or whatever scope citiesList should be in.
exactly what i was looking for..works now. thanks! |
|