Thursday, April 1, 2010

Passing Values Through Scoped Variables

This post may seem complex. But it is really simple. Just follow the first three steps blindly. Then you will get to know my point of simplicity.

1.Create an XPage and go to the Source panel.
2. Select all the xml code that you see there and replace the same with the following code,

<?xml version="1.0" encoding="UTF-8"?>
<xp:view xmlns:xp="">
<xp:button value="Label" id="button1">
        <xp:eventHandler event="onclick" submit="true"
    <xp:label value="#{javascript:sessionScope.Label}" id="label1">

3. Now go to the Design Panel of the XPage.

4. There you go, you will see a Button and a Label as you see in the following screen shot,
5. The button named label will have the following code in its onclick event,
sessionScope.Label+="x", and the same is illustrated in the following figure

6. The label needs to have a computed value with the following code in it.
sessionScope.Label, and this is as illustrated in the following figure,
7. Now preview the page on the browser or on a 8.5.1 client and click the button.

8. You will see that the label get changed every time you click the button, and the same is illustrated in the following screen shot
What really happens here is that the label has been mapped to a sessionScope variable.When ever you click the butto, it updates the same and hence the label also gets its value refreshed.

Hope this helps :) 

No comments:

Post a Comment