1
votes

I created a simple repeat control, having inside it 2 simple inputTexts. Outside this repeat control, there is an editable inputText3 ( binded to dataSource ). I'm using it to make some calculations inside the repeat control. The calculations are displayed correctly. I have 2 buttons, for newLine and delete/hideLine. For the moment, those 2 fields inside the repeat control are not binded to the datasource.

i have a button which save the doc., and list it inside a viewPanel, having the first column inputText3, clickable. I noticed that if I open the document ( in edit or read mode ) this editable field value is correctly displayed, but the fields inside the repeat control are all null, even if I add some values before using the save method.

I try also to create 2 fields inside the form ( / datasource ) and binding this inputTexts to them, but again the repeat control fields are empty.

 <xp:repeat id="repeat1" var="varRepeat" indexVar="index">
 <xp:this.value><![CDATA[#{javascript:parseInt(sessionScope.dField)
 }]]></xp:this.value>

...

 <xp:inputText id="inputText1"></xp:inputText>

 <xp:inputText id="inputText2"></xp:inputText>

The editable field outside the repeat:

<xp:inputText id="number" value="#{docrepeat.valtotala}"
        defaultValue="100">
</xp:inputText>

.

<xp:this.data>
        <xp:dominoDocument var="docrepeat" formName="docrepeat"></xp:dominoDocument>
    </xp:this.data>

I'm definitely missing something here, hope to reach to a functional solution.

Should I bind the 2 inputText using the var property of the repeat?

Or how can I achieve this?

repeat control code:

<xp:repeat id="repeat1" var="test" indexVar="index" rows="8">
            <xp:this.value><![CDATA[#{javascript:parseInt(sessionScope.DField)
}]]></xp:this.value>
<xp:panel>
            <xp:table >
                <xp:tr>
                    <xp:td>

                        <xp:inputText id="inputText1">
                            <xp:eventHandler event="onchange"
                                submit="false">
                                <xp:this.script><![CDATA[try
{
var idx="view:_id1:inputText3";
var index=document.getElementById(idx).value;

var number="view:_id1:number";
var val=document.getElementById(number).value;

var sum = val;

for(var i=0;i<index;i++) {
var input1="view:_id1:repeat1:"+i+":inputText1"
var nr1=document.getElementById(input1).value;

sum-=nr1;
document.getElementById("view:_id1:repeat1:"+i+":inputText2").value = sum;
}
// calculating some %
document.getElementById("view:_id1:test").value = parseInt((sum*100)/val); 

}
catch(e)
{
alert("not working");
}]]></xp:this.script>
                            </xp:eventHandler>
                        </xp:inputText>
                        <xp:inputText id="inputText2"></xp:inputText>
                    </xp:td>
                </xp:tr>
            </xp:table>
            </xp:panel>
        </xp:repeat>

My little scenario was described here: Xpages how to obtain/create this calculations module

1
Please post the code of the releveant parts of your XPage. - Sven Hasselbach
I think we need to see the datasources - Patrick Sawyer
This would be far easier if you explained the purpose of what you're trying to accomplish. Explaining that there are certain fields doesn't really give me an idea of what you're trying to accomplish. Is this a document used to show how much time is spent on various parts of a project? Is it to show line items on a purchase order? Is it to show who voted for which candidate? Understanding the purpose will help us figure out the problem and may point to a different solution than using a repeat in this way. - David Navarre
@DavidNavarre stackoverflow.com/questions/25779853/… - here is my described scenario. - Florin M.
You need the table walker - described before - stwissel

1 Answers

0
votes

I think your datasource inside the repeat is a view. You need to add a datasource of object data inside the repeat. The way to do this is to create a panel inside the repeat and give that panel a datasource as follows.

<xp:repeat id="repeat1" rows="30" value="#{view1}"
            var="rowData">
        <xp:panel>


 <xp:dominoDocument var="objectData1"
                        formName="Item"
                        documentId="#{javascript:return rowData.getNoteID();}"
                        ignoreRequestParams="true" action="openDocument">
</xp:dominoDocument>

!!!put your stuff in the panel!!!


</xp:panel>
</xp:repeat>

So what is going on is the repeat grabs the datasource which is a view. So it will iterate through all of the entries in the view. But the view datasource does not know what to do with documents. So you create the objectData which will grab the noteID of that specific document and make that available to the repeat as a document(referenced by noteID). Making it available as a document will allow it to save values. You probably won't be able to use the value picker but just type in the field names and it will work.

Not sure I am completely understanding your problem. But you also need to save the datasource. So you could either put a save button in the panel to save that specific document or make the save button save all data sources. I prefer being able to save each document separately as it allows for applications that multiple can edit at the same time.