0

Suppose top have one class Student. My problem is that when I run the code in debug and I put some breackpoints in my method onRowSelect but when I select the row, the code doesn't go to breakpoints and it show me the dialog but whitout value.

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>

The class StudentBean is:

@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);
        }

Anyone can help me?

Postilla
  • 161
  • 1
  • 1
  • 8
  • 1
    Hard to guess what the issues is without [mcve]. Please also read [commandButton/commandLink/ajax action/listener method not invoked or input value not set/updated](https://stackoverflow.com/questions/2118656/commandbutton-commandlink-ajax-action-listener-method-not-invoked-or-input-value) – Selaron Jul 12 '19 at 09:12

1 Answers1

0

You have a typo in your code that most likely is causing the dialog not to update with fresh values from the backing bean.

The p:ajax rowSelect event has the attribute update=":form:StrudentDetail" defined. However, what you really want to update is :form:StudentDetail.

You did not specify which version of JSF or EE you are running. It's worth mentioning that @ManagedBean is deprecated since JSF 2.3. So if this is a new application, you should migrate to @Named and CDI.

Adam Waldenberg
  • 2,271
  • 9
  • 26
  • This would normally call the method just not update anything. And if you run in development mode it would even throw an error – Kukeltje Jul 14 '19 at 12:46
  • You can enable development mode by setting `javax.faces.PROJECT_STAGE` in your `web.xml`. This should allow you to catch typos like these (and other errors) a lot faster. – Adam Waldenberg Jul 14 '19 at 14:48