0
votes

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?

2
Are you generating a dojo Dialog for every row?Michael Saiz
no i have only one panel. when i click a row i pass the document id to a hidden field in the panel and i partial-refresh the panel. then i show it using a dojo library that converts this panel to a dojo popup dialog. the boxes of the panel use this doc id to retrieve the fields from the correct document.mike_x_

2 Answers

2
votes

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.

2
votes

I see a bunch of potential issues here, although I might be wrong in some points; you need to be more precise and give us some coding examples so we can see what you tried so far:

First, it shouldn't really matter what property you use to feed data into the edit boxes: if your pop-up is showing data from the wrong repeat entry then the problem most probably is in the way you pass the edit box's value into the pop-up.

Question is: what kind of binding do you use for those edit boxes? Without knowing what you tried it's hard to give you a hint; I probably would try binding them to viewScope vars which you set early enough in the doc's life cycle. I'd try using an array of named javascript objects, where the array could be used as datasource for the repeat. Your pop-up then could use the repeat's index var param to get to the right table row, and the object's name reference to get to the column.

Second, a default value is created upon creation of a doc datasource as a suggestion to the user. I never tried this but I don't think that a partial refresh can create a new default value. But again, I don't think that's the real problem.

In case I got you wrong please try to be precise in describing your task etc.