Question

The user changes a select box, an ajax call is made and a div is changed base on which option is selected by the user:

For example the user select an account, and after the ajax call he can see his account balance:

<s:select name="accountNum" list="sourceAccounts"
     listKey="accountNo" listValue="accountNo" 
     headerKey="" 
     headerValue="%{getText(\"label.select.anAccount\")}"
     onchange="$(this).publish('accountChanged',this,event)"/>


<s:url var="balance" action="balance" />

<sj:div href="%{balance}" listenTopics="accountChanged" deferredLoading="true"/>

The above is not work, as the option value of the select box is not passed to the div url (balance).

Is the struts2 jQuery has an internal support for my usecase, or should I write my own js to set the div url.

Also

Is it possible to change the div href url and reload it!

Was it helpful?

Solution

I see you're willing to submit dynamic attributes to the div loading url.

You can easily do that using the formIds parameter of sj:div

<sj:div href="%{some_url} formIds="myform"></sj:div>

<form id="myform">
   <input name="xyz" value="abc"/>
</form>

Now whenever the div reloads, it submits the specified form to that url.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top