假设顶部有一个班级学生。我的问题是,当我在调试中运行代码并在方法中放置了一些 breackpoint 时onRowSelect
但是当我选择该行时,代码不会转到断点,它向我显示对话框但显示值。
search.xhtml:
<h:form id="form">
<p:dataTable id="resultStudent" var="student" lazy="true" value="#{studentBean.listStudents}" selectionMode="single" selection="#{studentBean.selectedStudent}" rows="10"
paginator="true"
paginatorTemplate="{CurrentPageReport} {FirstPageLink} {PreviousPageLink} {PageLinks} {NextPageLink} {LastPageLink} {RowsPerPageDropdown}"
rowsPerPageTemplate="2,5,10,15" rowKey="#{student.idStudent}">
<!-- This is the problem -->
<p:ajax event="rowSelect" listener="#{studentBean.onRowSelect}" update=":form:StrudentDetail" oncomplete="PF('studentDialog').show()" process="resultStudent"/>
....
</p:dataTable>
<!-- The dialog is -->
<p:dialog header="Detaails Student" widgetVar="studentDialog" modal="true" showEffect="fade" hideEffect="fade" resizable="false">
<p:outputPanel id="StudentDetail" style="text-align:center;">
<p:panelGrid columns="2" rendered="#{not empty studentBean.selectedStudent}" columnClasses="label,value">
<f:facet name="header">
<!-- <p:graphicImage name="demo/images/car/#{dtLazyView.selectedCar.brand}-big.gif"/>-->
</f:facet>
班级 学生豆 是:
@ManagedBean(name = "studentBean")
@ViewScoped
public class StudentBean {
... AAL method get and set
private Student selectedStudent;
@PostConstruct
public void init() {...
}
public void onRowSelect(SelectEvent event) {
//THis I put the debug and the code doesn't seem execute here
int id=(Student)event.getObject()).getIdStudent());
FacesMessage msg = new FacesMessage("Student Selected");
FacesContext.getCurrentInstance().addMessage(null, msg);
}
有人可以帮助我吗?
您的代码中有一个拼写错误,很可能导致对话框无法使用后备 Bean 中的新值进行更新。
p:ajax
rowSelect 事件具有定义的属性update=":form:StrudentDetail"
。但是,您真正想要更新的是 :form:StudentDetail
.
您没有指定正在运行的 JSF 或 EE 版本。值得一提的是,自 JSF 2.3 以来,@ManagedBean
已被弃用。因此,如果这是一个新应用程序,则应迁移到 @Named
和 CDI。