user684434
user684434

Reputation: 1165

JSF2 ui:include pass variable number of input param

We have a common component ,where the number of buttons or checkbox varies and also the labels. Can i have a common include file and pass param which can vary. In the include file ,is there a way to find how many number of input param and based on that render as many number of buttons or checkbox..

Upvotes: 3

Views: 2793

Answers (1)

BalusC
BalusC

Reputation: 1108632

You can use <ui:param> to pass parameters to the include file.

<ui:include src="/WEB-INF/includes/some.xhtml">
    <ui:param name="number" value="3" />
</ui:include>

The parameter value is in the above particular example available as #{number} in some.xhtml.

An alternative is to register the include file as a tag file in a .taglib.xml file:

<tag>
    <tag-name>some</tag-name>
    <source>/WEB-INF/tags/some.xhtml</source>
</tag>

Then you can specify the parameter as a tag file attribute:

<my:some number="3" />

It's this way also available as #{number} inside some.xhtml.

Upvotes: 5

Related Questions