2

i have an issue that it gives me some headache lately.

In my XPage there is a view displaying some docs ( let say Pdoc as datasource ) and I open/create them inside a <xe:dialog>. This dialog has only Pdoc declared as datasource, and it inherits some values from the Xpage datasrouce. My clickable column formula is:

// some var declarations
var formName = rowData.getDocument().getItemValueString("Form");

if ( formName == "fmP" )

{ viewScope.put("dlgDocUnid", pe.getUniversalID())
getComponent("exampleDialog").show(); }

On the same XPage, I can create a new Pdoc using the same dialog via a button, New Pdoc.

The problem is: when I opened an existing Pdoc and then just save it or close it, and after I use the button to create a newNote => the old / previous ( already saved Pdoc ) is showed...

If firstly I just created a new note Pdoc, it works, and it is showing a new empty Pdoc.

My dialog data code:

<xp:this.data>
        <xp:dominoDocument var="Pdoc" formName="fmPersContact"
            ignoreRequestParams="true" scope="request" action="editDocument">

            <xp:this.documentId><![CDATA[#{javascript:viewScope.get("dlgDocUnid");}]]></xp:this.documentId>
        </xp:dominoDocument>
    </xp:this.data>

I use the .documentId for the open method from the viewPanel. I think here is the problem. I think ,( I'm not sure), I should compute this documentId in such way that when I create a newNote this documentID shouldn't be anymore the viewScope.get("dlgDocUnid"). Thanks for your time.

Florin M.
  • 2,159
  • 4
  • 39
  • 97

2 Answers2

2

If I understood correctly, you have defined two data sources within the XPage and you try to consume them in the dialog, right? Instead I suggest defining a single data source within a panel inside the xe:dialog.

I have blogged about a similar example. In this example, tooltip dialog has been used but it's the same logic, you might replace xe:tooltipDialog with xe:dialog.

http://lotusnotus.com/lotusnotus_en.nsf/dx/mini-patterns-for-xpages-parameter-editing-with-dialogs-1.htm

The idea here is that you use a viewScope variable named noteId. To open an existing document, set this variable to the note id of the existing document. To create a new document, the value will be set as NEW. Then you define the data source within the dialog according to this variable:

<xe:dialog>
 <xp:panel style="width:500.0px"> 
  <xp:this.data> 
    <xp:dominoDocument
        var="document1"
        formName="Parameter" 
        action="#{viewScope.noteId eq 'NEW'?'createDocument':'editDocument'}"
        documentId="#{viewScope.noteId eq 'NEW'?'':viewScope.noteId}" 
        ignoreRequestParams="true"> 
    </xp:dominoDocument> 
  </xp:this.data> 
 ..... Dialog content ....
 </xp:panel>
</xe:dialog>

When you put the data source inside the dialog, you don't refresh the page to load or prepare data sources before launching the dialog which is your current problem I guess.

Serdar Basegmez
  • 3,355
  • 16
  • 20
  • Thanks for your answer. There are quite big chances not to understand you ( it is my fault / little experience in Xpages ): my xpages has only one datasource declared in data ( Cdoc ), the dialog indeed is on my xpage and it has Pdoc. as datasource declared ). I will try to change the action and the documentId parameters and let you know. – Florin M. Aug 07 '14 at 06:57
  • Paste some more code from data sources. Maybe I understood the problem wrong. – Serdar Basegmez Aug 07 '14 at 07:01
  • My xpage code is: – Florin M. Aug 07 '14 at 07:03
  • My dialog code: <![CDATA[#{javascript:viewScope.get("dlgDocUnid");}]]> – Florin M. Aug 07 '14 at 07:03
  • When you open a new dialog, you clear `viewScope.dlgDocUnid`? – Serdar Basegmez Aug 07 '14 at 07:04
  • I guess I didn't :) My code for the button that creates a new dialog is in my question ... How can I clear the viewscope? – Florin M. Aug 07 '14 at 07:06
  • `viewScope.remove("dlgDocUnid")`, but if you are removing this variable, you need to check if it's null within the dialog data source. Look at my example from my blog. – Serdar Basegmez Aug 07 '14 at 07:08
  • So, if I just : viewScope.dlgDocUnid="NEW" in my NEW DOC button, I will just change its value, without removing it. And then I could use your action and documentID parameters ? – Florin M. Aug 07 '14 at 07:17
  • One more little misunderstanding: Adding .. is equally with just documentId = " .. " into the ? Now I'll make the changes you suggested and let you know. – Florin M. Aug 07 '14 at 07:27
  • Yes. That is coming from XML syntax, you can't use some characters in attributes, so XPages editors change that into CDATA... – Serdar Basegmez Aug 07 '14 at 07:28
  • Thanks, it works. Useful blog, I've added it to my favorites xpages/Lotus notes learning platforms. Thanks again – Florin M. Aug 07 '14 at 07:35
0

Could it be that you forgot to deactivate the flag to ignore request parameters. Sounds like the dialog is always associated with the current document instead of the parameters from the docid

user2316219
  • 304
  • 1
  • 11