rendered attribute not evaluated in include

118 views Asked by At

I have a include file with a parameter bean which I use for two concrete java BeanA and BeanB classes.

BeanB class has additional methods and therefore I check the render attribute to not access a method not available:

View:

<ui:include src="/inc_bean.xhtml">
    <ui:param name="bean" value="#{beanB}"/>
</ui:include>

Include File with var bean:

<p:tabView>
    <p:tab>
        <!-- content shall only be rendered if instance of BeanB -->
        <h:panelGroup rendered="#{bean.class.simpleName eq 'BeanB'}">
            <h:form>
                <h:inputText value="#{bean.propertyB}"/>
            </h:form>
        </h:panelGroup>
    </p:tab>
</p:tabView>

When I use the include with class BeanA I get following error at glassfish 4.1.1 and JSF mojarra 2.2.9:

The class 'BeanA' does not have the property 'propertyB'.

Workaround:

wrap the inner content in a new strongly typed (BeanB) composite.

Include File:

<p:tabView>
    <p:tab>
        <comp:beanB bean="#{bean}" rendered="#{bean.class.simpleName eq 'BeanB'}"/>
    </p:tab>
</p:tabView>
0

There are 0 answers