Modifying the empinfo-servlet.xml file – HP Integrity NonStop J-Series User Manual

Page 121

Advertising
background image

String firstname = ((Employee) command).getFirstname();
String lastname = ((Employee) command).getLastname();
int age = ((Employee) command).getAge();
String email = ((Employee) command).getEmail();

String rord = ((Employee) command).getRord();

if (rord!=null && rord.equalsIgnoreCase("Retrieve")) {

Employee emp1 = empdao.getDetail(empid);

Map<String, String> model = new HashMap<String, String>();
model.put("empid", "" + emp1.getEmpid());
model.put("empfn", emp1.getFirstname());
model.put("empln", emp1.getLastname());
model.put("empage", "" + emp1.getAge());
model.put("empemail", emp1.getEmail());

return new ModelAndView("retrieveresult", "model", model);

}

if (rord!=null && rord.equalsIgnoreCase("Delete")) {

String str = empdao.deleteEmployee(empid);

Map<String, String> model = new HashMap<String, String>();
model.put("del", str);
return new ModelAndView("deleteresult", "model", model);

}

else {
empdao.insertDetail(empid, firstname, lastname, age, email);

Map<String, String> model = new HashMap<String, String>();
model
.put("add",
"Transaction Complete - One Employee Added to Employee Database");
return new ModelAndView("insertresult", "model", model);

}

}
}

Modifying the EmpInfo-servlet.xml File

Modify the EmpInfo-servlet.xml file in the EmpInfo/WebContent/WEB-INF directory to
map the command name and its corresponding command class for retrieveordelete.jsp.

After modification, the EmpInfo-servlet.xml file appears as:

<?xml version="1.0" encoding="UTF-8"?>
<beans xmlns="http://www.springframework.org/schema/beans"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xmlns:aop="http://www.springframework.org/schema/aop"
xmlns:p="http://www.springframework.org/schema/p"
xmlns:context="http://www.springframework.org/schema/context"
xmlns:jee="http://www.springframework.org/schema/jee"
xmlns:tx="http://www.springframework.org/schema/tx"
xsi:schemaLocation="
http://www.springframework.org/schema/beans
http://www.springframework.org/schema/beans/spring-beans-2.5.xsd
http://www.springframework.org/schema/context
http://www.springframework.org/schema/context/spring-context-2.5.xsd
http://www.springframework.org/schema/jee

Overview of EmpInfo

121

Advertising
This manual is related to the following products: