Question

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

Was it helpful?

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).

OTHER TIPS

Y4nn welcome to the XPages club. When you bind a control to a data source it is better to set the value in the data source than in the control. So you write:

 document1.getDocument().replaceItemvalue(...)

(picking on a glass now, watch out for correct syntax)

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top