Search code examples
jsfparameter-passingfaceletsuiinclude

How to define custom navigation rules for included component?


I'm trying the include a component (with ui:include) and set a navigation rule for the caller page. The included component has a form; when submitted I want to display a feedback message (like growl) and conditionally display the included panel again.

What is the best way to achieve this?


Solution

  • You can use <ui:param> to let the caller specify custom parameters for an <ui:include>.

    <ui:include ...>
        <ui:param name="foo" value="..." />
    </ui:include>
    

    You could pass them through to the method in the <h:commandButton> of the include page.

    <h:commandButton ... action="#{bean.submit(foo)}" />
    
    public String submit(String foo) {
        // ...
    }