问题
This question on StackOverflow got me interested into Themes. But the example in the question just assigns a CSS class in theme file to a themeId which is in turn assigned to the element with respective themeId on XPage. I could also directly assign the class name to component in XPage.
So my first question is what benefit does a theme bring to an XPage?
I was trying to explore what other properties could be assigned via themes and it seems we can assign other properties like valign
and style
in the theme file like this:
<control>
<name>HtmlTd</name>
<property>
<name>styleClass</name>
<value>tdclass</value>
</property>
<property>
<name>style</name>
<value>font-family: Courier</value>
</property>
<property>
<name>valign</name>
<value>top</value>
</property>
</control>
The above code actually sets the valign
and style
for all the <td>
tags in XPage. So my second question is what all properties could be set via themes?
回答1:
Themes are very powerful. Almost every control in XPages is really a bean meaning that you can set almost all of its properties using themes (see clarification of this in the answer from Paul).
Here some useful resources:
- Tim Tripcony has created a presentation called Taking Themes to the Next Level which highlights some of the powerful features of themes.
- The XPageswiki.com has a page on themes
回答2:
Just to clarify Per's answer, you can set almost everything. That's because the theme gets applied during the Render Response phase.
You can't override properties on the XPage with SSJS set to run on page load. That's because a static value is set, so no runtime bindings get applied.
You can't set anything that needs to be known before Render Response, e.g. the var property of a repeat control.
Render Response phase is why it's better for performance. If you use SSJS to compute a value on an XPage, it gets calculated a number of times during the partial refresh. If it's in a theme, it's only calculated during Render Response.
To look at examples of themes in action, look at OpenNTF and look at dPloy project by Tim and XPages Help Application by me.
来源:https://stackoverflow.com/questions/12634351/benefits-of-using-themes-in-xpages