FileDocCategorySizeDatePackage
SubscriptionForm.javaAPI DocExample8673Sun Mar 21 18:56:36 GMT 2004org.apache.struts.webapp.example

SubscriptionForm

public final class SubscriptionForm extends org.apache.struts.action.ActionForm
Form bean for the user profile page. This form has the following fields, with default values in square brackets:
  • action - The maintenance action we are performing (Create, Delete, or Edit).
  • host - The mail host for this subscription. [REQUIRED]
  • password - The password for this subscription. [REQUIRED]
  • type - The subscription type (imap,pop3) for this subscription. [REQUIRED]
  • username - The username of this subscription. [REQUIRED]
struts.form
name="subscriptionForm"
author
Craig R. McClanahan
version
$Revision: 1.4 $ $Date: 2003/01/11 03:08:23 $

Fields Summary
private String
action
The maintenance action we are performing (Create or Edit).
private boolean
autoConnect
Should we auto-connect at startup time?
private String
host
The host name.
private String
password
The password.
private String
type
The subscription type.
private String
username
The username.
Constructors Summary
Methods Summary
public java.lang.StringgetAction()
Return the maintenance action.



    // ----------------------------------------------------------- Properties


             
       

	return (this.action);

    
public booleangetAutoConnect()
Return the auto-connect flag.


        return (this.autoConnect);

    
public java.lang.StringgetHost()
Return the host name.


	return (this.host);

    
public java.lang.StringgetPassword()
Return the password.


	return (this.password);

    
public java.lang.StringgetType()
Return the subscription type.


	return (this.type);

    
public java.lang.StringgetUsername()
Return the username.


	return (this.username);

    
public voidreset(org.apache.struts.action.ActionMapping mapping, javax.servlet.http.HttpServletRequest request)
Reset all properties to their default values.

param
mapping The mapping used to select this instance
param
request The servlet request we are processing


        this.action = "Create";
        this.autoConnect = false;
        this.host = null;
        this.password = null;
        this.type = null;
        this.username = null;

    
public voidsetAction(java.lang.String action)
Set the maintenance action.

param
action The new maintenance action.


        this.action = action;

    
public voidsetAutoConnect(boolean autoConnect)
Set the auto-connect flag.

param
autoConnect The new auto-connect flag


        this.autoConnect = autoConnect;
    
public voidsetHost(java.lang.String host)
Set the host name.

param
host The host name


        this.host = host;

    
public voidsetPassword(java.lang.String password)
Set the password.

param
password The new password


        this.password = password;

    
public voidsetType(java.lang.String type)
Set the subscription type.

param
type The subscription type


        this.type = type;

    
public voidsetUsername(java.lang.String username)
Set the username.

param
username The new username


        this.username = username;

    
public org.apache.struts.action.ActionErrorsvalidate(org.apache.struts.action.ActionMapping mapping, javax.servlet.http.HttpServletRequest request)
Validate the properties that have been set from this HTTP request, and return an ActionErrors object that encapsulates any validation errors that have been found. If no errors are found, return null or an ActionErrors object with no recorded error messages.

param
mapping The mapping used to select this instance
param
request The servlet request we are processing


        ActionErrors errors = new ActionErrors();

	if ((host == null) || (host.length() < 1))
            errors.add("host",
                       new ActionError("error.host.required"));
	if ((username == null) || (username.length() < 1))
            errors.add("username",
                       new ActionError("error.username.required"));
	if ((password == null) || (password.length() < 1))
            errors.add("password",
                       new ActionError("error.password.required"));
	if ((type == null) || (type.length() < 1))
            errors.add("type",
                       new ActionError("error.type.required"));
	else if (!"imap".equals(type) && !"pop3".equals(type))
            errors.add("type",
                       new ActionError("error.type.invalid", type));

	return (errors);