In my application I wanted to bind a
viewScope variable with the field, but the key was not static. The
viewScope key was generated based on some business logic. To solve this problem, I created a
dataContext variable (whose name is constant) and computed the value of this (data context) variable. I wrote the code there to calculate the key name. Finally I binded the field with the
viewScope variable as follows:
The field binding:
Same technique can be extended to other objects like NotesDocument, NotesViewEntry, etc.
Sometimes in XPage applications it happens that our code do not run due to validation errors.
It becomes really difficult to debug if the form contains too many fields. To simplify the debug process in this scenario I have written a code snippet which gives client id of the control for which validation is getting failed.
var itr:java.util.Iterator = facesContext.getClientIdsWithMessages();
var str:Array = ;
Today I observed runtime error in one of my XPage. I investigated later and found that the error is occuring on a custom control which should not be rendered in this scenario. I have several custom controls added on my XPage and display only one custom control based on some condition, so I have computed the rendered property.
Now the question is, if the custom control is not rendered then why it is generating error?
I further investigated properties of the custom control and found there is a property “loaded”.
Rendered: it controls the visibility of the control, i.e., if it is true then the markup for this control will be added in the response.
Loaded: it controls the creation of control, i.e., if it is true then only the control is going to be created else it will not be created.
Coming to my problem, I moved my code from rendered to loaded property and everything is working fine. The custom control is not being created so there is no possibility of execution of any code inside that custom control.