Can Anyone Explain This Struts 2 AJAX Strange Refresh Behaviour?
Question
We have the following code (listed below) in our JSP. We are seeing the action configured in the href
of the div id=pwcercontainer
being called twice. Can't work out exactly why. Replacing the containing sx:div label="Admin Record Deployment"
with a plain non-struts div causes the action to be called only once. We can't see anything in the documentation for sx:div
that explains this behavior.
Does anyone know anything about this or have similar experience?
Thanks. NCF
<%@ page language="java" %>
<%@ taglib uri="/WEB-INF/tags/c.tld" prefix="c" %>
<%@ taglib prefix="s" uri="/struts-tags" %>
<%@ taglib uri="http://tiles.apache.org/tags-tiles" prefix="tiles" %>
<%@ taglib uri="/WEB-INF/tags/arcade.tld" prefix="arcade" %>
<%@ taglib prefix="sx" uri="/struts-dojo-tags" %>
<s:url id="pwcerAjax" action="pwcerajax" method="start" includeParams="none"/>
<s:url id="pwAjax" action="pwajax" method="start" includeParams="none"/>
<s:url id="listPendingDeploymentsLink" action="listPendingDeployments" namespace="/"/>
<s:url id="record" action="recordDeploymentFragment" method="showAdminRecord" namespace="/"/>
<sx:div label="Admin Record Deployment" >
<!-- Div where content will be displayed -->
<sx:div id="pwcercontainer" href="%{pwcerAjax}" showLoadingText="false" indicator="recordImage" preload="true">
</sx:div>
<div id="loadingContainer"><img id="recordImage" src="images/ajaxLoadingAnimation.gif" style="display:none" alt="loading animation"/></div>
</sx:div>
Solution
I have hit this issue many times now and it is always down to an error on my part. Either returning a fragment that contains the calling piece of code:
<s:url id="getDeployQueue" action="deploymentQueue" />
<sx:div href="%{#getDeployQueue}" formId="queueForm" executeScripts="true" autoStart="true" updateFreq="3000" preload="false" showLoadingText="false" listenTopics="refreshqueue" id="deploymentQueue" >
THE CODE RETURNED in HERE CONTAINS THE s:url id="getDeployQueue" duplicating it and resulting in double calls
</sx:div>
Or i have been setting the target attribute of another ajax tag to be an sx:div when I really should be updating it using a dojo topic.
Hope this helps somebody
Neil