1 7 package org.enhydra.pim.presentation.enhydrapim; 8 9 import org.enhydra.pim.business.PersonManagerI; 10 import org.enhydra.pim.business.api.OwnerI; 11 import org.enhydra.pim.business.api.PersonI; 12 import org.enhydra.pim.presentation.BasePO; 13 import org.enhydra.pim.spec.PersonManagerFactory; 14 import org.enhydra.xml.xmlc.XMLObject; 15 16 import com.lutris.appserver.server.httpPresentation.ClientPageRedirectException; 17 import com.lutris.appserver.server.httpPresentation.HttpPresentationException; 18 19 24 public class Add extends BasePO { 25 26 27 String ID_FIRSTNAME = "firstName"; 28 String ID_LASTNAME = "lastName"; 29 String ID_NICKNAME = "nickName"; 30 String ID_NOTE = "noteTextArea"; 31 32 33 34 35 40 public XMLObject handleDefault() throws HttpPresentationException { 41 return showPage(); 42 } 43 44 49 public XMLObject handleAddAddItem() throws HttpPresentationException { 50 51 String firstName = this.getComms().request.getParameter(ID_FIRSTNAME); 52 String lastName = this.getComms().request.getParameter(ID_LASTNAME); 53 String nickName = this.getComms().request.getParameter(ID_NICKNAME); 54 String note = this.getComms().request.getParameter(ID_NOTE); 55 56 if (nickName == null) nickName=""; 57 if (note == null) note=""; 58 59 if ((firstName== null || lastName== null) || 60 (firstName.length()==0 || firstName.length()==0 )){ 61 return showErrorPage("FirstName and LastName can not be empty"); 62 } 63 64 OwnerI user = null; PersonI person = null; 66 PersonManagerI pManager = null ; 67 try { 68 user = this.getSessionData().getUser(); 69 if (user!=null){ 70 pManager = PersonManagerFactory.getPersonManager(); 71 person = pManager.newPerson(user,firstName,lastName,nickName,note); 72 pManager.addPerson(person,user); 73 }else { 74 return showErrorPage("Invalid access"); 75 } 76 } catch (Exception e) { 77 return showErrorPage("Error during database writing"); 78 } 79 throw new ClientPageRedirectException(Common.REDIRECT_VIEW); 80 } 81 82 83 84 87 protected boolean loggedInUserRequired() { 88 return true; 90 } 91 92 98 public XMLObject showPage() throws HttpPresentationException { 99 AddHTML page = (AddHTML) myComms.xmlcFactory.create(AddHTML.class); 100 return page; 101 } 102 103 104 } 105 | Popular Tags |