Eclipse errors on #{component.valid}: "valid cannot be resolved as a member of component”
Asked Answered
Z

1

3

I've the below piece of code in a JSF page:

<p:inputText ...
    styleClass="labelledInput-input #{component.valid?'':'validation-failed'}"/>

Eclipse produces an error on component.valid part as below:

valid cannot be resolved as a member of component

How can I solve this?

Zelmazelten answered 11/8, 2015 at 11:53 Comment(0)
O
2

This is a known issue in Eclipse versions older than Mars. Eclipse isn't smart enough to determine that #{component} in this particular case actually references UIInput subclass and incorrectly thinks all time that it's UIComponent superclass, which indeed doesn't have a isValid() property. You can basically just ignore'n'run it. It's a false error and everything should work just fine.

If you want to get rid of the false error and can't upgrade to Mars, then go to Window > Preferences > Web > JavaServer Faces Tools > Validation, unfold Type Coercion Problems and set Unary operation boolean coercion problems to Ignore.

enter image description here

Screenshot borrowed from this blog in all courtesy.

While you're at it, also do the same for Unary operation number coercion problems. This should prevent same errors on same kind of EL operations on number based properties not defined in the abstract superclass.

Octroi answered 11/8, 2015 at 12:17 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.