When you write #{myBean.salute}
, JSF is looking for the property salute
. In Java code, it is "translated" to myBean.getSalute();
. In others words, you have to provide the getter for this property (and eventually the setter if this property can be modified by JSF, when it is used in an input field for example).
When you write #{myBean.salute()}
you are referring to the method salute()
.
The rule is quite simple: use a method when you want to do an action (i.e. generally it will be defined inside an action
or actionListener
attribute). In the others cases, use a property.
In your example, you want to display some text in your page, so instead calling #{myBean.salute()}
, just call #{myBean.salute}
.
For the second point, try to change your code to access the property something
instead of the method:
<!-- Using a method from an injected bean-->
#{bba.b.something}
and in BeanB
code:
public String getSomething() {
System.out.println("Hello!!!");
return "I am a SessionScopped Backing Bean, my name is 'B' and i am doing something";
}
Regarding your last point, I think that your Eclipse simply doesn't handle the EL 2.0 syntax.
与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…