Search code examples
xpageslotus-domino

Edit box default value is not recalculated on partial refresh


I have a repeat control and each row of it shows an entry (Employees' username, email, FullName). On click on the username (1st column) a dojo dialog pops up showing all employee information. From that dialog I can click edit button and edit employee info.

I am not using a datasource because employee data are in a 3rd database where I am not allowed to have direct access. So I am using sessionAsSigner to store the data when edit (signer is an account that has access to that 3rd nsf).

So instead of a datasource I am loading the data to read-only edit boxes using the "default value" property to load them. When I click edit I set them to readOnly(false) and i partial-refresh the panel so I can edit them. After that I click a save button to save them back to the document (using sessionAsSigner always) and then I set the fileds back to read-only and i partial-refresh the panel again. (I must mention that I have 4 fields but only 3 can be edited. The 4rth is always in read-only mode as it is the employee code and must not be changed.)

Everything works fine until here. The problem is when I edit one employee and then click the next one (in my repeat control) to edit again. The popup appears again but it kept the previous employee data. This means that default value didnt work, although I did a partial refresh on the popup panel. Partial refresh worked because the employee-code field (the permanent read-only one) shows the correct employee code but all the editable fields have the previous data.

I solved it by doing a full refresh of the page (location.reload()) but I would prefer to avoid the full refresh.

So the problem is that I am using the default-value property. It seems that it is not recalculated in partial refresh but only in the full refresh.

Any suggestions?


Solution

  • Without seeing the code it's hard to figure out what causes your issue but from what i can get out of your question i think it would be better to redesign it a bit. Here hint how i would solve this:

    For this example i used arrays as datasource wich you could also use if your data loaded with sessionAsSigner from the documents is not to huge, but i would prefere a bean or a Object Data Source wich i can then bind to my repeat control.

    <xp:panel id="repeatHolder">
        <xp:repeat
            id="repeat1"
            rows="30"
            var="rowEntry"
            indexVar="rowIndex">
            <xp:this.value><![CDATA[#{javascript://loading data with sessionAsSigner
                var person1 = {"name":"Igor","value":"value","age":"20","unid":"unid"};
                var person2 = {"name":"Victor","value":"value","age":"30","unid":"unid"};
                //end loading data              
                return [person1,person2];}]]>
            </xp:this.value>
            <xp:panel>
                <xp:text
                    escape="true"
                    id="computedField1"
                    value="#{rowEntry.name}">
                </xp:text>
                <xp:text
                    escape="true"
                    id="computedField2"
                    value="#{rowEntry.value}">
                </xp:text>
                <xp:button
                    value="edit"
                    id="edit">
                    <xp:eventHandler
                        event="onclick"
                        submit="false">
                        <xp:this.script><![CDATA[XSP.openDialog('#{id:editDialog}');]]></xp:this.script>
                    </xp:eventHandler>
                </xp:button>
                <xe:dialog
                    id="editDialog"
                    title="edit"
                    preload="false">
                    <xp:panel>
                        <xp:panel>
                            <xp:inputText
                                id="inputText1"
                                defaultValue="#{rowEntry.name}">
                            </xp:inputText>
                        </xp:panel>
                        <xp:panel readonly="true">
                            <xp:inputText
                                id="inputText2"
                                defaultValue="#{rowEntry.value}">
                            </xp:inputText>
                        </xp:panel>
                        <xp:button
                            value="save"
                            id="button1">
                            <xp:eventHandler
                                event="onclick"
                                submit="true"
                                refreshMode="complete">
                                <xp:this.action><![CDATA[#{javascript://run save actionAsSigner for doc:unid}]]></xp:this.action>
                            </xp:eventHandler>
                        </xp:button>
                    </xp:panel>
    
                    <xp:eventHandler
                        event="onHide"
                        submit="true"
                        refreshMode="partial"
                        refreshId="repeatHolder">
                        <xe:this.action><![CDATA[#{javascript://refresh view}]]></xe:this.action>
                    </xp:eventHandler>
                </xe:dialog>
                <br></br>
            </xp:panel>
        </xp:repeat>    
    </xp:panel>
    

    I also would use one Dialog per row as long as you use the xe:dialog with preload=false and if you just use it to edit only 3 fields you dont have to worry about Performance issus.