1
votes

Dynamic dataSource on a panel, partial refresh to load values from viewScope or other. set default values on the datasource before loading.

When doing a full refresh on a panel (new window), I used to use beforePageLoad to run a handler class against the datasource and set up or check values before the "document" loaded.

I've moved this into a modal dialog where I set the datasource dynamically and then open the modal. For existing documents I just switched to using postOpenDocument, same handler call, works great! I have tried every other sneaky way and/or event for newDocument none of them run, or I simply cant get a handle on "doc" where doc is: DominoDocument var="doc"

Anyone doing this without using extLib dialogs? (I believe the extLib ajax call would allow me to use beforePageLoad again, but I am trying not to use those, as it may get complicated when I address my mobile setup.

I've tried all the events (that apply, queryNewDocument, postNew, etc). afterRestoreView, beforeRenderResponse (<-cant find a handle to doc, also seems incorrect, but tried) The amount of processing the handler may need to do could be quite a bit so a simple throw catch with scopes probably wont work.

<xp:panel id="dialogWrap" >
<xp:this.data>
    <xp:dominoDocument
        var="doc"
        formName="#{compositeData.formName}"
        action="{#viewScope.modalAction}"
        documentId="#{viewScope.UNID}"
        ignoreRequestParams="true">
        <xp:this.postNewDocument><![CDATA[#{javascript:
            print("postNewDocument");
            if(requestScope.loadDialog){
    compositeData.handlerDocument.beforePageLoad(doc);
            }
        }]]>
        </xp:this.postNewDocument>
        <xp:this.postOpenDocument><![CDATA[#{javascript:
            print("postOpenDocument");
            if(requestScope.loadDialog){
                compositeData.handlerDocument.beforePageLoad(doc);
            }
        }]]>
        </xp:this.postOpenDocument>
    </xp:dominoDocument>
</xp:this.data>
<!--etc...-->

postOpenDocument works for existing records postNewDocument appears to need an additional refresh of the panel to get a handle ??, not working as above.

No error msgs, besides when I try a bunch of invalid handles to doc in the various events and lifecycles.. "expression failure..." I simply can not find a way to call the handler on newDocument, never runs... I would like to not use extLib dialog, or other ajax to iframe method if possible.

1
Can you prepare a simple but complete XPage that you would like to function, and post the source, so we can paste a real-life example in a test database and put it to the test for ourselves? With some description of what you would have expected it to do? Thanks. - D.Bugger
Its more complicated than a simple xPage, lots of cc's, model view, model doc, handlers, etc. I will see if I can boil it down, maybe that would help anyway. The title should maybe have been: What events allow pre-processing of a refreshed datasource (partial refresh). Thanks - Jamille Kemp
Maybe I just don't "see" what the problem is. Why do you want to preprocess a refreshed datasource? What would you want to happen? If the datasource is modified, why isn't it possible to preprocess the datasource on the server at the same time? Worst case, if you want to really have full control: use a Java Bean, write your own MyDocument class and use that as your datasource. PS when I started with XPages, I must have had very similar questions... - D.Bugger
The problem is I am not new to xPages, its a weird one, or just staring at it too much. The preprocessing is for setting up various controls, default values, etc. It works fine for existing documents, it works fine for creating or opening from an Xpage, it does not work for refreshing a dialog panel datasource for new doc. Yes, objectData might be the way to go. I'll post something useful tonight or tomorrow, if I boil it down it will prob just work. Thanks for your help, appreciate it! - Jamille Kemp

1 Answers

0
votes

Firstly some caveats. It's probably eight years since I developed an application without the Extension Library. Since 8.5.3 I've only ever advocated using the Extension Library. If you're not using the Extension Library, you probably need to understand what's happening with dialogs - dialogs with Dojo get moved out of the component tree and you need to handle them yourself. It's unclear how your dialog is working, so you'll have to understand the functionality further. Lastly, I don't tend to use dominoDocument events, but whats key is understanding when these run.

beforePageLoad event only runs once, when the page is initially loaded into memory. After that, it will never run again with partial refreshes.

You've added print statements to the document events, but that's not going to tell you when they run in relation to the XPages / JSF lifecycle. That is going to be the critical information you'll need to understand why it's not working and whether what you're trying to build is feasible. A PhaseListener and print statements in XPage events (beforePageLoad, afterPageLoad etc) will give you that information. You can find out more in the webinar, "Marty, You're Not Thinking Fourth Dimensionally" in the "2016 Webinars" section of TLCC webinars http://www.tlcc.com/admin/tlccsite.nsf/pages/recorded-xpages-webinars. There are also the slides and demos there.