开发者

Can we use ui:include in JSF to display a component?

I am new to JSF and I am trying to display a JSF2 component with ui:include

<ui:include src="myComponent.xhtml">
    <ui:param name="attr" value="aValue"/>
</ui:include>

The component is successfully displayed but the开发者_高级运维 param is not passed to the JSF2 component. the attribute attr is defined in the interface of the component.

It works if I use my component this way:

<ez:myComponent attr="aValue"/>

The point in using ui:include is to use something like that:

<ui:include src="#{componentName}"/>

Am I doing something that is not supported or is there another way to display my component and have the parameters filled?

I am using GlassFish v3.

Thanks in advance.


from my understanding of ui:param you should be able to acess the value of the ui:param in myComponent.xhtml by using #{attr} which by using param name check this out https://facelets.dev.java.net/nonav/docs/dev/docbook.html#template-param


Based on the comments in Inv3r53's answer: Periods have a special meaning in expression language to evaluate chains of expressions. If you want your page to be both standalone and used as a component then use a c:set (JSF 2 doc) outside of your composition tags to set cc.attrs.attr to attr. The set will be used if standalone, but left out when included (only the stuff between the composition tags is included).

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜