Guest User

Untitled

a guest
Mar 14th, 2018
99
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.53 KB | None | 0 0
  1. package com.forms;
  2.  
  3. import javax.servlet.http.HttpServletRequest;
  4. import org.apache.struts.action.ActionError;
  5. import org.apache.struts.action.ActionErrors;
  6. import org.apache.struts.action.ActionForm;
  7. import org.apache.struts.action.ActionMapping;
  8.  
  9. /**
  10. *
  11. * @version Version 1.0 2009
  12. * @author Emmanuel S. Garcia
  13. */
  14. public class LoginForm extends ActionForm
  15. {
  16. private String userName;
  17. private String password;
  18.  
  19. /**
  20. * Resets data fields to initial values on login.jsp
  21. * @param mapping
  22. * @param request
  23. */
  24. public void reset(ActionMapping mapping, HttpServletRequest request)
  25. {
  26. password = null;
  27. userName = null;
  28. }
  29.  
  30. /**
  31. * Performs validation of data on login.jsp
  32. * @param mapping
  33. * @param request
  34. * @return ActionErrors
  35. */
  36. public ActionErrors validate(ActionMapping mapping, HttpServletRequest request)
  37. {
  38. System.out.println("###LoginForm...");
  39.  
  40. ActionErrors errors = new ActionErrors();
  41.  
  42. if((userName == null) || (userName.length() < 1))
  43. errors.add("userName", new ActionError("error.username.required"));
  44. if((password == null) || (password.length() < 1))
  45. errors.add("password", new ActionError("error.password.required"));
  46.  
  47. return errors;
  48.  
  49. }
  50.  
  51. /**
  52. * @return password
  53. */
  54. public String getPassword() {
  55. return password;
  56. }
  57.  
  58. /**
  59. * @return userName
  60. */
  61. public String getUserName() {
  62. return userName;
  63. }
  64.  
  65. /**
  66. * @param string
  67. */
  68. public void setPassword(String string) {
  69. password = string;
  70. }
  71.  
  72. /**
  73. * @param string
  74. */
  75. public void setUserName(String string) {
  76. userName = string;
  77. }
  78.  
  79. }
Add Comment
Please, Sign In to add comment