且构网

分享程序员开发的那些事...
且构网 - 分享程序员编程开发的那些事

加载指示器页面XPages中的全部刷新

更新时间:2023-12-05 17:06:58

我尚未为此进行专门的NotesIn9展示,但是我在此TLCC网络研讨会中演示了一种技术.
https://www.***.com/watch?v = jBaRSM9Ng_o& index = 3& list = PL9nOJ-QrsuFa00dOsdE6EDh_l2fkiYD0D 相关部分从26分钟左右开始.

I've not yet made a dedicated NotesIn9 show for it yet, but I do a demo of a technique in this TLCC webinar.
https://www.***.com/watch?v=jBaRSM9Ng_o&index=3&list=PL9nOJ-QrsuFa00dOsdE6EDh_l2fkiYD0D The relevant part starts around the 26 minute part.

我是在初始加载页面时执行此操作的,但是如果您已经在页面上,我敢肯定可以进行完全刷新.

I'm doing this on loading the page initial but I'm sure could be adapted for a full refresh if you were already on the page.

基本概念是页面加载,实际上您不会加载任何长时间运行的数据.您只是发送了页面的外壳,然后在onClientLoad事件中触发了部分刷新.

The basic concept is on page load you don't actually load any long running data. You just sent the shell of the page and then in the onClientLoad event you trigger a partial refresh.

<xp:this.resources>
    <xp:script src="/xpUtilities.jss" clientSide="false"></xp:script>
    <xp:dojoModule name="extlib.dijit.ExtLib"></xp:dojoModule>
    <xp:dojoModule name="extlib.dijit.Loading"></xp:dojoModule>
    <xp:styleSheet href="/app.css"></xp:styleSheet>
</xp:this.resources>
Page 1


<xp:this.beforePageLoad><![CDATA[#{javascript:viewScope.put("vsHasData", false);}]]></xp:this.beforePageLoad>
&#160;&#160;-&#160;&#160;Header UI goes here....<xp:br></xp:br>
<xp:br></xp:br>

<xp:br></xp:br>

<xp:panel id="MainContentWrapper">
<xp:panel id="MainContent">

    <xp:this.rendered><![CDATA[#{javascript:return viewScope.get("vsHasData");}]]></xp:this.rendered>
    <xp:br></xp:br>

    <xp:repeat id="repeat1" rows="100" var="rowData"
        indexVar="rowIdx">
        <xp:this.value><![CDATA[#{javascript:viewScope.get("vsStateMap").keySet()}]]></xp:this.value>
        <xp:text escape="true" id="computedField2"
            value="#{rowData}">
        </xp:text>
        -
        <xp:text escape="true" id="computedField3">
            <xp:this.value><![CDATA[#{javascript:viewScope.get("vsStateMap").get(rowData)}]]></xp:this.value>
            <xp:this.converter>
                <xp:convertNumber type="number"
                    integerOnly="true">
                </xp:convertNumber>
            </xp:this.converter>
        </xp:text>
        <xp:br></xp:br>
    </xp:repeat>
    <xp:br></xp:br>
    <xp:br></xp:br>
</xp:panel>
</xp:panel>
<xp:eventHandler event="onClientLoad" submit="true" refreshMode="partial" refreshId="MainContentWrapper">
    <xp:this.action><![CDATA[#{javascript:return getStateTotals();}]]></xp:this.action>
    <xp:this.onStart><![CDATA[XSP.startAjaxLoading("Calculating State Totals. This may take a few moments.")]]></xp:this.onStart>
    <xp:this.onComplete><![CDATA[XSP.endAjaxLoading()]]></xp:this.onComplete>
    <xp:this.onError><![CDATA[XSP.endAjaxLoading()]]></xp:this.onError>
</xp:eventHandler>

那是一个演示页面.要看的东西是添加的dojo资源,这一事实是我开始隐藏"MainContent",然后是作用域变量,然后是onClientLoad位的末尾.

That's a demo page. The stuff to look at is for dojo resources that are added, the fact that I start off hiding the "MainContent" vie a scoped variable and then the end onClientLoad bit.

因此将加载页面,但是用于生成重复控件的数据不会运行,因为它位于未渲染的面板中.因此,用户可以立即进入页面.然后onClientLoad起作用-在启动时显示请稍候"之类的东西,然后运行该函数以获取数据. 数据完成后,我设置了scopedVariable来显示mainContent区域,然后触发endAjaxLoading东西并显示所有内容.

So the page loads, but the data to generate the repeat control does NOT run because it's in a non rendered panel. So the users get to the page instantly. Then the onClientLoad kicks - on Start it shows a "Please Wait" kind of thing then runs the function to get the data. When the data is completed, I set a scopedVariable to then show the mainContent area and the endAjaxLoading stuff then triggers and everything gets displayed.