Sean Ding
Sean Ding

Reputation: 59

Xpages Repeat control inside repeat control

I'm trying to bulid a dynamic table by the choice of comboBox1, as below:

enter image description here

the question is...how can I get the inputtext value? how can I bind the data

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

I searched many articles on the web, still trapped. here is the whole code

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

first I searched this articel: https://xcellerant.net/2013/07/29/access-repeat-components-from-outside/ but I cant set the "Create controls at page creation" to true, so I can't use getComponent('inputText_' + rptIndex+'_' + rptIndex1)...trust me, I tried it....

then I searched these: 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 they all talk about using viewScope, and I DO think I can use it too, basiclly, I can store values in one 2D array like this viewScope.test=[[100,200],[0,100,200,300],[....]]

but...how...and can I use it in my case? looking forwad your guys help, thanks

Upvotes: 0

Views: 279

Answers (1)

Sean Ding
Sean Ding

Reputation: 59

...I solved it by dynamic binding

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

Upvotes: 2

Related Questions