PermaLink XPages: The View article(s) - How to Compute a Custom Control at Runtime09/13/2009 10:40 AM
Domino 8.5
I recently had 2 articles published in The View that demonstrate how to compute which custom control to display at runtime based on a formula.  This is similar to using a computed subform in traditional Notes/Domino development.  

The first article provides the technical overview on how to accomplish this using a built-in XPages feature.  The second article expands on the first by enhancing the custom control to allow the use of parameters so that it can be re-used in any of your applications.

Here's a synopsis of the articles.  (the full articles require a subscription login)

XPages — How to Compute a Custom Control at Runtime
     
       
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.
 
XPages — A Reusable Solution for Computing a Custom Control at Runtime
In XPages development, you use a custom control when you have a group of fields or functionality that you want to reuse on other XPages within your application. In an earlier article (THE VIEW, 2009) I showed you how to use a custom control that computes which custom control to display on an XPage at runtime, similar to using computed subforms in Domino Designer.

Now I’ll show you how to enhance that custom control so you can reuse it in any XPages application to compute any custom control at runtime. Plus, I’ll show you how to create custom control properties for parameters that can be accessed with serverside JavaScript. Learning how to parameterize your custom controls will enable you to build your own library of reusable controls for rapid application development.

-John


Technorati:
This page has been accessed 546 times. .
Comments :v

1. Vitalijs10/16/2009 09:26:52 AM


This is very simple technique.
1. create a repeater
2. put there include page control (<xp:include pageName='${javascript:"test_IncludeControl.xsp"}' id="include1"></xp:include>)
3. compute control name adding at the end .xsp

P.S. include page not ony can include pages, but also custom controls.




Search
Partner with us
Need help on your XPages projects?

Talk to the experts! Read more...
XPage Examples
By Category
About Me
Downloads
My Links
Monthly Archive
Powered by
Blogsphere
Lotus Domino ND7 RSS News Feed RSS Comments Feed Geo URL netcraft RSS Validator Lotus Geek Chris. A. Brandlehner OpenNTF BlogSphere