Question

There are many tutorials on the internet where component object on JSF page is used. Usually component.clientId or component.valid are used. Example

<h:inputText .... styleClass="#{component.valid ? '' : 'ui-input-invalid'}"/>

If i create page with such component, i get an error:

javax.el.PropertyNotFoundException: 
The class 'javax.faces.component.UIPanel' does not have the property 'valid'.

I googled that for inputText should be there UIInput class (which has isValid method), but i have there UIPanel (which dasn't).

Any idea why is there UI Panel? (Java EE 6, JSF 2.1, Weblogic 12.1.2)

Was it helpful?

Solution

Whether or not a single component is valid is irrelevant in the long run; the entire request will be marked as invalid, even if it's as a result of the failure of a single component.

You should be retrieving the status of a request on the facesContext implicit EL object

<h:inputText .... styleClass="#{facesContext.validationFailed ? '' : 'ui-input-invalid'}"/>

Nothing I've seen in the 2.1 or 2.2 API supports the the presence of a valid attribute for the component implicit EL object. It's an implementation of javax.faces.component.UIComponent

Reference:

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top