Package org.apache.beehive.samples.petstore.forms

Source Code of org.apache.beehive.samples.petstore.forms.AccountForm

/*
* Copyright 2004 The Apache Software Foundation.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
*     http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*
* $Header:$
*/
package org.apache.beehive.samples.petstore.forms;

import org.apache.struts.action.ActionErrors;
import org.apache.struts.action.ActionMapping;
import org.apache.beehive.samples.petstore.model.Account;
import org.apache.beehive.samples.petstore.model.Address;

import javax.servlet.http.HttpServletRequest;

public abstract class AccountForm
    extends AbstractPetstoreForm {

    private Account _account;

    public AccountForm() {
        super();
    }

    public AccountForm(Account account) {
        this();
        _account = account;
    }

    protected Account getAccount() {
        return _account;
    }

    public String getUserId() {
        return _account.getUserId();
    }

    public String getFirstName() {
        return _account.getFirstName();
    }

    public void setFirstName(String firstName) {
        _account.setFirstName(firstName);
    }

    public String getLastName() {
        return _account.getLastName();
    }

    public void setLastName(String lastName) {
        _account.setLastName(lastName);
    }

    public String getEmail() {
        return _account.getEmail();
    }

    public void setEmail(String email) {
        _account.setEmail(email);
    }

    public String getPhone() {
        return _account.getPhone();
    }

    public void setPhone(String value) {
        _account.setPhone(value);
    }

    public String getAddr1() {
        return _account.getAddress().getAddr1();
    }

    public void setAddr1(String value) {
        _account.getAddress().setAddr1(value);
    }

    public String getAddr2() {
        return _account.getAddress().getAddr2();
    }

    public void setAddr2(String value) {
        _account.getAddress().setAddr2(value);
    }

    public String getCity() {
        return _account.getAddress().getCity();
    }

    public void setCity(String value) {
        _account.getAddress().setCity(value);
    }

    public String getState() {
        return _account.getAddress().getState();
    }

    public void setState(String value) {
        _account.getAddress().setState(value);
    }

    public String getZip() {
        return _account.getAddress().getZip();
    }

    public void setZip(String value) {
        _account.getAddress().setZip(value);
    }

    public String getCountry() {
        return _account.getAddress().getCountry();
    }

    public void setCountry(String value) {
        _account.getAddress().setCountry(value);
    }

    public String getFavCategory() {
        return _account.getFavCategory();
    }

    public void setFavCategory(String value) {
        _account.setFavCategory(value);
    }

    public String getLangPref() {
        return _account.getLangPref();
    }

    public void setLangPref(String value) {
        _account.setLangPref(value);
    }

    public boolean isMyListOpt() {
        return _account.isMyListOpt();
    }

    public void setMyListOpt(boolean value) {
        _account.setMyListOpt(value);
    }

    public boolean isBannerOpt() {
        return _account.isBannerOpt();
    }

    public void setBannerOpt(boolean value) {
        _account.setBannerOpt(value);
    }

    public ActionErrors baseValidate(ActionErrors errors, ActionMapping mapping, HttpServletRequest request) {
        addErrorIfStringEmpty(errors, "firstName", "account.error.firstName.required", _account.getFirstName());
        addErrorIfStringEmpty(errors, "lastName", "account.error.lastName.required", _account.getLastName());
        addErrorIfStringEmpty(errors, "email", "account.error.email.required", _account.getEmail());
        addErrorIfStringEmpty(errors, "phone", "account.error.phone.required", _account.getPhone());

        Address address = _account.getAddress();
        addErrorIfStringEmpty(errors, "address1", "account.error.address1.required", address.getAddr1());
        addErrorIfStringEmpty(errors, "city", "account.error.city.required", address.getCity());
        addErrorIfStringEmpty(errors, "state", "account.error.state.required", address.getState());
        addErrorIfStringEmpty(errors, "zip", "account.error.zip.required", address.getZip());
        addErrorIfStringEmpty(errors, "country", "account.error.country.required", address.getCountry());

        return errors;
    }

    public static final Account getAccount(AccountForm form) {
        return form.getAccount();
    }
}
TOP

Related Classes of org.apache.beehive.samples.petstore.forms.AccountForm

TOP
Copyright © 2018 www.massapi.com. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.