1 /**
2 * Copyright 2005-2006 the original author or authors.
3 *
4 * Licensed under the Gnu General Pubic License, Version 2.0 (the
5 * "License"); you may not use this file except in compliance with
6 * the License. You may obtain a copy of the License at
7 *
8 * http://www.opensource.org/licenses/gpl-license.php
9 *
10 * This program is distributed in the hope that it will be useful,
11 * but WITHOUT ANY WARRANTY; without even the implied warranty of
12 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
13 * See the Gnu General Public License for more details.
14 */
15 package org.figure8.join.control.form;
16
17 import org.figure8.join.control.JoinForm;
18 import org.figure8.join.control.action.LoginAction;
19
20 import org.apache.struts.action.ActionMapping;
21
22 import javax.servlet.http.HttpServletRequest;
23 /**
24 * Form object used for login into Join application.
25 * @author <a href="mailto:laurent.broudoux@free.fr">Laurent Broudoux</a>
26 * @version $Revision: 1.1 $
27 *
28 * @struts.form name="loginForm"
29 */
30 public class LoginForm extends JoinForm{
31
32
33
34 /** User login */
35 private String login;
36 /** User password */
37 private String password;
38 /** Redirection target URL */
39 private String targetUrl;
40
41
42
43
44 /** Creates a new instance of LoginForm. */
45 public LoginForm(){
46 }
47
48
49
50
51 /** @return Input login */
52 public String getLogin(){
53 return login;
54 }
55 /** @param login User login */
56 public void setLogin(String login){
57 this.login = login;
58 }
59 /** @return Input password */
60 public String getPassword(){
61 return password;
62 }
63 /** @param password User password */
64 public void setPassword(String password){
65 this.password = password;
66 }
67 /** @return Input target url */
68 public String getTargetUrl(){
69 return targetUrl;
70 }
71 /** @param targetUrl Redirection target url */
72 public void setTargetUrl(String targetUrl){
73 this.targetUrl = targetUrl;
74 }
75
76
77
78
79 /**
80 * Validation of the form attributes.
81 * @param operation String representing the operation to invoke on Action
82 * @param mapping Mapping between forwards name and path for this action
83 * @param request The servlet container request wrapper
84 */
85 public void doValidate(String operation, ActionMapping mapping, HttpServletRequest request){
86
87 if (LoginAction.ENTER_OP.equals(operation)){
88
89 if (login == null || login.length() == 0)
90 addActionError("errors.required", getGuiMessageResources().getMessage("label.user.login"));
91
92 if (password == null || password.length() == 0)
93 addActionError("errors.required", getGuiMessageResources().getMessage("label.user.password"));
94 }
95 }
96 }