谁能解释一下 Struts 2 AJAX 奇怪的刷新行为?
我们的 JSP 中有以下代码(如下所列)。 我们看到 div id=pwcercontainer
的 href
中配置的操作被调用了两次。 无法弄清楚具体原因。 将包含的 sx:div label="Admin Record Deployment"
替换为普通的非 struts div 会导致该操作仅被调用一次。 我们在 sx:div
的文档中看不到任何解释此行为的内容。
有谁知道这件事或有类似的经历吗?
谢谢。 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>
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>
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
我已经多次遇到这个问题,而且总是由于我的错误而导致。 要么返回一个包含调用代码片段的片段:
要么我已经将另一个ajax标签的目标属性设置为sx:div,而我确实应该使用dojo主题更新它。
希望这对某人有帮助
尼尔
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:
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