xpages save / cancel actions scenario

孤街浪徒 提交于 2019-12-12 02:49:05

问题


I will describe shortly my little project application:

the main doc. content is Cdoc ( datasource which contains fields + a button ). This button displays a dialog which is Pdoc ( a datasource ) - before showing the button I will save the doc. to get the UNID and then I will pass it to the Pdoc, I want to link the Cdoc and Pdoc with the UNID. My button which shows the dialog:

<xp:button value="Adding Pdoc from the dialog" id="button3"
        styleClass="lotusFormButton" refreshMode="partial">

        <xp:eventHandler event="onclick" submit="true"
            refreshMode="partial" refreshId="computedField3">
            <xp:this.action><![CDATA[#{javascript: if ( Cdoc.isNewNote() ) { Cdoc.save(); }
Cdoc.setValue("computedField3",Cdoc.getDocument().getUniversalID());
getComponent('exampleDialog').show()}]]></xp:this.action>
        </xp:eventHandler>

The dialog / Pdoc contains just 1 button: Save ( because the X button is implicitly added to the dialog )

<xp:button value="Salvare" id="button6" styleClass="lotusFormButton">

<xp:eventHandler event="onclick"
    submit="true" refreshMode="partial" immediate="false"
    save="false" refreshId="viewPanel1">
        <xp:this.action><![CDATA[#{javascript:Pdoc.save();     
getComponent('exampleDialog').hide();
   }]]>
           </xp:this.action>
</xp:eventHandler>

So, it saves the docs. from Pdoc and they are displayed in an embedded view from Cdoc.

The main. doc Cdoc contains also 2 (actions) buttons:

Cancel: redirect to Previous Page.

and

Save
<xp:button value="Salvare" id="buttonSave" styleClass="lotusFormButton" rendered="#{javascript:currentDocument.isEditable()}">

            <xp:eventHandler event="onclick" submit="true"
                refreshMode="partial" immediate="false" save="true"
                id="eventHandler1">
                <xp:this.action><![CDATA[#{javascript:if (Cdoc.getItemValueString("txt_UNID")!= "") { 

Cdoc.save(); 
}
facesContext.getExternalContext().redirect("http://ourserver.ro/XApp.nsf/view.xsp")

}]]></xp:this.action>
            </xp:eventHandler>
</xp:button>

The problem is:

Let say I'll create 3 docs. from Pdoc from the dialog, the Cdoc. is already saved ( because the UNID was obtained ). If I save then using Cdoc Save, my main view panel from view.xsp will display:

  • one doc. Cdoc with its 3 Pdoc docs. ( I need just this case to be displayed )

  • another Cdoc ( I guess when I first obtain the UNID and I saved the Cdoc to obtain the UNID, this is the Cdoc in this case. Btw, if I save again Cdoc using the Save button , will the UNID will change ? ) and one empty ( don't know why ) Pdoc from the dialog.

How should my Save button from Cdoc should be like? Should I change also the Save from Pdoc button?

Thanks for your time.


回答1:


I believe save="true" on a button will submit and save all datasources on the page. That could explain spurious Pdoc documents. You're calling the save in script, so you don't need save="true" - you can just use a normal Button type rather than Submit type for the button.

Once a Document has been saved, the UNID will not be changed.



来源:https://stackoverflow.com/questions/24400934/xpages-save-cancel-actions-scenario

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!