Quantcast
Channel: XPages - Runtime
Viewing all articles
Browse latest Browse all 15

Choosing between xpages controls and plain html elements

$
0
0
It is better to use plain HTML elements as far as possible inside your xpages/custom control markup. For example, if you don't need to do a partial refresh of a DIV or you don't need to work with that DIV on the server side at all, you better use the plain div instead of the xp:div. The same is true with any other html elements. This will reduce the number of component objects the JSF tree has to maintain on the server and understandably will improve the performance. (Before JSF 1.2 it was not recommended to mix in JSF and plain html tags)

Having said that, how do you know if a div is going to be accessed on the server side right when you design the page!! What I do is to start with plain html elements for which it is less likely to have an associated server side code (like partial refresh/onclick event) and then convert it to a xpages tag later when I discover it needs some server side handling.

There are some instances where you need to do some server side computing while rendering the plain html code to the browser. For instance, if I need to render a plain html div tag (because I don't have any server side code attached to it) with some attributes computed based on some business logic. You can do something like the following.

 div class="row" me="customer" myid="#{javascript:entryCustomer.getKey()}" parid="#{javascript:entryCompany.getKey()}">  
<!-- some other controls or contents go here -->
</div>

I am sure I tried something like this in version 8.5.1 and it didn't like it. Since then I was thinking that a server side evaluation won't work other than on a standard xpage control. Just out of curiosity I tried it today, and it works. Very cool, now I can replace a lot of xpages controls with plain html controls.

Viewing all articles
Browse latest Browse all 15

Latest Images

Trending Articles





Latest Images