Library similar to standard JSF composite API. It is based on Mojarra implementation, Myfaces are not supported. Unlike the standard composite components it:
- doesn't create a new component node in JSF component tree
- enables to wrap a non-component tag as the <p:ajax> or converters
The main purpose of Tagext library is making wrappers around JSF components in the same manner of JSF composite components does. Originaly the library was developed as an abstraction library to support migration from Richfaces to Primefaces.
Tagwrap library defines 4 tags corresponding to composite tags:
- <tx:compositeComponent> no correspondent composite tag
- <tx:interface> ~ <composite:interface>
- <tx:attribute> ~ <composite:attribute>
- <tx:implementation> ~ <composite:implementation>
Simple example of custom my:outputText definition :
<ui:composition>
<tx:compositeComponent>
<tx:interface>
<tx:attribute name="value" default="Hello world!"/>
</tx:interface>
<tx:implementation>
<h:outputValue value="#{__value}"/>
</tx:implementation>
</tx:compositeComponent>
</ui:composition>
Following fragment from JSF page:
<my:outputText/>;
shows "Hello world!" text.
Tagext maps all declared atributtes(tag parameters) from the interface block to variables in the implementation block using prefix "__" for variable names. Original attributes are hidden in the implementation section. This approach guaratees that no tag parameter is propagated to children components (that is big problem in Mojarra facelets components).
More advanced example:
<ui:composition>
<tg:compositeComponent>
<tx:interface>
<tx:attribute name="action" isMethodParam="true"/>
<tx:attribute name="actionListener"/>
<tx:attribute name="id" required="true"/>
<tx:attribute name="event"/>
<tx:attribute name="update"/>
<tx:attribute name="rendered" default="true"/>
<tx:attribute name="style"/>
<tx:attribute name="value"/>
</tx:interface>
<tx:implementation>
<p:commandLink id="#{__id}"
action="#{:invokeTagMethodExpression(__action)}"
update="#{__update}"
rendered="#{__rendered}"
style="#{__style}"
value="#{__value}">
<tx:ifExist value="__event">
<f:attribute name="event" value="#{__event}"/>
</tx:ifExist>
<tx:ifExist value="__actionListener">
<f:attribute name="actionListener" value="#{__actionListener}"/>
</tx:ifExist>
<ui:insert/>
</p:commandLink>
</tx:implementation>
</tx:compositeComponent>
</ui:composition>
2.Another handlers:
- <tx:ifExist var="xyz"> checks if variable is defined. It is similar to <c:if test="#{!empty xyz}> that checks the emptiness of variable "xyz". Unlike c:if the tx:ifExists checks if variable exists at all.
- <tx:eval> expression="#{value_expression}" Evaluates specified value expression.
- <tx:setVar>