代码之家  ›  专栏  ›  技术社区  ›  Neil Foley

struts2 sx:div,计时器忽略preload=“true”

  •  1
  • Neil Foley  · 技术社区  · 15 年前

    我有以下刷新计时器:

    <s:url id="getDeployQueue" action="deploymentQueue" >
        <s:param name="readonly" value="readonly" />
    </s:url>
    
    <sx:div id="deploymentQueue" href="%{#getDeployQueue}" errorText="Oh wait, I couldn't get the queue right now!" 
        formId="queueForm" executeScripts="false" preload="true" listenTopics="refreshqueue" 
        autoStart="true" updateFreq="8000" startTimerListenTopics="/startDeployQueue" stopTimerListenTopics="/stopDeployQueue" />
    

    我遇到的问题是,它在加载内容之前会等待8000毫秒,即使我的preload为true。在这之后,它会像我预期的那样工作,每8000毫秒重新加载一次内容。删除updatefreq=“8000”会导致DIV正确预加载,但我的计时器不会启动。

    这是预期行为吗?如果有,是否有解决办法?

    我以前通过在sx:div标记中嵌入HTML来解决这个问题,但是由于包含表单的HTML和试图在表单顶部写入的Ajax,firefox 3.5现在使用这种方法抛出了安全错误。

    2 回复  |  直到 11 年前
        1
  •  2
  •   Neil Foley    15 年前

    似乎没人能回答,我用以下方法解决了这个问题

    <sx:div id="combinedQueue" href="%{#getCombinedQueue}" errorText="Awww Snap I can't get the queue" formId="queueForm" executeScripts="false" 
        autoStart="false" updateFreq="15000" preload="false" showLoadingText="false" listenTopics="refreshqueue" startTimerListenTopics="/startDeployQueue" stopTimerListenTopics="/stopDeployQueue">   
    
        <noscript>
            <tiles:insertAttribute name="queue" />
        </noscript>
    
        <!-- Preload the deployment queue, this is done to avoid security precautions new to firefox 3.5 -->
        <sx:div id="combinedQueuePreload" href="%{#getCombinedQueue}" errorText="Awww Snap I can't get the queue" 
            executeScripts="false" preload="true" showLoadingText="false" afterNotifyTopics="/startDeployQueue" />
    
    </sx:div>
    

    在最新的火狐中,它似乎因安全异常而失败。我通过复制代码来解决这个问题:(。我用嵌套的sx:div预加载,完成后,它用计时器通知div启动。很奇怪。

        2
  •  0
  •   Community CDub    8 年前

    不使用trick,您可以使用struts2 jquery插件,只需导入库并将标记从sx:更改为sj:

    An example here