Hi,
I have a bean that is taking to the page updateStudent.xhtml but is not populating the fields
The bewn is as below:
{code}
public String loadStudent(int id){
System.out.println("Printing something");
try{
Student theStudent = studentDbUtil.getStudent(id);
ExternalContext externalContext =
FacesContext.getCurrentInstance().getExternalContext();
Map<String, Object> requestMap = externalContext.getRequestMap();
requestMap.put("student", theStudent);
}
catch(Exception e){
e.printStackTrace();
}
return "updateStudent.xhtml";
}
public String updateStudent(Student student){
studentDbUtil.updateStudent(student);
System.out.println("test from update student controller");
return "newjsf?faces-redirect=true";
}
{code}
the page is:
{code}
<?xml version='1.0' encoding='UTF-8' ?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml"
xmlns:h="http://xmlns.jcp.org/jsf/html"
xmlns:p="http://primefaces.org/ui">
<h:head>
<title>Facelet Title</title>
</h:head>
<h:body>
<h:form id="form">
<p:panelGrid columns="2">
<p:panelGrid columns="2">
<h:outputText value="First Name"/>
<h:inputText value="#{student.firstName}"/>
<h:outputText value="Last Name"/>
<h:inputText value="#{student.lastName}"/>
<h:inputHidden value="#{student.id}"/>
</p:panelGrid>
<h:commandButton value="Save" action = "#{studentController.updateStudent(student)}" />
</p:panelGrid>
</h:form>
</h:body>
</html>
{code}