【发布时间】:2012-04-13 06:15:11
【问题描述】:
我有一个 html 页面(editprofile.xhtml),它显示了保存在数据库中的数据。我面临的问题是当我在屏幕上编辑一些数据并单击更新按钮时,编辑的数据不会进入 bean,它为 null 从而导致错误。
<h:form id="editProfileForm">
<f:facet name="label">
<h:outputText value="Edit User Profile" />
</f:facet>
<rich:panel header="Edit User Profile" style="font-size:10pt" >
<rich:simpleTogglePanel switchType="client" opened="true">
<f:facet name="header">Registration Details</f:facet>
<table>
<tbody>
<tr>
<td>Login Name</td>
<td>
<h:inputText size="15" id="loginName" required="true"
value="#{EditUserProfileBean.loginName}">
<rich:ajaxValidator event="onblur" />
</h:inputText>
</td>
<td></td>
<td>Password</td>
<td><h:inputSecret size="12" id="password" required="true"
value="#{EditUserProfileBean.password}" >
<rich:ajaxValidator event="onblur" />
</h:inputSecret>
</td>
<td>Confirm Password</td>
<td><h:inputSecret size="12" id="confirmpassword" required="true"
value="#{EditUserProfileBean.confirmpassword}" >
<rich:ajaxValidator event="onblur" />
</h:inputSecret>
</td>
</tr>
</rich:simpleTogglePanel>
<h:commandButton id="editProfile" action="#{EditUserProfileBean.saveEditProfileAction}" immediate="true" value="Update Profile" />
</rich:panel>
</h:form>
上面的页面在加载时填充了现有数据,但如果我编辑并说更新,则值为 null
【问题讨论】:
-
你是否在你的bean中为你想要传递的属性定义了setter?这个代码是sn-p的形式吗?提交表单的代码在哪里,还是ajax?
-
尝试从你的 commandButton 中删除 immediate="true"。
-
谢谢,它奏效了……但我很惊讶“立即”是如何负责的……
-
我将此作为答案发布,并附有解释。
标签: java jsf jakarta-ee jsf-2