Thank you so much! This saved me hours of work!
Markus Doring wrote: > > Thanks Dave, that works! > > I finally also found a working example here: > http://javachamp.blogspot.com/2008/06/struts-2-ajax-drop-down-example.html > > You can actually get rid of any javascript functions and just publish the > topic in the onchange and use die struts div tag to do the rest: > > > <s:form id="regionClassForm" theme="ajax" > action="occResourceStatsByRegion" namespace="/ajax"> > <s:hidden name="resource_id" value="%{resource_id}" /> > <s:select name="region" list="regionClasses" value="region" > onchange="dojo.event.topic.publish('imgByRegion_topic');return false;" > theme="ajax"/> > </s:form> > <s:url id="imgByRegionUrl" action="occResourceStatsByRegion" > namespace="/ajax" includeParams="none"/> > <s:div id="imgByRegion" href="%{imgByRegionUrl}" formId="regionClassForm" > listenTopics="imgByRegion_topic" theme="ajax"></s:div> > > > pretty nice. > Markus > > > > newton.dave wrote: >> >> Did you try publishing a topic onchange and having the div have that >> topic in its listenTopics? >> >> Dave >> >> >> --- On Thu, 8/7/08, Markus Doring <[EMAIL PROTECTED]> wrote: >> >>> From: Markus Doring <[EMAIL PROTECTED]> >>> Subject: struts2 select onchange to trigger ajax call >>> To: user@struts.apache.org >>> Date: Thursday, August 7, 2008, 3:37 PM >>> I would like to have an onchange event from a select element >>> to trigger an >>> AJAX call that replaces a div. >>> >>> I was trying to use the struts 2.0.11 ajax theme, but I >>> cant find a why to >>> bind the select element to my div. In struts 2.1 I should >>> be able to use >>> sx:bind, but that is not available in 2.0.11 unfortunately. >>> >>> If I use a simple s:a anchor to trigger the call all works >>> well: >>> >>> <s:form id="regionClassForm" >>> theme="ajax" action="statsByTaxon" >>> namespace="/ajax"> >>> <s:select id="rank" name="rank" >>> list="ranks" value="rank" >>> theme="ajax"/> >>> <s:a id ="myBelovedAnchor" >>> targets="imgByTaxon" theme="ajax"> >>> </s:a> >>> </s:form> >>> <s:div id="imgByTaxon"> >>> <s:action name="statsByTaxon" >>> namespace="/ajax" >>> executeResult="true"/> >>> </s:div> >>> >>> >>> Any ideas how I can bind the select onChange() event to... >>> well, to what >>> really? >>> I also tried to use dojo.connect() to bind the onchange to >>> the onclick of >>> the anchor like this without success: >>> >>> function init() { >>> var sel = dojo.byId("rank"); >>> var anch = dojo.byId("myBelovedTrigger"); >>> dojo.event.connect(sel, "onChange", anch, >>> "onClick"); >>> } >>> >>> >>> thanks, >>> Markus >>> >>> >>> >>> -- >>> View this message in context: >>> http://www.nabble.com/struts2-select-onchange-to-trigger-ajax-call-tp18878122p18878122.html >>> Sent from the Struts - User mailing list archive at >>> Nabble.com. >>> >>> >>> --------------------------------------------------------------------- >>> To unsubscribe, e-mail: [EMAIL PROTECTED] >>> For additional commands, e-mail: >>> [EMAIL PROTECTED] >> >> --------------------------------------------------------------------- >> To unsubscribe, e-mail: [EMAIL PROTECTED] >> For additional commands, e-mail: [EMAIL PROTECTED] >> >> >> > > -- View this message in context: http://www.nabble.com/struts2-select-onchange-to-trigger-ajax-call-tp18878122p19878935.html Sent from the Struts - User mailing list archive at Nabble.com. --------------------------------------------------------------------- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]