我正在使用PrimeFaces 5.1,我有一个字段累积指示器,它是Y / N /选择的选择下拉菜单,当我将值更新为Y / N时编辑/更新发生正常,但是当我选择选择时作为下拉值,它不会将其更新为null。我能够从后端将值设置为null。当我选择select作为下拉值时,它应该更新为null,而不是它显示保存在数据库中的先前值(Y / N)。下面是我的代码xhtml,java bean和更新查询。请告知为什么它不将值更新为null值。
我尝试将下拉值itemValue ="#{null}"但这并没有像本文中提到的那样工作如何使用selectone下拉保存Null值
下面是我的xhtml:
<p:column headerText="Cumulative Indicator" width="60">
<p:cellEditor>
<f:facet name="output">
<h:outputText value="#
{AcctRefRecord.cumIndicator}" />
</f:facet>
<f:facet name="input">
<h:selectOneMenu value="#{AcctRefRecord.cumIndicator}"
label="Cumulative Indicator">
<f:selectItem
itemLabel="--Select--" itemValue="" />
<f:selectItem
itemValue="Y" />
<f:selectItem
itemValue="N" />
</h:selectOneMenu>
</f:facet>
</p:cellEditor>
</p:column>
<p:dataTable id="dtable" var="AcctRefRecord"value="#
{AcctRefMBean.
AcctRefRecords}" editable="true"
paginator="true" rows="10"
paginatorTemplate="{CurrentPageReport} {FirstPageLink}
{PreviousPageLink} {PageLinks} {NextPageLink} {LastPageLink}
{RowsPerPageDropdown}" >
<p:ajax event="rowEdit" listener="#
{AcctRefMBean.onRowEdit}" update=":dtableform:msgs" resetValues="true"/>
<p:ajax event="rowEditCancel" listener="#
{AcctRefMBean.onRowCancel}" update=":dtableform:msgs"/>
以下是我的javaBean:
//retrive the record/row of type
AcctRefTo on which edit even occurred
AcctRefTo to = (AcctRefTo)
event.getObject();
FacesContext facesContext = FacesContext.getCurrentInstance();
HttpSession session = (HttpSession)
facesContext.getExternalContext().getSession(false);
String userId = (String)
session.getAttribute(WebAppConstants.CURRENT_USER_ID);
if (userId == null) {
userId = WebAppConstants.DEFAULT_CURRENT_USER_ID;
}
to.setUpdatedByUserID(userId);
updateRecord(to);
FacesMessage msg = new FacesMessage("Reference Data Updated for Account#"
+ to.getAcctNbr());
FacesContext.getCurrentInstance
().addMessage("null", msg);
}
/**
* @param to
* updates the given to in DB accordingly
*/
public void updateRecord(AcctRefTo to) {
jetSessionFacadebean.updateAccntRef(to);
}
以下是我的updateQuery:
<key><value>updateAcctgRef</value></key>
<value>
update acct_ref set
cd_val=?,
dt_eff_end=?,
ind_bal=?,
ind_bal_acct_type=?,
ind_cum=?,
ind_net=?,
ind_net__bal_type=?,
ind__rcn=?,
ind_b=?,
nbr_gl_acct_yeb_offst=?,
nbr_gl_acct_net_unam_bal=?,
cd_fee_cat_type=?,
id_lst_updt=?,