我有一个有 3 个选项卡的 tabView,在每个选项卡中都有一个 panelGrid 和 dataTable,我想从 panelGrid 向 dataTable 添加一条记录,当我这样做时,我希望 tabView 移动到下一个选项卡,并且在第二个选项卡中相同,这很好,但我的问题是当我从 dataTable 中选择一条记录时,我想将 panelGrid 更改为选择的相同信息,然后移动到下一个选项卡并在那里编辑信息,它可以工作仅当我添加新记录时才可以,该选项卡转到下一个,但是当我返回并从 dataTable 中选择另一个数据时,它不会移动到下一个选项卡,我无法弄清楚我做错了什么。
这是我的标签代码:
<h:form id="frmExamBank" widgetVar="accordionPanelWidget">
<p:tabView widgetVar="tabWidget" id="tabsId"
activeIndex="#{mbCoursesExamBank.activeIndexTab}">
<p:tab title="Course Exam Bank" id="tab1">
<ui:include src="/pages/instructors/test.xhtml" />
</p:tab>
<p:tab title="Course Exam Questions" id="tab2" disabled="true">
<ui:include src="/pages/instructors/questions.xhtml" />
</p:tab>
<p:tab title="Course Exam Answers" id="tab3" disabled="true">
<ui:include src="/pages/instructors/answers.xhtml" />
</p:tab>
</p:tabView>
</h:form>
这是我的panelGrid:
<p:panelGrid columns="4" id="pnlCoursesExamBankData">
<f:facet name="header">
<div align="center">#{msg2.get('course_exam_bank')}</div>
</f:facet>
<p:outputLabel value="#{msg2.get('course')}" for="course" />
<p:selectOneMenu id="course" value="#{mbCoursesExamBank.entity.course}"
required="true" converter="omnifaces.SelectItemsIndexConverter"
label="#{msg2.get('course')}" filter="true" filterMatchMode="contains">
<f:selectItems value="#{mbCourses.all}" var="course"
itemLabel="#{course.fullName}" itemValue="#{course}" />
</p:selectOneMenu>
<p:outputLabel value="#{msg2.get('exam_category')}" for="examCategory" />
<p:selectOneMenu id="examCategory"
value="#{mbCoursesExamBank.entity.examCatogory}" required="true"
converter="omnifaces.SelectItemsIndexConverter"
label="#{msg2.get('exam_category')}">
<f:selectItem itemLabel="#{msg2.get('select_category')}"
itemValue="#{null}" noSelectionOption="true" />
<f:selectItems value="#{mbExamCategory.all}" var="category"
itemLabel="#{category.name}" itemValue="#{category}" />
</p:selectOneMenu>
<f:facet name="footer">
<div align="center">
<p:commandButton value="#{msg2.get('add')}"
action="#{mbCoursesExamBank.addCoursesExamBank()}"
update="@parent,@parent:tblCoursesExamBank,frmExamBank:tabsId"
process="@parent:pnlCoursesExamBankData" icon="btn-icon fa fa-plus" />
<p:commandButton value="#{msg2.get('save')}"
action="#{mbCoursesExamBank.update()}"
update="@parent,@parent:tblCoursesExamBank"
process="@parent:pnlCoursesExamBankData"
icon="btn-icon fa fa-floppy-o" />
<p:commandButton value="#{msg2.get('delete')}"
action="#{mbCoursesExamBank.delete()}"
update="@parent,@parent:tblCoursesExamBank"
process="@parent:pnlCoursesExamBankData"
icon="btn-icon fa fa-pencil" />
</div>
</f:facet>
</p:panelGrid>
这是我的数据表:
<p:dataTable paginatorPosition="bottom" id="tblCoursesExamBank"
value="#{mbCoursesExamBank.all}" var="bank" selectionMode="single"
selection="#{mbCoursesExamBank.entity}" rowKey="#{bank.id}"
rowIndexVar="rowIndex" paginator="true" rows="6">
<p:ajax event="rowSelect"
update="@parent:pnlCoursesExamBankData,frmExamBank,frmExamBank:tabsId"
process="@this" />
<p:column headerText="#" width="10%">
#{rowIndex+1}
</p:column>
<p:column headerText="#{msg2.get('course')}"
filterBy="#{bank.course.name}" sortBy="#{bank.course.name}"
filterMatchMode="contains">
#{bank.course.name}
</p:column>
<p:column headerText="#{msg2.get('exam_catogory')}"
filterBy="#{bank.examCatogory.name}"
sortBy="#{bank.examCatogory.name}" filterMatchMode="contains">
#{bank.examCatogory.name}
</p:column>
</p:dataTable>