Probably one of the most useful features
in XPages has to be the scope variables, with proper planning you can really
make good use of them and eliminate the need to store temporary values
in backend notes documents. As I showed in a recent blog entry
you can put anything into a scope variable, including a hashmap and you
can then run a repeat control off the hashmap. Well the scope variables
themselves are also hashmaps so why not use the same technique to see what’s
There are four scope variables that
you can use, applicationScope, sessionScope, requestScope and viewScope.
To make it easier to debug an application that is using scoped variables
I have created four new custom controls, one for each of the four scoped
variables. The code in the custom controls is simple.
<xp:panel id="applicationVars" styleClass="debugPanel">
For the other custom controls you just
need to replace applicationScope with the other scope variables.
Using your new custom controls is easy,
just add them to the bottom of any page where you need to keep an eye on
the scoped variables. If your only using the sessionScope on a page then
you just need to add that custom control, if your making use of the requestScope
then just include that custom control.
I also like to create a new xPage in
my applications called ‘debug’ where I put in the custom controls for the
application and session scopes for easy access to them.
Don’t forget to remove ( or hide ) the
debug info before releasing your application.