Search code examples
xpagesdocumentsession-scopedomino-designer-eclipse

How can i get data from another document when i creat a new document on my XPage?


I've start to develop XPage 7 weeks ago, and i have a problem with "getting data".

On my first page i have a view with a lot of documents, and a button who redirect me on a new page, to create a new document. On my first page i can select a document and when i click on the button i put my id document selected on a sessionSCope.

Button script:

var viewPanel=getComponent("viewPanel1");
var docIDArray=viewPanel.getSelectedIds();
var docUID=database.getDocumentByID(docIDArray[0]).getUniversalID();
sessionScope.put("docUID", docUID); 
context.redirectToPage("AjoutSuivi");

On my new XPage i want to get some data on my selected document so on clientLoad of the XPage i execute this script:

var docUID = sessionScope.get("docUID");
var doc:NotesDocument = database.getDocumentByUNID(docUID);
getComponent("contactname1").setValue(doc.getItemValueString("ContactName"));

On my database i have a field "ContactName" and on my XPage i have a field contactname1. I have try with "database.getDocumentByID(docUID)" and i'm sure that "database" is the good link of the database.

When i try it, there is nothing on the field contactname1 have u an idea why that's doesn't work ?

So much thank's if you can help me

Yann

PS: sorry for my bad english


Solution

  • Put your code into the event afterPageLoad and it should work (for the execution order of events take a look at XPage Cheat Sheet #1 - The Page Lifecycle).