tags:

views:

15

answers:

1

hi, there's a jsf page with a form:

....
<h:form>
 <h:commandLink action="#{userBean.logout}" value="Logout" />
</h:form>
....
<ui:repeat value="#{categoryBean.allCategories}" var="c">
....

The categoryBean.allCategories is a call to EJB which is based on a <f:param> from previous page acquired via @ManagedProperty. So when the user clicks on Logout, the whole page evaluates, but without the param and there's NullPointerException. Is there any possibility how to skip the evaluation?

A: 

Make use of the rendered attribute:

<h:panelGroup rendered="#{not empty param.name}">
    <ui:repeat value="#{categoryBean.allCategories}" var="c">
        ...
    </ui:repeat>
</h:panelGroup>

Alternatively you can also just do a nullcheck in getAllCategories() method.

if (param != null) {
    // Return it.
}
return null;
BalusC