Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

JSF rendered question

Tags:

el

jsf-2

Is EL-parsing of children to elements with rendered="false" really supposed to be evaluated? This is causing me alot of trouble with null pointer exceptions and similar. Looking at the following example:

<p:tab title="#{userCompetenceController.getTreeName(3)}" rendered="#{!empty userCompetenceController.getTreeName(3)}">
  <xdin:competenceTable id="competenceBox3"
                        profile="#{userCompetenceController.selectedProfile}"
                        tree="#{userCompetenceController.getCompetenceTree(3)}"
                        maxHeight="500px"/>
</p:tab>

The main issue (besides performance) is that xdin:competenceTable does not support a null tree-attribute. getTreeName(int index) returns null in this case, and is followed by a call to getCompetenceTree(3) which returns null, even though its parent (p:tab) has rendered="false"

In short: xdin:competenceTable is parsed by EL even though it's parent has rendered="false". Why?

like image 784
Rasmus Franke Avatar asked May 11 '11 07:05

Rasmus Franke


1 Answers

Take a look at the JSF lifecylce below.

Rendering is only the last phase, and rendered="false" only affects that last phase, while errors in constructing a component happen in the first.

Non-rendered components should in fact not do anything during all phases, but it looks as though your component does not conform to that part of the spec.

enter image description here

like image 93
Michael Borgwardt Avatar answered Nov 15 '22 07:11

Michael Borgwardt