XPages重复控制和按钮

时间:2015-02-03 18:16:35

标签: xpages repeat

我对XPage显示项目摘要进行了重复控制。要查看其他详细信息,用户单击一个按钮(在重复内部),该按钮将viewScope变量设置为repeat的rowIndex,然后打开一个模式以显示重新记录的项目详细信息。

我无法从按钮设置viewScope变量。它就像无法获得rowIndex的句柄一样。

我有一个计算文本字段设置为在重复开始时显示rowIndex(工作正常)。

我显然缺少一些基本的东西。任何帮助将不胜感激。

相关的源代码如下:

<xp:repeat id="repeat1" rows="50" var="entry" indexVar="rowIndex">
<xp:this.value><![CDATA[#{javascript:var m = sessionScope.assetMap;
if(m!=null){
m.entrySet()
}}]]></xp:this.value>
<div>
    <small>                 
    <label>
    <xp:text escape="true" id="num">
    <xp:this.value><![CDATA[#{javascript:var itemNum:Number =     parseInt(rowIndex + 1);
itemNum.toPrecision(0);}]]></xp:this.value>
    </xp:text>
    .&#160; Description:&#160; &#160;
    </label>
    <xp:text escape="true" id="desc">
    <xp:this.value><![CDATA[#{javascript:@Word(entry.getValue(),"~",3);}]]>    </xp:this.value>
    </xp:text>
    </small>
</div>
<br></br>
<div>
<xp:button type="button" value="Details ..." id="button2">
<xp:eventHandler event="onclick" submit="true" refreshMode="complete">
<xp:this.action><![CDATA[#{javascript:try{var itemNum:Number =     parseInt(rowIndex + 1);
viewScope.currentItem = itemNum.toPrecision(0);
}catch(e) {
requestScope.errstatus = e.toString();}}]]></xp:this.action>
</xp:eventHandler>
</xp:button>

    

02/04/2015更新:

我已将问题隔离到自定义控件的呈现属性。如果我不使用渲染属性,代码就可以工作。

我的XPage(CSJS)的onCLientLoad中的代码是:

$(window).on('load resize', function(){
var screenWidth = $(window).width();
var sDevice = '';

switch(true){
    case (screenWidth < 768):
        sDevice = 'mobile';
        break;
    case (screenWidth < 922):
        sDevice = 'tablet';
        break;
    case (screenWidth >= 922):
        sDevice = 'desktop'
}

XSP.partialRefreshPost( '#{id:pnlList}', {params: {'sDevice': sDevice}} );

});

我在具有呈现属性的XPage中的自定义控件的源是:

<xp:panel rendered="#{javascript:param.sDevice == 'mobile'}">
        <xc:ccSYS_AppLayoutReq_p xp:key="panelContentFacet">
            <xp:this.facets>
                <xc:cc_cartracking_p xp:key="contentFacet"></xc:cc_cartracking_p>
            </xp:this.facets>
        </xc:ccSYS_AppLayoutReq_p>  
        </xp:panel>

谢谢,

1 个答案:

答案 0 :(得分:2)

您必须在按钮中设置“设置部分执行模式”execMode="partial"选项。

在同事的问题https://stackoverflow.com/a/28330481/2065611

中查找完整的答案