5.2 FacesInspectionResultProcessor

FacesInspectionResultProcessor processes the inspection result and evaluates any expressions of the form #{...} using JSF EL. For example:

<entity type="com.myapp.Person">
	<property name="pension" hidden="#{!person.retired}"/>

FacesInspectionResultProcessor would update this inspection result's hidden attribute based on evaluating the JSF expression #{!person.retired}. It could be used to show/hide the pension field in response to the retired checkbox being checked.

Arrays and collections are also supported:

<entity type="com.myapp.Person">
	<property name="pension" lookup="#{person.arrayOfValues}"/>

The JSF expression language also supports branching statements. For example:

import org.metawidget.inspector.annotation.*;

public class ContactBean {

	@UiLabel( "#{contact.readOnly ? 'Back' : null}" )
	public void cancel() { ... }

FacesInspectionResultProcessor would update the label of this action to be either 'Back' or default to 'Cancel', depending on whether the Contact was being edited. It is taken from the JSF Address Book sample (see Section 1.3.2, “Web Address Book”).

If FacesInspectionResultProcessorConfig.setInjectThis is set, a special request-level _this attribute (the underscore is needed because this is a reserved word in EL) is injected into the FacesContext. JSF EL expressions rely on the JSF context being properly initialized with certain managed bean names. This is rather brittle. Instead, injecting _this allows the EL to refer to the originating object (i.e. #{_this.name}) regardless of how the JSF context is configured.

However injectThis cannot be used within attributes such as faces-lookup. Those attributes map to well-defined places within the JSF framework (i.e. f:selectItems) and are evaluated at a different phase of the JSF lifecycle. In some cases they will skip invoking FacesInspectionResultProcessor. For example if a h:selectOneMenu fails to validate during POSTback, its f:selectItems will be redisplayed without a new inspection and with no chance to injectThis.