Instead of manipulating the dom and creating option objects, why not just have
the select box in its own jsp, surround it with a div, and use an ajax updater:
<select id="firstSelect" onchange="updateOtherOptions()"/>
<div id="otherSelect">
<jsp:include "otherSelect.jsp" />
</div>
Other select.jsp
<s:form partial=true beanclass=actionBean.beanclass>
<select .../>
</s:form>
function updateOtherOptions () {
var parameters = $('form').serialize(true);
parameters['_eventName'] = updateOtherOptions;
new Ajax.Updater('otherSelect', '/yourActionBeanUrl',
{parameters: parameters});
}
@DontValidate
public Resolution updateOtherOptions() {
// logic here to pull other menu options by looking at post-
this can also be done in an @Before method
return new ForwardResolution("/otherSelect.jsp");
}
-----Original Message-----
From: Lionel [mailto:[email protected]]
Sent: Tuesday, March 17, 2009 6:23 AM
To: [email protected]
Subject: Re: [Stripes-users] Need advice on dependent menu design
AK wrote:
> This is not specifically a Stripes issue, but I suspect someone here
> has dealt with this problem and can provide some advice.
>
> I'm trying to build a set of dependent drop-down menus, State and
> City. When one of the 50 states is selected from the 1st drop-down,
> the City menu is populated with all the cities in that state.
>
> What's the best way to do something like this (w/ Stripes)? Also,
> anyone know where I can get this data?!
Using any Javascript framework and a JavascriptResolution, it is really
easy.
Something like this will do the work with Prototype:
new Ajax.Request(url, {
parameters: $(idSourceDropdown).name+'='+$F(idSourceDropdown),
onSuccess: function(request) {
$(destDropdown).options.length=0;
eval(request.responseText).each(function(item, i){
$(destDropdown).options[i] = new Option(item.label, item.value);
});
},
method:'post'
});
In your actionBean:
Just populate a List<LabelValueBean> and return new
JavascriptResolution(theList)
------------------------------------------------------------------------------
Apps built with the Adobe(R) Flex(R) framework and Flex Builder(TM) are
powering Web 2.0 with engaging, cross-platform capabilities. Quickly and
easily build your RIAs with Flex Builder, the Eclipse(TM)based development
software that enables intelligent coding and step-through debugging.
Download the free 60 day trial. http://p.sf.net/sfu/www-adobe-com
_______________________________________________
Stripes-users mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/stripes-users
------------------------------------------------------------------------------
Apps built with the Adobe(R) Flex(R) framework and Flex Builder(TM) are
powering Web 2.0 with engaging, cross-platform capabilities. Quickly and
easily build your RIAs with Flex Builder, the Eclipse(TM)based development
software that enables intelligent coding and step-through debugging.
Download the free 60 day trial. http://p.sf.net/sfu/www-adobe-com
_______________________________________________
Stripes-users mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/stripes-users