Facelets: ui:param default value
facelets, jsf
Solution
A default value can be defined by using a ternary operator checking for null value.
<h:outputText value="#{templParam != null ? templParam : 'Default value'}"></h:outputText>
This will print "Default value" if the parameter was not passed by a `ui:param` tag.
Problem
How can one define a default value for a facelet template parameter? Consider the following element using a template parameter: ``` <h:outputText value="#{templParam}"></h:outputText> ``` The above line will print the the template parameter `templParam` which is passed by a `ui:param` tag in a `ui:composition` using the template: ``` <ui:param name="templParam" value="Hello world"></ui:param> ``` But if `ui:param` tag is missing nothing will be printed. Although, how can one print e.g "Default value" in this case?