当我点击编辑列时,我正在使用celleditor,以获得更改反映我需要使用f5刷新页面。我想更改日期,所以我单击编辑按钮然后完成更改并按下保存,但更改仅在我刷新页面时反映。
<p:dataTable id="foodTableId" width="100%" cellspacing="1" cellpadding="0" border="0" var="v" value="#{dashboardBean.myFoodList}" paginator="true"
rows="#{msg['dashboard.product.mapping.datatable.rows']}" editable="true">
<p:ajax event="rowEdit" listener="#{dashboardBean.onEdit}" update=":dashboardForm:foodTableId"/>
<p:ajax event="rowEditCancel" listener="#{dashboardBean.onCancel}" />
<p:column style="width:100px;" sortBy="#{v.project}" headerText="Project Name">
<p:cellEditor>
<f:facet name="output">
<h:outputText value="#{v.project}" />
</f:facet>
<f:facet name="input">
<p:inputText style="width:305px;" value="#{v.project}"/>
</f:facet>
</p:cellEditor>
</p:column>
<p:column style="width:60px;" sortBy="#{v.action}" headerText="Action" id="actionId">
<p:cellEditor>
<f:facet name="output">
<h:outputText value="#{v.action}" />
</f:facet>
<f:facet name="input">
<h:selectOneMenu style="width:90px;" value="#{v.action}">
<f:selectItem itemLabel="Promo Start" itemValue="Promo Start" />
<f:selectItem itemLabel="Promo End" itemValue="Promo End" />
</h:selectOneMenu>
</f:facet>
</p:cellEditor>
</p:column>
<p:column style="width:120px;" sortBy="#{v.promoDate}" headerText="Action Date">
<p:cellEditor>
<f:facet name="output">
<h:outputText value="#{v.promoDateString}" />
</f:facet>
<f:facet name="input">
<p:calendar value="#{v.promoDate}" pattern="MMM dd, yyyy" />
</f:facet>
</p:cellEditor>
</p:column>
<p:column style="width:50px;" headerText="#{msg['product.label.edit']}" >
<p:rowEditor/>
</p:column>
bean
public String onEdit(RowEditEvent event) {
setEditMode(true);
foodPromoDTO = (FoodPromotionDTO) event.getObject();
Map<String, Object> sessMap = CommonUtil.getSessionMap();
SessionDTO sessionDTO = (SessionDTO) sessMap.get(WebConstants.SESSION_DTO);
String eid=sessionDTO.getUserDetailsDTO().getEid();
Integer roleCountryId=sessionDTO.getLoggedinUserRoleCountryId();
getDashboardService().addFoodPromotion(foodPromoDTO, eid, editMode, roleCountryId,sessionDTO.getLoggedinCountryCode());
return WebConstants.DASHBOARD;
}
答案 0 :(得分:1)
您必须为编辑完成后添加一个ajax事件,它将被保存。
<p:ajax event="cellEdit" listener="#{beanName.onCellEdit}" update="name of
your component" />
您可以在bean中包含此函数以执行操作。
public void onCellEdit(CellEditEvent event) {
Object oldValue = event.getOldValue();
Object newValue = event.getNewValue();
//Do oepration
}