How to use ui:include with parameters?

前端 未结 2 356
Happy的楠姐
Happy的楠姐 2021-02-01 15:20

Have JSF 1.2 two pages(one.xhtml and other.xhtml),
that are included to the current page by following rule:

...
    

        
相关标签:
2条回答
  • 2021-02-01 15:54

    In addition to BalusC's answer:

    Note that this only supports strings, not action methods. For the latter you would need to upgrade to JSF 2.0 and use composite components.

    There is a way to do this with JSF 1.2, though it's somewhat ugly:

    <ui:include src="general.xhtml">
        <ui:param name="actionBean" value="#{myBackingBean}" />
        <ui:param name="actionMethod" value="edit" />
    </ui:include>
    

    and

    <h:commandButton action="#{actionBean[actionMethod]}" />
    
    0 讨论(0)
  • 2021-02-01 16:10

    You need to nest <ui:param> inside <ui:include> to pass parameters to the included file.

    <ui:include src="general.xhtml">
        <ui:param name="action" value="actionOne" />
    </ui:include>
    

    and in the include:

    <h:commandButton action="#{action}" />
    

    Note that this only supports strings, not action methods. For the latter you would need to upgrade to JSF 2.0 and use composite components.

    0 讨论(0)
提交回复
热议问题