Search code examples
jsfjsf-2jstlfacelets

What is the alternative to <c:set> after the view is built?


what is the alternative to <c:set> after the view is built ? Generally <c:set> works when the view is being built. After that, how do I change that ?

For example, what would be the equivalent of the following in JSF tag ? The following property is just not set after the view is built.

<c:set property="showPromoDetails" target="#{viewScope}" value="null" />

Solution

  • I'll assume JSF 2.x. Put this somewhere in the view, the common convention is somewhere near the top.

    <f:metadata>
        <f:event type="preRenderView" listener="#{viewScope.preRenderView}" />
    </f:metadata>
    

    with

    public void preRenderView() {
        showPromoDetails = null;
    }