0

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>
djmj
  • 5,579
  • 5
  • 54
  • 92
  • That can happen if this is placed inside an ``. Is this true? – BalusC Aug 15 '16 at 18:00
  • Not directly. It is within a primefaces `p:tabView`. – djmj Aug 15 '16 at 18:27
  • And `#{bean}` represents its `var`? The `` has this bug solved since 2.2.7, see also http://stackoverflow.com/q/22613193 – BalusC Aug 15 '16 at 18:27
  • it is a variable of the include file. I edited my question with further markup. – djmj Aug 15 '16 at 18:31
  • Do you have a stack trace at hand? `rendered='false'` usually is respected by the HTML code renderer and the `decode` method of input fields, but maybe something else tries to evaluate the expression. – Stephan Rauh Aug 15 '16 at 22:14

0 Answers0