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

OrderActionForm

public class OrderActionForm extends BaseActionForm

Fields Summary
private static final List
CARD_TYPE_LIST
private org.springframework.samples.jpetstore.domain.Order
order
private boolean
shippingAddressRequired
private boolean
confirmed
private List
cardTypeList
Constructors Summary
public OrderActionForm()


  /* Static Initializer */

   
    CARD_TYPE_LIST.add("Visa");
    CARD_TYPE_LIST.add("MasterCard");
    CARD_TYPE_LIST.add("American Express");
  
    this.order = new Order();
    this.shippingAddressRequired = false;
    this.cardTypeList = CARD_TYPE_LIST;
    this.confirmed = false;
  
Methods Summary
public voiddoValidate(org.apache.struts.action.ActionMapping mapping, javax.servlet.http.HttpServletRequest request, java.util.List errors)


    if (!this.isShippingAddressRequired()) {
      addErrorIfStringEmpty(errors, "FAKE (!) credit card number required.", order.getCreditCard());
      addErrorIfStringEmpty(errors, "Expiry date is required.", order.getExpiryDate());
      addErrorIfStringEmpty(errors, "Card type is required.", order.getCardType());

      addErrorIfStringEmpty(errors, "Shipping Info: first name is required.", order.getShipToFirstName());
      addErrorIfStringEmpty(errors, "Shipping Info: last name is required.", order.getShipToLastName());
      addErrorIfStringEmpty(errors, "Shipping Info: address is required.", order.getShipAddress1());
      addErrorIfStringEmpty(errors, "Shipping Info: city is required.", order.getShipCity());
      addErrorIfStringEmpty(errors, "Shipping Info: state is required.", order.getShipState());
      addErrorIfStringEmpty(errors, "Shipping Info: zip/postal code is required.", order.getShipZip());
      addErrorIfStringEmpty(errors, "Shipping Info: country is required.", order.getShipCountry());

      addErrorIfStringEmpty(errors, "Billing Info: first name is required.", order.getBillToFirstName());
      addErrorIfStringEmpty(errors, "Billing Info: last name is required.", order.getBillToLastName());
      addErrorIfStringEmpty(errors, "Billing Info: address is required.", order.getBillAddress1());
      addErrorIfStringEmpty(errors, "Billing Info: city is required.", order.getBillCity());
      addErrorIfStringEmpty(errors, "Billing Info: state is required.", order.getBillState());
      addErrorIfStringEmpty(errors, "Billing Info: zip/postal code is required.", order.getBillZip());
      addErrorIfStringEmpty(errors, "Billing Info: country is required.", order.getBillCountry());
    }

    if (errors.size() > 0) {
      order.setBillAddress1(order.getShipAddress1());
      order.setBillAddress2(order.getShipAddress2());
      order.setBillToFirstName(order.getShipToFirstName());
      order.setBillToLastName(order.getShipToLastName());
      order.setBillCity(order.getShipCity());
      order.setBillCountry(order.getShipCountry());
      order.setBillState(order.getShipState());
      order.setBillZip(order.getShipZip());
    }

  
public java.util.ListgetCreditCardTypes()

 return cardTypeList; 
public org.springframework.samples.jpetstore.domain.OrdergetOrder()

 return order; 
public booleanisConfirmed()

 return confirmed; 
public booleanisShippingAddressRequired()

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

    super.reset(mapping, request);
    shippingAddressRequired = false;
  
public voidsetConfirmed(boolean confirmed)

 this.confirmed = confirmed; 
public voidsetOrder(org.springframework.samples.jpetstore.domain.Order order)

 this.order = order; 
public voidsetShippingAddressRequired(boolean shippingAddressRequired)

 this.shippingAddressRequired = shippingAddressRequired;