JSF component binding without bean property

It’s been put in the default EL scope during building of the view tree (that’s when all binding attributes — and attributes of tag handlers like JSTL <c:xxx> and JSF <f:xxx> — are being evaluated). It’s being shown by normal EL means during rendering of the view tree. Rendering of the view tree happens after building of the view tree, so it works that way. It’s not that this code runs “line by line” as you seemed to expect from the source.

I can’t point you out a single reference where it’s been specified as there is none. You’d have to read both the EL spec and JSF spec separately and do a 1+1=2.

By the way, to avoid confusion among new developers and to avoid clashes with existing variables in the EL scopes, you can use a java.util.HashMap in the request scope which is been declared as follows in faces-config.xml:

<managed-bean>
    <description>Holder of all component bindings.</description>
    <managed-bean-name>components</managed-bean-name>
    <managed-bean-class>java.util.HashMap</managed-bean-class>
    <managed-bean-scope>request</managed-bean-scope>
</managed-bean>

and is been used as follows

#{components.aaa.id}
<h:inputText id="txt1" binding="#{components.aaa}"/>

which is more self-documenting.

See also:

Leave a Comment