@ManagedBean("myBean")
public class MyBean {
public String getId(String name) {...}
}
#{myBean.id('foo')}
JSF trying to resolve MyBean.getId('foo')(). How to pass parameter to value expression?
JSF 2.2.
Tried: #{myBean.getId('foo')}, not working. JSF tried to resolve MyBean.getGetId('foo')().
The first issues is the
@ManagedBeanannotation. If you're on JSF 2.2, you should not be using@ManagedBeanas those have been sunset for a few years. Instead, use the modern CDI annotations that have a well-defined scope.Try the following instead:
Next with the EL expression, invoke the
getId()function like this:You cannot use property-like expressions because the
getId(...)method takes an argument and does not follow the JavaBean standard (see here: https://docs.oracle.com/en/java/javase/17/docs/api/java.desktop/java/beans/Introspector.html)You could theoretically create your own
ELResolverthat supported this if you wished. (https://subscription.packtpub.com/book/business-&-other/9781782176466/1/ch01lvl1sec13/writing-a-custom-el-resolver)