美好的一天
是否有可能(我似乎无法点击'勾选'接受行编辑)以使用Primefaces数据表来显示不可更新的Postgres视图的结果,但是在onRowEdit事件中有自定义代码,它会将更改正确地保存到数据库吗?
或者必须将Primefaces / JSF数据表链接到可更新的实体映射,以便将其用于更新'并显示信息?
我在.xhtml文件中有这个:
<p:dataTable id="conf_data_table" var="confRoomBookingDisplay" style="width: auto" rowIndexVar="rowid" editingRow="true"
value="#{conferenceRoomBookingView.conferenceRoomBookingList}" editable="true"
editMode="row" widgetVar="cellBookings">
<f:facet name="header">
Venue Booking
</f:facet>
<p:ajax event="rowEdit" listener="#{conferenceRoomBookingView.onRowEdit}"
update=":create_new_booking:growl"/>
<p:ajax event="rowEditCancel" listener="#{conferenceRoomBookingView.onRowCancel}"
update=":create_new_booking:growl"/>
<p:column headerText="Booking Ref" style="width: 10%; text-align: center">
<p:outputLabel value="#{ConferenceRoomBooking.conferenceRoomBookingAid}"
style="text-align: center"/>
</p:column>
<p:column headerText="Time Slot" style="width: 10%; text-align: center">
<p:outputLabel value="#{ConferenceRoomBooking.timeSlot}" style="text-align: center"/>
</p:column>
<p:column headerText="Booked For" style="width: 15%; alignment: center">
<p:outputLabel value="#{ConferenceRoomBooking.empShortNameSurname}"
style="text-align: left"/>
</p:column>
<p:column headerText="Booking Comment" style="width: 60%; alignment: center">
<p:cellEditor>
<f:facet name="output">
<h:outputText value="#{ConferenceRoomBooking.conferenceRoomBookingComment}"/>
</f:facet>
<f:facet name="input">
<p:inputText value="#{ConferenceRoomBooking.conferenceRoomBookingComment}"
style="width:98%"/>
</f:facet>
</p:cellEditor>
</p:column>
<p:column style="width: 5%">
<p:rowEditor />
</p:column>
</p:dataTable>
然后在我的@RequestScoped(javax.enterprise.context.RequestScoped)@Named支持bean(我也尝试使用@ViewScoped - org.omnifaces.cdi注释)。
事件代码如下所示:
public void onRowEdit(RowEditEvent event) {
conferenceRoomBookingAid = (((ConferenceRoomBookingEntity) event.getObject()).getConferenceRoomBookingAid());
String msgEdit = Long.toString(conferenceRoomBookingAid);
FacesMessage msg = new FacesMessage("Booking Edited for Reference ID:", msgEdit);
FacesContext.getCurrentInstance().addMessage(null, msg);
confRoomService.persistComment(How do I get my updated value from the event???);
}
public void onRowCancel(RowEditEvent event) {
conferenceRoomBookingAid = (((ConferenceRoomBookingEntity) event.getObject()).getConferenceRoomBookingAid());
String msgEdit = Long.toString(conferenceRoomBookingAid);
FacesMessage msg = new FacesMessage("Booking Cancelled for Reference ID: ", msgEdit);
FacesContext.getCurrentInstance().addMessage(null, msg);
}
目前正在评论confRoomService.persistComment(How do I get my updated value from the event???);
代码,让我找到一个正确呈现的表格,我可以在其中编辑该行。但问题是我无法点击“接受”。 /&#39;是&#39;用鼠标勾选,然后按Enter键再次清除单元格。
我使用不可更新视图的原因是当前数据库结构使用外键将数据链接到人,并且使用基本实体将显示外键id而不是其值。
答案 0 :(得分:0)
在很多不同版本的实体和数据库视图之后,我得出的结论是要使用JSF / Primefaces数据表组件:
如果在上面证明是错误的话,我会欣喜若狂,但是现在基于数据库视图使用数据表作为不可变的时候已经和平了。