Saturday 7 January 2012

Declaring global variable in XPage using dataContexts

While working on a XPages application I required a database object to be initialized and then used in various controls in XPage. I wanted to initialize the object only once then use it again and again. With some experimenting I found out that if I put the initialization code in beforePageLoad, afterPageLoad or beforeRenderResponse I was able to access the object from anywhere in XPage. But I wasn't sure that whether this was the correct way or the objects would get automatically garbage collected. So I posted this question on XPages forum.

Paul S. Withers suggested me to use dataContexts. You can find them in All Properties tab of XPages properties inside data section.

Continue reading »

0 comments:

Post a Comment