Xpages重复控件内的重复控件

时间:2018-06-21 05:53:45

标签: controls xpages repeat

我正在尝试通过选择comboBox1来构建动态表,如下所示:

enter image description here

问题是...如何获取inputtext的值?我该如何绑定数据

<xp:inputText id="inputText_${rptIndex}_${rptIndex1}"></xp:inputText>

我在网上搜索了很多文章,但仍然被困。这是整个代码

<xp:repeat id="repeat2" rows="30"
                    indexVar="rptIndex" var="yhwzdetails">
                    <xp:this.value><![CDATA[#{javascript:if(getComponent("comboBox1").getValue()){
                              var subview = database.getView("vchsubstancebycategory");
                              var dcl = subview.getAllDocumentsByKey(getComponent("comboBox1").getValue());

                              if(dcl.getCount()> 0){return dcl;}}else{return 0}}]]></xp:this.value>
                    <xp:repeat id="repeat3" rows="30"
                        indexVar="rptIndex1" var="yhwzdetails1">
                        <xp:this.value><![CDATA[#{javascript:
                                  var subview = database.getView("vchsubstancebycategory2nd");
                                  var dcl = subview.getAllDocumentsByKey(getComponent("comboBox1").getValue() + yhwzdetails.getItemValueString("checkCategory"));

                                  if(dcl.getCount()> 0){return dcl;}}]]></xp:this.value>
                        <xp:tr style="text-align:center">
                            <xp:td
                                style="width:25%;vertical-align:middle;background-color:#f3f3f3"
                                rendered="#{javascript:if(rptIndex1==0){return true}else{return false}}">
                                <xp:this.rowspan><![CDATA[#{javascript:
                                       if(rptIndex1==0){
                                            var subview = database.getView("vchsubstancebycategory2nd");
                                            var dcl = subview.getAllDocumentsByKey(getComponent("comboBox1").getValue() + yhwzdetails.getItemValueString("checkCategory"));

                                            return dcl.getCount();}
                                        else{return 1}}]]>
                                </xp:this.rowspan>
                                <xp:text escape="true"
                                    id="computedField3">
                                    <xp:this.value><![CDATA[#{javascript:labellang(yhwzdetails.getItemValueString("checkCategory"))}]]></xp:this.value>
                                </xp:text>
                            </xp:td>

                            <xp:td
                                style="width:25%;background-color:#f3f3f3">
                                <xp:text escape="true"
                                    id="computedField4">
                                    <xp:this.value><![CDATA[#{javascript:labellang(yhwzdetails1.getItemValueString("checkName"))}]]></xp:this.value>
                                </xp:text>
                            </xp:td>

                            <xp:td style="width:25%">
                                <xp:inputText
                                id="inputText_${rptIndex}_${rptIndex1}">
                                </xp:inputText>
                            </xp:td>

                            <xp:td style="width:25%">
                                <xp:text escape="true"
                                    id="computedField5" value="#{yhwzdetails1.PTNlimit}">
                                </xp:text>
                            </xp:td>
                        </xp:tr>
                    </xp:repeat>
</xp:repeat>

首先,我搜索了此文章: https://xcellerant.net/2013/07/29/access-repeat-components-from-outside/ 但是我无法将“在页面创建时创建控件”设置为true,所以我不能使用getComponent('inputText_'+ rptIndex +'_'+ rptIndex1)...相信我,我尝试了。...

然后我搜索了以下内容: How to loop and get the values from all the components in a repeat when saving Creating Global Array in in xPages using SSJS xPages repeat control with scoped variable as data source 他们都在谈论使用viewScope,我确实也可以使用它,基本上,我可以像这样将值存储在一个2D数组中 viewScope.test = [[100,200],[0,100,200,300],[....]]

但是...如何...在我的情况下可以使用它吗?希望得到你们的帮助,谢谢

1 个答案:

答案 0 :(得分:2)

...我通过动态绑定解决了

<xp:inputText id="inputText_${rptIndex}_${rptIndex1}" 
       value="#{document1[yhwzdetails1.testppm]}">
</xp:inputText>