2
votes

This project is made with Primefaces 3.5, JSF 2.0, Oracle database.

The view:

<h:form id="schedule" class="schedule">

// more JSF and forms and dialogs

<p:dialog widgetVar="patientDialog" dynamic="true" header="Find Patient" showEffect="clip" hideEffect="explode" modal="true" >
            <h:form id="frmPatient">
                <h:panelGrid id="findPatient" columns="1">
                    <h:panelGrid id="findPatientParameters" columns="2">
                        <h:outputLabel value="Firstname: " /> 
                        <p:inputText id="name" label="name" size="15" value="#{waitinglistBean.name}" />
                        <h:outputLabel value="Patient Code: " /> 
                        <p:inputText id="pcode" label="pcode" size="15" value="#{waitinglistBean.pcode}" />
                        <br />
                        <p:commandButton value="Search" process="name" actionListener="#{waitinglistBean.patients}" update="patients"/>
                    </h:panelGrid>
                    <h:panelGrid id="findPatientDetails" columns="1">
                        <p:dataTable id="patients" var="patient" resizableColumns="true" scrollable="true" scrollWidth="1250" 
                                     scrollHeight="150" value="#{waitinglistBean.patients}" 
                                     rowKey="#{patient.PCode}" selection="#{waitinglistBean.selectedPatient}" 
                                     selectionMode="single" >
                            <f:facet name="header">  
                                Click "Select" button after selecting a row to select patient.
                            </f:facet>  
                            <p:column width="150" headerText="Code">  
                                #{patient.PCode}  
                            </p:column>  
                            <p:column width="150" headerText="Family Name">  
                                #{patient.PLname}  
                            </p:column>  
                            <p:column width="150" headerText="First Name">  
                                #{patient.PFname}  
                            </p:column> 
                            <p:column headerText="Sex" >  
                                #{patient.PSex}  
                            </p:column>  
                            <p:column headerText="Birthdate">  
                                #{patient.PBorn}  
                            </p:column> 
                            <p:column headerText="Street">  
                                #{patient.PStreet}  
                            </p:column>
                            <f:facet name="footer">  
                                <p:commandButton id="viewButton" value="Select" icon="ui-icon-search"  
                                        oncomplete="patientDialog.hide()" 
                                        update=":frmDialogs:frmWaiting:tabView:patientDetails" 
                                        process="patients"/>  
                            </f:facet>
                        </p:dataTable>
                    </h:panelGrid>
                </h:panelGrid>
            </h:form>
        </p:dialog>
    <p:dialog widgetVar="patientDialog" dynamic="true" header="Find Patient" showEffect="clip" hideEffect="explode" modal="true" >
            <h:form id="frmPatient">
                <h:panelGrid id="findPatient" columns="1">
                    <h:panelGrid id="findPatientParameters" columns="2">
                        <h:outputLabel value="Firstname: " /> 
                        <p:inputText id="name" label="name" size="15" value="#{waitinglistBean.name}" />
                        <h:outputLabel value="Patient Code: " /> 
                        <p:inputText id="pcode" label="pcode" size="15" value="#{waitinglistBean.pcode}" />
                        <br />
                        <p:commandButton value="Search" process="name" actionListener="#{waitinglistBean.patients}" update="patients"/>
                    </h:panelGrid>
                    <h:panelGrid id="findPatientDetails" columns="1">
                        <p:dataTable id="patients" var="patient" resizableColumns="true" scrollable="true" scrollWidth="1250" 
                                     scrollHeight="150" value="#{waitinglistBean.patients}" 
                                     rowKey="#{patient.PCode}" selection="#{waitinglistBean.selectedPatient}" 
                                     selectionMode="single" >
                            <f:facet name="header">  
                                Click "Select" button after selecting a row to select patient.
                            </f:facet>  
                            <p:column width="150" headerText="Code">  
                                #{patient.PCode}  
                            </p:column>  
                            <p:column width="150" headerText="Family Name">  
                                #{patient.PLname}  
                            </p:column>  
                            <p:column width="150" headerText="First Name">  
                                #{patient.PFname}  
                            </p:column> 
                            <p:column headerText="Sex" >  
                                #{patient.PSex}  
                            </p:column>  
                            <p:column headerText="Birthdate">  
                                #{patient.PBorn}  
                            </p:column> 
                            <p:column headerText="Street">  
                                #{patient.PStreet}  
                            </p:column>
                            <f:facet name="footer">  
                                <p:commandButton id="viewButton" value="Select" icon="ui-icon-search"  
                                        oncomplete="patientDialog.hide()" 
                                        update=":frmDialogs:frmWaiting:tabView:patientDetails" 
                                        process="patients"/>  
                            </f:facet>
                        </p:dataTable>
                    </h:panelGrid>
                </h:panelGrid>
            </h:form>
        </p:dialog>
    // more JSF and dialogshizzle
 </h:form>

The backing bean:

@ManagedBean(name="waitinglistBean")
@ViewScoped
public class WaitinglistBean implements Serializable
{
private Patients patient;
private OrWaitinglist orWaitinglist;
private List<Patients> patients = new ArrayList<Patients>();
private String name;
private Integer pcode;

public WaitinglistBean() {

}

public void setSelectedPatient(Patients patient) {
    this.patient = patient;
}
public Patients getSelectedPatient() {
    return patient;
}
public OrWaitinglist getOrWaitinglist() {
    return orWaitinglist;
}
public void setOrWaitinglist(OrWaitinglist orWaitinglist) {
    this.orWaitinglist = orWaitinglist;
}
public String getName() {
    return name;
}
public void setName(String name) {
    this.name = name;
}
public Integer getPcode() {
    return pcode;
}
public void setPcode(Integer pcode) {
    this.pcode = pcode;
}

public List<Patients> getPatients() {
    PatientsDao patientsDao = new PatientsDaoImpl();
    patients = patientsDao.getSearchPatient(name, pcode);
    System.out.println(name + " " + pcode);
    return patients;
}

public void createOrWaitinglist()
{
    orWaitinglist.setPatients(patient);
}

So first a user enter a string: "Firstname" and an Integer: "Patient Code". When he hits the "Search" button it fires the actionListener="#{patientBean.patients} inside that commandbutton. The method needs 2 parameter, name and pcode which have their own setters/getters.

When I look in console it shows me the printout of these 2 parameters, and they are twice "null", so that means the parameters from the JSF pages were not passed to the backing bean, although the value of the inputText has been set to the backingbean set method: value="#{patientBean.name}"

My question now is why do I get these null-values. I've read several posts which use these setters, but still I get null-values.

after edit i still have the same problem;

1
Just add id of both p:inputText into process attribute of your search buttonJitesh
i've added process="name" to my commandbutton but still "null"JeroenVP
Is the JSF code, wrapped inside the html:form, <h:form>?Himanshu Bhardwaj
yes the dialog is wrapped in <h:form id="schedule" class="schedule">JeroenVP
Is it true that it is not allowed to nest "forms" like I did <h:form> <p:dialog> <h:form> //shizzle <h:form> <p:/dialog> </h:form>JeroenVP

1 Answers

2
votes

for send value of input component in h:panelgrid to the backingbean use somthing like this:

<p:commandButton value="Search" process="@(frmPatient:findPatientParameters :input)" 
           actionListener="#{patientBean.patients}" update="patients"/>