Here is my code
it is calling the action and alert is printing the querystring, but the querystring is not getting passed. If I append the querystring in sx:div href, it is getting passed.
function showDialog(tempControlId){
var acridsDiv = document.getElementById("acrids");
acridsDiv.href = '/SMS/problemrecord/SearchAcridAction.action?acridTypeIdAjax='+tempControlId;
alert(acridsDiv.href); //alert is printing the href
dojo.event.topic.publish("show_acrids");
dlg.show();
}
<sx:div id="acrids"
listenTopics="show_acrids" theme="ajax"
href="/SMS/problemrecord/SearchAcridAction.action"
showLoadingText="false"
>
</sx:div>
Please see the below URL and pasted content. I m exactly trying the same. But it is not calling the action.
http://struts.apache.org/2.0.11/docs/ajax-div-template.html
JavaScript Examples:
To further illustrate these concepts here is an example. Say you want to change the url of a div at runtime via javascript. Here is what you need to do:
What you will need to do is add a JS function that listens to a JS event that publishes the id from the select box that was selected. It will modify the URL for the div (adding the id so the correct data is obtained) and then bind() the AJAX div so it refreshes.
<saf:head theme="ajax" />
<script type="text/javascript">
function updateReports(id) {
var reportDiv= window['reportDivId'];
reportDiv.href = '/../reportListRemote.action?selectedId='+id;
reportDiv.refresh();
}
dojo.event.topic.getTopic("updateReportsListTopic").subscribe(null, "updateReports");
</script>
<form ... >
<saf:select .... onchange="javascript: dojo.event.topic.publish("updateReportsListTopic", this.value); " />
<saf:div id="reportDivId" theme="ajax" href="/.../reportListRemote.action" >
Loading reports...
</saf:div>
</form>