Class AddressesForm
java.lang.Object
org.apache.struts.action.ActionForm
com.softslate.commerce.customer.core.BaseForm
com.softslate.commerce.customer.order.BillingAddressForm
com.softslate.commerce.customer.order.AddressesForm
- All Implemented Interfaces:
Serializable
- Direct Known Subclasses:
AddressBookAddressForm
,CheckoutAddressesForm
Struts form class representing a user's billing and delivery addresses. It is
also a superclass of
CheckoutAddressesForm
, which
is used for submissions to "/CheckoutAddresses.do", where both billing and
delivery addresses, as well as a shipping option, are submitted.
AddressesForm
is a subclass of
BillingAddressForm
, and it
inherits its billing address properties.
The validate
method of this class first checks to see if the
user chose to use the same address for billing and delivery. If so, it copies
the billing address properties to the delivery properties. It then loops
through the "deliveryRequired" database setting and makes sure each required
field is populated. It also checks to make sure the submitted delivery state
or province corresponds to the submitted country, and that fields such as
emails and phone numbers are in a valid format.
- Author:
- David Tobey
- See Also:
-
Field Summary
Modifier and TypeFieldDescriptionprivate String
private String
private String
private String
private String
private String
private String
private String
private String
private String
private String
private String
private String
private String
private String
private String
private String
private String
private String
private String
private boolean
(package private) static org.apache.commons.logging.Log
private static final long
Fields inherited from class org.apache.struts.action.ActionForm
multipartRequestHandler, servlet
-
Constructor Summary
-
Method Summary
Modifier and TypeMethodDescriptionvoid
If this forms deliveryUseBilling property is set, copies billing properties to delivery properties.boolean
boolean
isDeliveryFieldValid
(String thisFieldString, String thisValue) For a given field, validates the value of the field in this form.void
prepareStateAndOtherFields
(Customer customer) Prepares the billingState, billingOther, deliveryState, and deliveryOther fields for presentation.void
prepareStateAndOtherFields
(Order order) Prepares the billingState, billingOther, deliveryState, and deliveryOther fields for presentation.void
setDeliveryAddress1
(String string) void
setDeliveryAddress2
(String string) void
setDeliveryCity
(String string) void
setDeliveryCountry
(String string) void
setDeliveryEmail1
(String string) void
setDeliveryEmail2
(String string) void
setDeliveryExtra1
(String string) void
setDeliveryExtra2
(String string) void
setDeliveryExtra3
(String deliveryExtra3) void
setDeliveryExtra4
(String deliveryExtra4) void
setDeliveryExtra5
(String deliveryExtra5) void
setDeliveryFirstName
(String string) void
setDeliveryLastName
(String string) void
setDeliveryNotes
(String string) void
setDeliveryOrganization
(String string) void
setDeliveryOther
(String string) void
setDeliveryPhone1
(String string) void
setDeliveryPhone2
(String string) void
setDeliveryPostalCode
(String string) void
setDeliveryState
(String string) void
setDeliveryUseBilling
(boolean b) org.apache.struts.action.ActionErrors
validate
(org.apache.struts.action.ActionMapping mapping, javax.servlet.http.HttpServletRequest request) void
Validates this form's delivery fields.void
Validate this form's state field.Methods inherited from class com.softslate.commerce.customer.order.BillingAddressForm
doesCountryAllowOtherStates, getBillingAddress1, getBillingAddress2, getBillingCity, getBillingCountry, getBillingEmail1, getBillingEmail2, getBillingExtra1, getBillingExtra2, getBillingExtra3, getBillingExtra4, getBillingExtra5, getBillingFirstName, getBillingLastName, getBillingNotes, getBillingOrganization, getBillingOther, getBillingPhone1, getBillingPhone2, getBillingPostalCode, getBillingState, getCsrfToken, isBillingFieldValid, isOtherState, setBillingAddress1, setBillingAddress2, setBillingCity, setBillingCountry, setBillingEmail1, setBillingEmail2, setBillingExtra1, setBillingExtra2, setBillingExtra3, setBillingExtra4, setBillingExtra5, setBillingFirstName, setBillingLastName, setBillingNotes, setBillingOrganization, setBillingOther, setBillingPhone1, setBillingPhone2, setBillingPostalCode, setBillingState, setCsrfToken, stateAndCountryMatch, validateBillingFields, validateBillingStateField
Methods inherited from class com.softslate.commerce.customer.core.BaseForm
formUtils, getBusinessObjectFactory, getErrors, getMapping, getMessage, getMessages, getRequest, getSettings, getUser, html5OrXhtml, initializeProperties, setBusinessObjectFactory, setErrors, setMapping, setMessages, setRequest, setSettings, setUser
Methods inherited from class org.apache.struts.action.ActionForm
getMultipartRequestHandler, getServlet, getServletWrapper, reset, reset, setMultipartRequestHandler, setServlet, validate
-
Field Details
-
serialVersionUID
private static final long serialVersionUID- See Also:
-
log
static org.apache.commons.logging.Log log -
deliveryUseBilling
private boolean deliveryUseBilling -
deliveryFirstName
-
deliveryLastName
-
deliveryOrganization
-
deliveryAddress1
-
deliveryAddress2
-
deliveryCity
-
deliveryState
-
deliveryOther
-
deliveryPostalCode
-
deliveryCountry
-
deliveryPhone1
-
deliveryPhone2
-
deliveryEmail1
-
deliveryEmail2
-
deliveryExtra1
-
deliveryExtra2
-
deliveryExtra3
-
deliveryExtra4
-
deliveryExtra5
-
deliveryNotes
-
-
Constructor Details
-
AddressesForm
public AddressesForm()
-
-
Method Details
-
getDeliveryUseBilling
public boolean getDeliveryUseBilling() -
getDeliveryAddress1
-
getDeliveryAddress2
-
getDeliveryCity
-
getDeliveryCountry
-
getDeliveryEmail1
-
getDeliveryEmail2
-
getDeliveryExtra1
-
getDeliveryExtra2
-
getDeliveryFirstName
-
getDeliveryLastName
-
getDeliveryNotes
-
getDeliveryOrganization
-
getDeliveryPhone1
-
getDeliveryPhone2
-
getDeliveryPostalCode
-
getDeliveryState
-
getDeliveryOther
-
setDeliveryUseBilling
public void setDeliveryUseBilling(boolean b) -
setDeliveryAddress1
-
setDeliveryAddress2
-
setDeliveryCity
-
setDeliveryCountry
-
setDeliveryEmail1
-
setDeliveryEmail2
-
setDeliveryExtra1
-
setDeliveryExtra2
-
getDeliveryExtra3
-
setDeliveryExtra3
-
getDeliveryExtra4
-
setDeliveryExtra4
-
getDeliveryExtra5
-
setDeliveryExtra5
-
setDeliveryFirstName
-
setDeliveryLastName
-
setDeliveryNotes
-
setDeliveryOrganization
-
setDeliveryPhone1
-
setDeliveryPhone2
-
setDeliveryPostalCode
-
setDeliveryState
-
setDeliveryOther
-
validate
public org.apache.struts.action.ActionErrors validate(org.apache.struts.action.ActionMapping mapping, javax.servlet.http.HttpServletRequest request) - Overrides:
validate
in classBillingAddressForm
-
copyBillingToDelivery
public void copyBillingToDelivery()If this forms deliveryUseBilling property is set, copies billing properties to delivery properties. -
validateDeliveryFields
public void validateDeliveryFields()Validates this form's delivery fields. First, this method loops through the fields in the "deliveryRequired" setting and check that each of the corresponding properties of this form are populated. Second, it loops through the fields in the "deliveryValidated" setting and ensures the field values are valid. (For example, that the email is in valid form.) -
isDeliveryFieldValid
For a given field, validates the value of the field in this form. Emails are validated with a regular expression. Phone numbers are checked just to ensure at least 10 digits are present. And postal codes are checked for at least five digits if the country is the US.- Parameters:
thisFieldString
- The name of the field to validatethisValue
- The field's value- Returns:
- True, if the field's value is valid
-
validateDeliveryStateField
public void validateDeliveryStateField()Validate this form's state field. One, if 'Other' was selected as the state, this method ensures that a value for the other field is present. Two, if 'Other' was not selected, the state is checked to make sure it matches with the submitted country. -
prepareStateAndOtherFields
Prepares the billingState, billingOther, deliveryState, and deliveryOther fields for presentation. Determines if a givenCustomer
's address uses a 'Other' state and if so populates the fields accordingly.- Overrides:
prepareStateAndOtherFields
in classBillingAddressForm
- Parameters:
customer
- The given customer whose address fields are being prepared.
-
prepareStateAndOtherFields
Prepares the billingState, billingOther, deliveryState, and deliveryOther fields for presentation. Determines if a givenOrder
's address uses a 'Other' state and if so populates the fields accordingly.- Overrides:
prepareStateAndOtherFields
in classBillingAddressForm
- Parameters:
order
- The given order whose address fields are being prepared.
-