HP Integrity NonStop H-Series User Manual
Page 447

com.hp.empinfo.domain.Employee employee = new com.hp.empinfo.domain.Employee();
// Set employee id
employee.setEmpid(getEmpid());
// Set employee Firstname
employee.setFirstname(getFirstname());
// Set employee Lastname
employee.setLastname(getLastname());
// Set employee age
employee.setAge(getAge());
// Set employee email
employee.setEmail(getEmail());
/** Inserting Employee Details* */
dao.insertDetail(employee.getEmpid(), employee.getFirstname(),
employee.getLastname(), employee.getAge(), employee
.getEmail());
status = "success";
resetInsert();
}
}
return status;
}
private boolean validateData() {
boolean status = true;
MessageFactory mf = new MessageFactory();
FacesContext ctx = FacesContext.getCurrentInstance();
// Checking Employee FirstName
if ((firstname.length()) < 2) {
ctx.addMessage("InsertForm:firstname", new FacesMessage(
FacesMessage.SEVERITY_ERROR, mf
.getMessage("errorFirstName"), null));
status = false;
}
// Checking Employee LastName
if ((lastname.length()) < 2) {
ctx.addMessage("InsertForm:lastname", new FacesMessage(
FacesMessage.SEVERITY_ERROR,
mf.getMessage("errorLastName"), null));
status = false;
}
// Checking Employee Age
if (age > 100) {
ctx.addMessage("InsertForm:age", new FacesMessage(
FacesMessage.SEVERITY_ERROR, mf.getMessage("errorAge"),
null));
status = false;
}
// Checking Email address
Pattern p = Pattern.compile(".+@.+\\.[a-z]+");
Matcher m = p.matcher(email);
boolean matchFound = m.matches();
if (!matchFound) {
ctx.addMessage("InsertForm:email", new FacesMessage(
FacesMessage.SEVERITY_ERROR, mf.getMessage("errorEmail"),
null));
status = false;
}
// End of checking Email address
return status;
}
public String update() throws Exception {
String s1 = null;
state1 = false;
state = false;
ntexist = false;
IEmployeeDao dao = (IEmployeeDao) ServiceFinder.findBean("empdao");
if (dao.checkEmp(getEmpid()) != null) {
Example of Integrating MyFaces into Spring
447