'OmniFaces importConstants not available on ui:param

I have a web application currently deployed on Wildfly 26.1.0, using JSF 2.3 and OpenJDK 11. I'm also using the latest version of OmniFaces (3.13.3).

I'm trying to pass via ui:param a constant field value, and I'm experiencing a strange behaviour.

When I declare o:importConstants on the layout, or even on the composition, the value is never available on ui:param. However, if I change it to f:importConstants (inside f:metadata) everything works as I expected.

Layout

<!DOCTYPE html>
<html xmlns="http://www.w3.org/1999/xhtml"
      xmlns:ui="http://xmlns.jcp.org/jsf/facelets"
      xmlns:f="http://xmlns.jcp.org/jsf/core"
      xmlns:h="http://xmlns.jcp.org/jsf/html"
      xmlns:o="http://omnifaces.org/ui">

    <o:importConstants type="com.mytest.AvailableOutcomes" />
    
    <h:head>
        <meta charset="utf-8" />
    </h:head>
    
    <h:body>

        Layout outcome 1: #{outcome}

        <ui:insert name="content" />

        Layout outcome 2: #{outcome}

    </h:body>
</html>

Composition

<ui:composition xmlns="http://www.w3.org/1999/xhtml"
                xmlns:h="http://xmlns.jcp.org/jsf/html"
                xmlns:f="http://xmlns.jcp.org/jsf/core"
                xmlns:ui="http://xmlns.jcp.org/jsf/facelets"
                xmlns:o="http://omnifaces.org/ui"
                template="/faces/tst/importConstantsTestLayout.xhtml">

    <o:importConstants type="com.mytest.AvailableOutcomes" />
    
    <ui:param name="outcome" value="#{AvailableOutcomes.INDEX}" />

    <ui:define name="content">

        My outcome is #{outcome}

    </ui:define>

</ui:composition>

Ouput

Layout outcome 1: <empty>

My outcome is <empty>

Layout outcome 2: <empty>

Working version

Layout

<!DOCTYPE html>
<html xmlns="http://www.w3.org/1999/xhtml"
      xmlns:ui="http://xmlns.jcp.org/jsf/facelets"
      xmlns:f="http://xmlns.jcp.org/jsf/core"
      xmlns:h="http://xmlns.jcp.org/jsf/html"
      xmlns:o="http://omnifaces.org/ui">

    <h:head>
        <meta charset="utf-8" />
    </h:head>
    
    <h:body>

        <ui:insert name="content" />

    </h:body>
</html>

Composition

<ui:composition xmlns="http://www.w3.org/1999/xhtml"
                xmlns:h="http://xmlns.jcp.org/jsf/html"
                xmlns:f="http://xmlns.jcp.org/jsf/core"
                xmlns:ui="http://xmlns.jcp.org/jsf/facelets"
                xmlns:o="http://omnifaces.org/ui"
                template="/faces/tst/importConstantsTestLayout.xhtml">

    <f:metadata>
        <f:importConstants type="com.mytest.AvailableOutcomes" />
    </f:metadata>
    
    <ui:param name="outcome" value="#{AvailableOutcomes.INDEX}" />

    <ui:define name="content">

        My outcome is #{outcome}

    </ui:define>

</ui:composition>

Output

My outcome is index

I would prefer using omnifaces importConstants so I can declared only once and use across all pages.

I'm not sure if this is the expected behaviour, or a bug. If someone could shed a light, I would appreciate.

Thanks in advance for your help!



Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source