【发布时间】:2014-10-31 02:37:30
【问题描述】:
你知道我的应用为什么会抛出这个异常吗:
WARNING: /myProfile.xhtml @71,27 target="#{profileBean.selectedUser}": Property 'selectedUser' not found on type bg.fmi.master.thesis.beans.ProfileBean
javax.el.PropertyNotFoundException: /myProfile.xhtml @71,27 target="#{profileBean.selectedUser}": Property 'selectedUser' not found on type bg.fmi.master.thesis.beans.ProfileBean
---
Caused by: javax.el.PropertyNotFoundException: Property 'selectedUser' not found on type bg.fmi.master.thesis.beans.ProfileBean
当我的 bean 中有这个属性时:
@ManagedBean(name = "profileBean")
public class ProfileBean implements Serializable {
private TUser selectedUser = new TUser();
public TUser getSelectedUser() {
return selectedUser;
}
public void setSelectedUser(TUser selectedUser) {
this.selectedUser = selectedUser;
}
.xhtml 代码是这样的:
<p:dataGrid var="user" value="#{profileBean.userList}">
<p:panelGrid columns="2">
....
<p:commandButton id="submit" value="Save changes" actionListener="#{profileBean.editUser()}" >
<f:setPropertyActionListener target="#{profileBean.selectedUser}" value="#{user}" />
</p:commandButton>
</p:dataGrid>
提前致谢!
【问题讨论】:
-
代码看起来不错。您很可能没有运行您认为正在运行的代码。也就是说,您的环境似乎支持 EL 2.2。为什么不只是
action="#{profileBean.editUser(user)}"而不是这个听众混乱? -
它再次抛出异常:原因:javax.el.MethodNotFoundException:/myProfile.xhtml @73,53 action="#{profileBean.editUser(user)}":找不到方法:bg。 fmi.master.thesis.beans.ProfileBean@11e9862.editUser(bg.fmi.master.thesis.model.TUser)。我也编辑了我的方法。在你关于类似问题的一篇文章中,写到 f:attribute 可以使用,我设法使它与这个代码一起工作
但我仍然不清楚为什么它不能以上述其他方式工作。 -
您很可能没有运行您认为正在运行的代码。
-
我怎样才能知道我到底在运行什么?
-
日志中除了这个还有其他错误吗?
标签: jsf jsf-2 primefaces el