0

I have this MyHumbleTO which attribute is read on a JSF page. So I need to add isTheAwesomeBoolean Method to use elsewhere. But now the page is reading that new method instead the get method, which is inappropriate. Is there a way to ignore that in page?

<h:outputText value="#{myAwesomeBean.myHumbleTO.theAwesomeBoolean ne null ? 
                    (myAwesomeBean.myHumbleTO.theAwesomeBoolean ? 'Yes ' : 'No') : ''}" />


public class MyHumbleTO implements Serializable{

    private Boolean theAwesomeBoolean;

    public boolean isTheAwesomeBoolean() {
        return Boolean.TRUE.equals(theAwesomeBoolean);
    }

    public Boolean getTheAwesomeBoolean() {
        return theAwesomeBoolean;
    }
}
alexpfx
  • 6,412
  • 12
  • 52
  • 88

2 Answers2

1

With recent EL (Version >= 2.2) just use getTheAwesomeBoolean() (see this answer for details).

In the given example:

<h:outputText value="#{myAwesomeBean.myHumbleTO.getTheAwesomeBoolean() ne null ? 
        (myAwesomeBean.myHumbleTO.theAwesomeBoolean ? 'Yes ' : 'No') : ''}" />
DaniEll
  • 1,022
  • 4
  • 22
  • 31
1

First of all, If you'd try to debug this, you will find out, that this is all about EL implementation, not JSF.

Since there is a right answer from DaniEll for exactly what you pasted in XHTML, I'll answer differently.

No, there is no way to favor one or another. Especially it will never work if you would like to use this in an input. You cannot bind value property like that. And I'd avoid mixing simple types with class types in such cases (boolean/Boolean, int/Integer etc.).

Emil Sierżęga
  • 1,785
  • 2
  • 31
  • 38