1

I'm using teamstudio's unplugged for the record.

I'm trying to build a table using a repeat control with a view as a data source. The user should be able to change edit the documents and then save all data sources.

Below is a example that currently does not work. I have also tried using computed ids for all the different check-boxes in the cells and storing the UNID of the row's document in a hidden text field and then read every row based on the computed ids and saving them. That didn't work because computing ids in a repeater is impossible in unplugged despite tons of effort.

If i have done something wrong or there is a trick i haven't tried, i would love to hear about it.

<xp:table id="table">
                <xp:tr>
                    <xp:td>Document name</xp:td>
                    <xp:td>Field1</xp:td>
                    <xp:td>Field2</xp:td>
                    <xp:td>Field3</xp:td>
                </xp:tr>
                <xp:repeat id="repeat1" rows="30"
                    value="#{TestDocs}" indexVar="index" var="Docs" first="0"
                    removeRepeat="true" repeatControls="true">
                    <xp:panel>

                        <xp:tr>
                            <xp:td>
                                <xp:text id="Name" escape="true"
                                    value="#{document1.Name}">
                                </xp:text>
                            </xp:td>
                            <xp:td>
                                <xp:checkBox id="Field1"
                                    checkedValue="true" uncheckedValue="false"
                                    value="#{document1.Field1}">
                                    <xp:this.defaultChecked><![CDATA[${javascript: 

if(document1.getDocument().getItemValue("Field1")=="[true]"){               
 return true;
  }else{
 return false;
 }}]]></xp:this.defaultChecked>


                                </xp:checkBox>
                            </xp:td>
                            <xp:td>
                                <xp:checkBox id="Field2"
                                    checkedValue="true" uncheckedValue="false"
                                    value="#{document1.Field2}">
                                    <xp:this.defaultChecked><![CDATA[${javascript: 

 if(document1.getDocument().getItemValue("Field2")=="[true]"){              
 return true;
 }else{
 return false;
 }}]]></xp:this.defaultChecked>


                                </xp:checkBox>
                            </xp:td>
                            <xp:td>
                                    <xp:checkBox id="Field3"
                                    checkedValue="true" uncheckedValue="false"
                                    value="#{document1.Field3}">
                                    <xp:this.defaultChecked><![CDATA[${javascript: 

 if(document1.getDocument().getItemValue("Field3")=="[true]"){              
 return true;
 }else{
 return false;
 }}]]></xp:this.defaultChecked>


                                </xp:checkBox>
                            </xp:td>

                        </xp:tr>
                    </xp:panel>
                </xp:repeat>
            </xp:table>
            <xp:button value="Save" id="button3"
                styleClass="button">

                <xp:eventHandler event="onclick" submit="true"
                    refreshMode="complete" disableValidators="true">
                    <xp:this.action>
                        <xp:save></xp:save>
                    </xp:this.action>
                </xp:eventHandler>
            </xp:button>
Per Henrik Lausten
  • 21,331
  • 3
  • 29
  • 76
Florenze
  • 65
  • 8

1 Answers1

0

My inclination would be to move the logic for all of this client side. So build the table with jQuery, and then on save, take the values out of the fields you create and write them into hidden fields that will actually get saved.

In terms of computing IDs of fields etc, I would add attributes to the elements you want to work with and then select them using jQuery:

$('[myattr="the value"]')
Matt White
  • 700
  • 4
  • 14
  • jQuery probably is not the best thing to use in XPages, as it is not to obvious how to get them working.... – Tode May 21 '14 at 11:38
  • This is specifically for use in Teamstudio Unplugged using the Unplugged Controls project which emulates XPages but also ships with jQuery. – Matt White May 21 '14 at 11:58
  • 1
    In version 3.1 Unplugged doesn't automatically include jQuery anymore (http://info.teamstudio.com/hs-fs/hub/218295/file-712497103-pdf/teamstudiodocs/release-notes/rn_en_Unplugged_3.1_iOS.pdf), but you can still add it manually. – Mark Leusink May 21 '14 at 14:17
  • @MattWhite Populating the table is then an issue, im going to try a AJAX call to a nonrendered xpages, its the best i can think of. – Florenze May 25 '14 at 07:43