我正在尝试使用建立时间表<p:datatable>
。目前,我正在<f:setPropertyActionListener>
尝试使用并尝试利用数据表中的rowIndexVar
,如您在本周二的以下代码中所见。不幸的是它没有用。问题在于基础模型包含5个列表(每个工作日1个),所以我要在每列上处理不同的列表。
我不知道我是否真的错了。但是到目前为止,还好,现在我只遇到问题,我想从单击的相应单元格中提取数据。到目前为止,这是我的表:
<p:dataTable id="schedule" var="rows" value="#{scheduleBean.emptyRowDefault}"
editMode="cell"
rowIndexVar="index"
widgetVar="cellCars" >
<f:facet name="header">
#{msg['schedule']}
</f:facet>
<p:column headerText="#{msg['hour']}">
<h:outputText value="#{index+1}" />
</p:column>
<p:column headerText="#{msg['time']}">
<h:outputText value="#{scheduleBean.schedule.times[index]}" />
</p:column>
<p:column headerText="#{msg['monday']}">
<p:commandLink value="#{scheduleBean.schedule.monday[index].name}" onclick="PF('subjectDialog').show();" />
</p:column>
<p:column headerText="#{msg['tuesday']}">
<p:commandLink update=":form:eventDetails" onclick="PF('subjectDialog').show();" >
<f:setPropertyActionListener value="#{scheduleBean.schedule.tuesday.get(index)}" target="#{scheduleBean.subject}" />
<h:outputText value="#{scheduleBean.schedule.tuesday[index].name}" />
</p:commandLink>
</p:column>
<p:column headerText="#{msg['wednesday']}" >
<p:commandLink value="#{scheduleBean.schedule.wednesday[index].name}" onclick="PF('subjectDialog').show();" />
</p:column>
<p:column headerText="#{msg['thursday']}">
<p:commandLink value="#{scheduleBean.schedule.thursday[index].name}" onclick="PF('subjectDialog').show();" />
</p:column>
<p:column headerText="#{msg['friday']}">
<p:commandLink value="#{scheduleBean.schedule.friday[index].name}" onclick="PF('subjectDialog').show();" />
</p:column>
</p:dataTable>
这个对话框:
<p:dialog widgetVar="subjectDialog" header="Neues Fach anlegen" showEffect="clip" hideEffect="clip" resizable="false">
<h:panelGrid id="eventDetails" columns="2">
<p:outputLabel for="name" value="#{msg['subject']}" />
<p:inputText id="name" value="#{scheduleBean.subject.name}" required="true" />
<p:outputLabel for="hour" value="#{msg['hour']}" />
<h:selectOneMenu id="hour" value="#{scheduleBean.subject.hourTime}" style="width:100%">
<f:selectItems value="#{scheduleBean.schedule.hours}" var="day" itemLabel="#{hour}" itemValue="#{hour}" />
</h:selectOneMenu>
<p:outputLabel for="weekday" value="#{msg['weekday']}" />
<h:selectOneMenu id="weekday" value="#{scheduleBean.subject.weekday}" style="width:100%">
<f:selectItems value="#{scheduleBean.schedule.weekdays}" var="day" itemLabel="#{day}" itemValue="#{day}" />
</h:selectOneMenu>
<p:outputLabel for="teacher" value="#{msg['teacher']}" />
<p:inputText id="teacher" value="#{scheduleBean.subject.teacher}" required="true" />
<p:outputLabel for="room" value="#{msg['room']}" />
<p:inputText id="room" value="#{scheduleBean.subject.room}" required="true" />
</h:panelGrid>
<h:panelGroup style="text-align: center; width: 340px; float: left">
<p:commandButton id="addButton" styleClass="button button2" value="#{msg['save']}" action="#{scheduleBean.save}" update="schedule :form:eventDetails" oncomplete="PF('subjectDialog').hide();" />
<p:commandButton id="delete" styleClass="button button2" value="#{msg['delete']}" action="#{scheduleBean.remove(scheduleBean.subject)}" update="schedule msgs" oncomplete="PF('subjectDialog').hide();" />
<p:commandButton id="cancel" styleClass="button button2" value="#{msg['cancel']}" immediate="true" oncomplete="PF('subjectDialog').hide();" />
</h:panelGroup>
</p:dialog>
不确定为什么不为该星期二的行调用您的managedBeans属性,而是关于对话框的刷新,将对话框放置在主窗体之外并inner
在对话框本身内添加窗体的一种常见做法是:
<p:dialog widgetVar="subjectDialog" header="Neues Fach anlegen" showEffect="clip" hideEffect="clip" resizable="false">
<h:form id="dialogForm">
...
</h:form>
</p:dialog>
然后,您只需在数据表中执行操作即可update=":dialogForm"
。
这样做的原因是浏览器可能会将p:dialog的内容重定位到DOM树的其他元素(通常在任何form元素的末尾)。这将导致您所有的按钮和表单元素停止工作。
本文收集自互联网,转载请注明来源。
如有侵权,请联系 [email protected] 删除。
我来说两句