KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > com > sslexplorer > webforwards > webforwardwizard > forms > WebForwardTypeSelectionForm


1 /*
2  * SSL-Explorer
3  *
4  * Copyright (C) 2003-2006 3SP LTD. All Rights Reserved
5  *
6  * This program is free software; you can redistribute it and/or
7  * modify it under the terms of the GNU General Public License
8  * as published by the Free Software Foundation; either version 2 of
9  * the License, or (at your option) any later version.
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. See the
13  * GNU General Public License for more details.
14  *
15  * You should have received a copy of the GNU General Public
16  * License along with this program; if not, write to the Free Software
17  * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
18  */

19             
20 package com.sslexplorer.webforwards.webforwardwizard.forms;
21
22 import javax.servlet.http.HttpServletRequest JavaDoc;
23
24 import org.apache.struts.Globals;
25 import org.apache.struts.action.ActionErrors;
26 import org.apache.struts.action.ActionMapping;
27 import org.apache.struts.action.ActionMessage;
28
29 import com.sslexplorer.webforwards.WebForward;
30 import com.sslexplorer.wizard.AbstractWizardSequence;
31 import com.sslexplorer.wizard.forms.DefaultWizardForm;
32
33 /**
34  */

35 public class WebForwardTypeSelectionForm extends DefaultWizardForm {
36     private static final int NO_TYPE_SELECTED = -1;
37     public static final String JavaDoc ATTR_TYPE = "type";
38     private int type = WebForward.TYPE_TUNNELED_SITE;
39
40     /**
41      * Construtor
42      */

43     public WebForwardTypeSelectionForm() {
44         super(true, false, "/WEB-INF/jsp/content/webforward/webforwardwizard/webForwardTypeSelection.jspf", "", false, false,
45                         "webForwardTypeSelection", "webForwards", "webForwardWizard.webForwardTypeSelection", 1);
46     }
47         
48     /* (non-Javadoc)
49      * @see com.sslexplorer.wizard.forms.AbstractWizardForm#apply(com.sslexplorer.wizard.AbstractWizardSequence)
50      */

51     public void apply(AbstractWizardSequence sequence) throws Exception JavaDoc {
52         super.apply(sequence);
53         sequence.putAttribute(ATTR_TYPE, new Integer JavaDoc(type));
54     }
55
56     /**
57      * @return int
58      */

59     public int getType() {
60         return type;
61     }
62
63     /**
64      * @param type
65      */

66     public void setType(int type) {
67         this.type = type;
68     }
69
70     @Override JavaDoc
71     public ActionErrors validate(ActionMapping mapping, HttpServletRequest JavaDoc request) {
72         if(isCommiting() && type == NO_TYPE_SELECTED) {
73             ActionErrors errors = new ActionErrors();
74             errors.add(Globals.ERROR_KEY, new ActionMessage("webForwardWizard.webForwardTypeSelection.error.noSelection"));
75             return errors;
76         }
77         return null;
78     }
79 }
Popular Tags