Pages

Monday, January 31, 2011

How To Add Style Sheet URL Dynamically To XPages? (xp:headTag)

The following is a way using which u can include style sheets into xpages in a dynamic fashion. Yes it lets you compute style sheet URL in the XPage.

Note the usage of the scoped variables along with custom text in constructing the url of the style sheet

<xp:headTag tagName="link" rendered="true" loaded="true">
   <xp:this.attributes>
         <xp:parameter name="rel" value="stylesheet"></xp:parameter>
         <xp:parameter name="type" value="text/css"></xp:parameter>
         <xp:parameter name="href" >
         <xp:this.value>
<![CDATA[#{javascript:return applicationScope.get("scopeVariableNameContainingURL")+"leftouturl/filename.css"}]]>
</xp:this.value>
         </xp:parameter>
     </xp:this.attributes>
</xp:headTag>



To know about including client side script libraries in a similar fashion click here
Hope this helps :)

No comments:

Post a Comment