0
votes

I have global context document currentDoc and repeat control with responses of currentDoc.
In repeat control i have 2 fields:
1) ComboBox
2) Editbox, with computed Visible by ComboBox:

var temp = respDoc.getItemValueString( "Combobox1");
return temp == "a";

Onchange event ComboBox i update repeat control.
And i have button "Add response" (create/save response and update repeat control)
Its work. But.. if i create response and save this, field with computed Visible reset to "" and not saved. If i re-enter text to Editbox and re-saved, then Ok. Only works after re-saving. Have not errors. May be you know, what problem?

Source code

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

    <xp:repeat id="repeat1" rows="30" var="respDoc"
        repeatControls="false"
        indexVar="respDocIndex" value="#{javascript:return curDoc.getDocument().getResponses();}">
        <xp:panel id="panel1">
            <xp:table>
                <xp:tr>
                    <xp:td style="width:150.0px">
                        <xp:comboBox id="comboBox1" style="width:95%"
                            value="#{respDoc.combobox}" required="false">
                            <xp:selectItem
                                itemLabel="Email" itemValue="a">
                            </xp:selectItem>
                            <xp:selectItem itemLabel="UserName"
                                itemValue="b">
                            </xp:selectItem>

                            <xp:eventHandler event="onchange"
                                submit="true" refreshMode="partial" refreshId="repeat1">
                            </xp:eventHandler>
                        </xp:comboBox>
                    </xp:td>
                    <xp:td>
                    <xp:inputText id="inputText2"
                        value="#{respDoc.editbox}" maxlength="20">
                        <xp:this.rendered><![CDATA[#{javascript://return true    <---- if uncomment it, then all work
var temp = respDoc.getItemValueString( "combobox");
return temp == "b";}]]></xp:this.rendered>
                    </xp:inputText></xp:td>
                    <xp:td>
                        <xp:button value="Save" id="button4">
                            <xp:eventHandler event="onclick"
                                submit="true" refreshMode="partial" refreshId="repeat1">
                                <xp:this.action><![CDATA[#{javascript:respDoc.save();}]]></xp:this.action>
                            </xp:eventHandler></xp:button>
                    </xp:td>
                </xp:tr>
            </xp:table>
        </xp:panel>
    </xp:repeat>
    <xp:button value="Add Response" id="button2">
        <xp:eventHandler event="onclick" submit="true"
            refreshMode="partial" refreshId="repeat1">

            <xp:this.action><![CDATA[#{javascript:if(curDoc.isNewNote())
    curDoc.save();
var doc:NotesDocument = database.createDocument();
doc.replaceItemValue("Form", "test");
doc.makeResponse(curDoc.getDocument());
doc.save();}]]></xp:this.action>

        </xp:eventHandler>
    </xp:button>
1
Post more of your source code. Most likely it's an issue with the way your data sources are defined, but it's difficult to determine just from a description of the behavior.Tim Tripcony

1 Answers

2
votes

Your approach has a number of issue:

  1. A server roundtrip is initiated on the change of a checkbox, which is an unexpected behavior for a form
  2. A document that has not been saved can't have responses, so you shouldn't show the repeat
  3. When you create a new document you don't assign the "combobox" item any value,so your test temp =="b" fails.
  4. When no rendered, no value is send back to the server, that might not be what you want

I would use style="display : none" to hide the field on the client side and have the event only run on the client. also add a value to your combobox when creating a new document:

 var doc:NotesDocument = database.createDocument();
 doc.replaceItemValue("Form", "test");
 doc.makeResponse(curDoc.getDocument());
 doc.replaceItemValue("Combobox1","a");
 doc.save();
 doc.recyle();

Hope that helps