XPages - multiple data sources different read/edit modes
Steve Castledine 17 November 2009 10:08:45
Slow rate of posting right now, hopefully will pick it up over the coming months as I do have a list of topics waiting to be blogged about.So a quick one which personally I had been stuck on for a while but for me is a very common use case: Having a document or data source open in read mode and having a second data source open but in edit mode so you can submit new data. The usual scenario here is content related pages with the ability to add comments.
Now I had achieved this before however in ways that I was not happy with. For example you can just bind your fields to scope variables and manually add code to look for those variables and create the document in SSJS. Alternatively you could embed an iframe to another XPage which does the document creation.
However the correct way is of course the simplest and probably embarrassingly overlooked (after speaking with Zen master Phil). So the basics are data sources can only be driven one at a time (automatically) on each XPage in terms of assigning the id of the document to open and then the mode of opening that document (open/edit).
So by default if you have two data source on a page, with different sources, and you go to that XPage then both data sources will pick up the same data and in the same mode even if you specify differently (and one is supposed to be in edit mode).
So the answer is a data property "ignoreRequestParams" which can be found within the data source properties (via All Properties). You would leave this as default (false) for your main data source but set this to true for the data source you wish to create data with.
If you want to do any further processing, as per standard Notes Domino development, you can add a "computeWithForm" in the same property section, you can also add code within Events > Data > say "querySaveDocument".
- Comments [5]
