This forum is closed to new posts and responses. Individual names altered for privacy purposes. The information contained in this website is provided for informational purposes only and should not be construed as a forum for customer support requests. Any customer support requests should be directed to the official HCL customer support channels below:

HCL Software Customer Support Portal for U.S. Federal Government clients
HCL Software Customer Support Portal



Feb 20, 2012, 3:17 PM
30 Posts
topic has been resolvedResolved

Theme and inheritance: Append values, not replace - possible?

  • Category: Styles and Themes
  • Platform: All
  • Release: 8.5.3
  • Role: Developer
  • Tags: theme,control,viewroot,inherit
  • Replies: 3
 I have two themes: One boilerplate and another one that extends that.
 
In the boilerplate I add different classes to the BODY-tag depending on what version of IE is accessing the page. Like so: 
 
 <control>

<name>ViewRoot</name>

<property

mode="concat">

<name>styleClass</name>

<value>#{javascript:(context.getUserAgent().isIE() ? 'ie' + context.getUserAgent().getBrowserVersionNumber().toString().split('.')[0] + ' ': '')}</value>

</property>

</control>

 
 
In my next time I wish to build on this and adding to the BODY-class the CSS-class of my theme, like so: 
 

<control>

<name>ViewRoot</name>

<property

mode="concat">

<name>styleClass</name>

<value>claro</value>

</property>

</control>
 
 
I expect the end result would be for IE9: 
 
body class="ie9 claro" 
 
But all I get is: 
 
body class="claro" 
 
 
How can I append the values? 
 

Thanks! 
 
/J 
Feb 20, 2012, 4:13 PM
14 Posts
Re: Theme and inheritance: Append values, not replace - possible?
Don't use two "<control>" nodes but two "<property>" nodes in the same "<control>" node.
 
So instead of : 
 
<control>

<name>ViewRoot</name>

<property mode="concat">

<name>styleClass</name>

<value>#{javascript:(context.getUserAgent().isIE() ? 'ie' + context.getUserAgent().getBrowserVersionNumber().toString().split('.')[0] + ' ': '')}</value>

</property>

</control>

 
 
 <control>

<name>ViewRoot</name>

<property mode="concat">

<name>styleClass</name>

<value>claro</value>

</property>

</control>
 
 
use : 
 
<control>

<name>ViewRoot</name>

 

<property mode="concat">

<name>styleClass</name>

<value>#{javascript:(context.getUserAgent().isIE() ? 'ie' + context.getUserAgent().getBrowserVersionNumber().toString().split('.')[0] + ' ': '')}</value>

</property>

 

<property mode="concat">

<name>styleClass</name>

<value>claro</value>

</property>

 
</control>
 
and you will get what you expect. 
 
Hope this helps. 
 
Renaud 
 
Feb 20, 2012, 4:58 PM
30 Posts
Re: Theme and inheritance: Append values, not replace - possible?
 It's two separate themes where I reference the control, so I can't have one control-node.
 
 
In theme "A" I compute the IE-version and sets a class on the BODY-tagg.
 
Theme "B" inherits theme "A" and sets another class on the BODY-tagg.
 
 
The application uses theme "B". 
 
The class from theme "A" is overwritten with the values from theme "B". 
 

Thanks! 
 
 
/J 
Feb 21, 2012, 8:18 AM
30 Posts
Re: Theme and inheritance: Append values, not replace - possible?
 OK - Solved!
 
 
This is somewhat of a hack, so brace yourself... ;-) 
 
 
Turns out that you can't append values for the same property of a control. This is a bummer and, in my humble opinion, takes a big bite out of the purpose of inheritance with themes.
 
 
So, hack it! 
 
 I discovered that if the extending theme has the same control and setting the same property any SSJS in the original theme for that same property is never executed. Hence the proof that you can't append...
 
But we can use another property to calculate our SSJS and store it in i scopedVariable for later retrieval in our extending theme, but what property?
Every time you use inline styling a kitten dies! So the style-property should always be empty - the perfect candidate!
 
boilerplate.theme: 

<control>

<name>ViewRoot</name>

<property>

<name>style</name>

<value>#{javascript:requestScope.put('isIE' ,(context.getUserAgent().isIE() ? 'ie' + context.getUserAgent().getBrowserVersionNumber().toString().split('.')[0] + ' ': ''))}</value>

</property>

</control>
 
For IE9 it would store "ie9" in the requestScope isIE variable. (I'm only interested in major release number of the browser)
 
 
In the extending theme: 
 

<control>

<name>ViewRoot</name>

<property mode="concat">

<name>styleClass</name>

<value>#{javascript:requestScope.get('isIE') + ' claro'}</value>

</property>

</control> 
 
So, again, for IE9 the class of the BODY-tag would read: body class="ie9 claro" 
For Chrome: body class=" claro" 
 
 
Case closed! 
 
 
/J 
 

This forum is closed to new posts and responses. Individual names altered for privacy purposes. The information contained in this website is provided for informational purposes only and should not be construed as a forum for customer support requests. Any customer support requests should be directed to the official HCL customer support channels below:

HCL Software Customer Support Portal for U.S. Federal Government clients
HCL Software Customer Support Portal