FileDocCategorySizeDatePackage
AccountActionForm.javaAPI DocExample4364Thu Dec 04 08:19:26 GMT 2003org.springframework.samples.jpetstore.web.struts

AccountActionForm

public class AccountActionForm extends BaseActionForm

Fields Summary
public static final String
VALIDATE_EDIT_ACCOUNT
public static final String
VALIDATE_NEW_ACCOUNT
private static final ArrayList
LANGUAGE_LIST
private String
username
private String
password
private String
repeatedPassword
private List
languages
private List
categories
private String
validate
private String
forwardAction
private org.springframework.samples.jpetstore.domain.Account
account
private org.springframework.util.PagedListHolder
myList
Constructors Summary
public AccountActionForm()


  /* Static Initializer */

   
    LANGUAGE_LIST.add("english");
    LANGUAGE_LIST.add("japanese");
  
    languages = LANGUAGE_LIST;
  
Methods Summary
public voiddoValidate(org.apache.struts.action.ActionMapping mapping, javax.servlet.http.HttpServletRequest request, java.util.List errors)

    if (validate != null) {
      if (VALIDATE_EDIT_ACCOUNT.equals(validate) || VALIDATE_NEW_ACCOUNT.equals(validate)) {
        if (VALIDATE_NEW_ACCOUNT.equals(validate)) {
          account.setStatus("OK");
          addErrorIfStringEmpty(errors, "User ID is required.", account.getUsername());
          if (account.getPassword() == null || account.getPassword().length() < 1 || !account.getPassword().equals(repeatedPassword)) {
            errors.add("Passwords did not match or were not provided.  Matching passwords are required.");
          }
        }
        if (account.getPassword() != null && account.getPassword().length() > 0) {
          if (!account.getPassword().equals(repeatedPassword)) {
            errors.add("Passwords did not match.");
          }
        }
        addErrorIfStringEmpty(errors, "First name is required.", this.account.getFirstName());
        addErrorIfStringEmpty(errors, "Last name is required.", this.account.getLastName());
        addErrorIfStringEmpty(errors, "Email address is required.", this.account.getEmail());
        addErrorIfStringEmpty(errors, "Phone number is required.", this.account.getPhone());
        addErrorIfStringEmpty(errors, "Address (1) is required.", this.account.getAddress1());
        addErrorIfStringEmpty(errors, "City is required.", this.account.getCity());
        addErrorIfStringEmpty(errors, "State is required.", this.account.getState());
        addErrorIfStringEmpty(errors, "ZIP is required.", this.account.getZip());
        addErrorIfStringEmpty(errors, "Country is required.", this.account.getCountry());
      }
    }

  
public org.springframework.samples.jpetstore.domain.AccountgetAccount()

 return account; 
public java.util.ListgetCategories()

 return categories; 
public java.lang.StringgetForwardAction()

 return forwardAction; 
public java.util.ListgetLanguages()

 return languages; 
public org.springframework.util.PagedListHoldergetMyList()

 return myList; 
public java.lang.StringgetPassword()

 return password; 
public java.lang.StringgetRepeatedPassword()

 return repeatedPassword; 
public java.lang.StringgetUsername()

 return username; 
public java.lang.StringgetValidate()

 return validate; 
public voidreset(org.apache.struts.action.ActionMapping mapping, javax.servlet.http.HttpServletRequest request)

    super.reset(mapping, request);
    setUsername(null);
    setPassword(null);
    setRepeatedPassword(null);
  
public voidsetAccount(org.springframework.samples.jpetstore.domain.Account account)

 this.account = account; 
public voidsetCategories(java.util.List categories)

 this.categories = categories; 
public voidsetForwardAction(java.lang.String forwardAction)

 this.forwardAction = forwardAction; 
public voidsetLanguages(java.util.List languages)

 this.languages = languages; 
public voidsetMyList(org.springframework.util.PagedListHolder myList)

 this.myList = myList; 
public voidsetPassword(java.lang.String password)

 this.password = password; 
public voidsetRepeatedPassword(java.lang.String repeatedPassword)

 this.repeatedPassword = repeatedPassword; 
public voidsetUsername(java.lang.String username)

 this.username = username; 
public voidsetValidate(java.lang.String validate)

 this.validate = validate;