【发布时间】:2012-10-07 10:13:17
【问题描述】:
我想知道是否可以从问题nesting-jsf-expression-strings 中调整 ExtendedBeanELResolver 来处理这个嵌套的 EL 表达式:
#{controllerBean.getBean('userProfileBean', component).street}*
其中 controllerBean.getBean 返回 bean userProfileBean。我将得到 ExtenedBeanELResolver 以下异常:
SCHWERWIEGEND: javax.el.PropertyNotFoundException: /WEB-INF/templates/modification/userProfile.xhtml @35,196 value="#{controllerBean.getBean('userProfileBean', component).street}": Property 'getBean' not found on type com.something.ControllerBean
如果我插入额外的括号它可以工作,但看起来比现在更难看:
#{(controllerBean.getBean('userProfileBean', component)).street}*
是否可以不用额外的括号?
CycDemo 回答后更新 1:
奇怪的问题。 如果我把
<h:inputText value="#{beanOne.getBean('data').title}" />
inside 页面呈现的表单,但仅在我提交表单之前。之后将显示相同的错误。
WARNUNG: /WEB-INF/templates/home.xhtml @61,66 value="#{beanOne.getBean('data').title}": Property 'getBean' not found on type com.something.BeanOne
如果我把它改成
<p:inputText value="#{beanOne.getBean('data').title}" />
页面甚至不会在开始时呈现。 我认为问题在于 JSF 在提交表单时尝试调用 setter 但无法正确评估它。
有什么想法吗?
更新 2
显然 JSF 正在尝试调用 getGetBean(),因为它正在 BeanOne 上寻找 property(我在 eclipse 中有一个断点) ) 这是错误的:
@ManagedBean
@ViewScoped
public class BeanOne {
private Object bean = new String("something");
public Object getBean(String name) {
FacesContext context = FacesContext.getCurrentInstance();
return context.getApplication().evaluateExpressionGet(context,
"#{" + name + "}",
Object.class);
}
public Object getGetBean() {
return bean; // <-- will be called by JSF
}
public void setGetBean(Object bean) {
this.bean = bean;
}
}
【问题讨论】:
-
您又遇到了哪个错误?提交您的理由;
标签: java jsf jsf-2 primefaces el