XPages — How to Compute a Custom Control at Runtime

John Mackey, president, Groupware Solutions Inc.


June, 2009


Learn how to compute a custom control on an XPage at runtime based on some criteria or a calculation. Similar to using computed subforms in Domino Designer, with this technique you can calculate which custom control to display to the user. Get the complete example code from the download database.


When Domino developers first start exploring XPages, they naturally tend to compare the new XPages controls and functionality with traditional IBM Lotus Notes and Domino development: “I know what I want to do and how I would have accomplished it with Domino Designer. Now how do I do it in XPages?”
Take the concept of a Notes computed subform. I have heard many developers asking how this is handled in XPages. While many Notes concepts are handled the same way in XPages as in traditional Notes development, the computed-subforms concept is not one of them.
The XPages design component that most closely corresponds with subforms is the custom control. You use a custom control where you have a group of fields or functionality that you want to reuse on other XPages within your application. Once created, a custom control shows up in the Controls palette. Then you can drag and drop the control onto any XPage in your application.
In Notes, you can compute which subform to include on a form based on a formula. Computing which subform to include at runtime is an easy way to tailor the form and functionality without having to maintain numerous hide/when formulas. This is a very valuable feature for rapid application development. With XPages, however, there is no computed custom control. I’ll show you a technique to help you get functionality in XPages that is similar to computed subforms.

Would you like to see the full version of this article?

If you are an electronic license holder to THE VIEW, please log in to view this article.

If you would like information about becoming an electronic license holder — and having 24/7 unrestricted access to all articles and content in THE VIEW Online Knowledgebase — click here to see the available subscription options.

Or call 1-781-751-8813 to speak directly with a subscription and licensing specialist about customized access for you and your team.