01 package com.bea.medrec.beans;
02
03 import com.bea.medrec.value.Registration;
04 import javax.servlet.http.HttpServletRequest;
05 import org.apache.struts.action.ActionErrors;
06 import org.apache.struts.action.ActionMapping;
07 import org.apache.struts.validator.Resources;
08
09 /**
10 * <p>Form bean for the user registration pages.
11 * This form has the following fields,
12 * with default values in square brackets:
13 * <ul>
14 * <li><b>userbean</b> - Instance of UserBean
15 * <li><b>patientbean</b> - Instance of PatientBean
16 * </ul>
17 * </p>
18 *
19 * @author Copyright (c) 2006 by BEA Systems. All Rights Reserved.
20 */
21 public class RegistrationBean extends BaseBean {
22 private PatientBean patientBean = new PatientBean();
23 private UserBean userBean = new UserBean();
24
25 public RegistrationBean() {
26 }
27
28 public PatientBean getPatientBean() {
29 return this.patientBean;
30 }
31
32 public UserBean getUserBean() {
33 return this.userBean;
34 }
35
36 public void setPatientBean(PatientBean pPatientBean) {
37 this.patientBean = pPatientBean;
38 }
39
40 public void setUserBean(UserBean pUserBean) {
41 this.userBean = pUserBean;
42 }
43
44 /**
45 * <p>Validate registration.</p>
46 *
47 * @param mapping
48 * @param request
49 *
50 * @return ActionErrors
51 */
52 public ActionErrors validate(ActionMapping mapping,
53 HttpServletRequest request) {
54 ActionErrors errors = new ActionErrors();
55 // only validate if the user has clicked "Login"
56 String loginSubmit = Resources.getMessage(request, "button.Register");
57 if (loginSubmit.equals(request.getParameter("action"))) {
58 errors = super.validate(mapping, request);
59 }
60 return errors;
61 }
62
63 /**
64 * <p>Converts registration presentation bean
65 * to registration value object.</p>
66 *
67 * @return Registration
68 */
69 public Registration toRegistration()
70 {
71 return new Registration(getPatientBean().toPatient(),
72 getUserBean().toUser());
73 }
74 }
|