谁能解释一下 Struts 2 AJAX 奇怪的刷新行为?

发布于 2024-07-09 14:23:40 字数 1480 浏览 8 评论 0原文

我们的 JSP 中有以下代码(如下所列)。 我们看到 div id=pwcercontainerhref 中配置的操作被调用了两次。 无法弄清楚具体原因。 将包含的 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 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

記憶穿過時間隧道 2024-07-16 14:23:40

我已经多次遇到这个问题,而且总是由于我的错误而导致。 要么返回一个包含调用代码片段的片段:

<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>

要么我已经将另一个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:

<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

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文