Class BillingAddressForm
java.lang.Object
org.apache.struts.action.ActionForm
com.softslate.commerce.customer.core.BaseForm
com.softslate.commerce.customer.order.BillingAddressForm
- All Implemented Interfaces:
Serializable
- Direct Known Subclasses:
AddressesForm,AuthorizeNetBillingAddressForm
Struts form class representing a user's billing address. The class is used
for submissions of billing address information in the customer account area.
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.
The validate method of this class loops through the
"billingRequired" database setting and makes sure each required field is
populated. It also checks to make sure the submitted 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
FieldsModifier and TypeFieldDescriptionprivate Stringprivate Stringprivate Stringprivate Stringprivate Stringprivate Stringprivate Stringprivate Stringprivate Stringprivate Stringprivate Stringprivate Stringprivate Stringprivate Stringprivate Stringprivate Stringprivate Stringprivate Stringprivate Stringprivate Stringprivate String(package private) static org.apache.commons.logging.Logprivate static final longFields inherited from class org.apache.struts.action.ActionForm
multipartRequestHandler, servlet -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionbooleandoesCountryAllowOtherStates(String country) Determines if a given country is set to allow 'Other' states.booleanisBillingFieldValid(String thisFieldString, String thisValue) For a given field, validates the value of the field in this form.booleanisOtherState(String state) Determines if a given state is a 'Other' state.voidprepareStateAndOtherFields(Customer customer) Prepares the billingState and billingOther fields for presentation in a form.voidprepareStateAndOtherFields(Order order) Prepares the billingState and billingOther fields for presentation in a form.voidsetBillingAddress1(String string) voidsetBillingAddress2(String string) voidsetBillingCity(String string) voidsetBillingCountry(String string) voidsetBillingEmail1(String string) voidsetBillingEmail2(String string) voidsetBillingExtra1(String string) voidsetBillingExtra2(String string) voidsetBillingExtra3(String billingExtra3) voidsetBillingExtra4(String billingExtra4) voidsetBillingExtra5(String billingExtra5) voidsetBillingFirstName(String string) voidsetBillingLastName(String string) voidsetBillingNotes(String string) voidsetBillingOrganization(String string) voidsetBillingOther(String string) voidsetBillingPhone1(String string) voidsetBillingPhone2(String string) voidsetBillingPostalCode(String string) voidsetBillingState(String string) voidsetCsrfToken(String csrfToken) booleanstateAndCountryMatch(String state, String country) Checks to make sure this form's state and country match.org.apache.struts.action.ActionErrorsvalidate(org.apache.struts.action.ActionMapping mapping, javax.servlet.http.HttpServletRequest request) voidValidates the billing fields of this form.voidValidate this form's state field.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, setUserMethods 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 -
billingFirstName
-
billingLastName
-
billingOrganization
-
billingAddress1
-
billingAddress2
-
billingCity
-
billingState
-
billingOther
-
billingPostalCode
-
billingCountry
-
billingPhone1
-
billingPhone2
-
billingEmail1
-
billingEmail2
-
billingExtra1
-
billingExtra2
-
billingExtra3
-
billingExtra4
-
billingExtra5
-
billingNotes
-
csrfToken
-
-
Constructor Details
-
BillingAddressForm
public BillingAddressForm()
-
-
Method Details
-
getBillingAddress1
-
getBillingAddress2
-
getBillingCity
-
getBillingCountry
-
getBillingEmail1
-
getBillingEmail2
-
getBillingExtra1
-
getBillingExtra2
-
getBillingFirstName
-
getBillingLastName
-
getBillingNotes
-
getBillingOrganization
-
getBillingPhone1
-
getBillingPhone2
-
getBillingPostalCode
-
getBillingState
-
getBillingOther
-
setBillingAddress1
-
setBillingAddress2
-
setBillingCity
-
setBillingCountry
-
setBillingEmail1
-
setBillingEmail2
-
setBillingExtra1
-
setBillingExtra2
-
getBillingExtra3
-
setBillingExtra3
-
getBillingExtra4
-
setBillingExtra4
-
getBillingExtra5
-
setBillingExtra5
-
setBillingFirstName
-
setBillingLastName
-
setBillingNotes
-
setBillingOrganization
-
setBillingPhone1
-
setBillingPhone2
-
setBillingPostalCode
-
setBillingState
-
setBillingOther
-
getCsrfToken
-
setCsrfToken
-
validate
public org.apache.struts.action.ActionErrors validate(org.apache.struts.action.ActionMapping mapping, javax.servlet.http.HttpServletRequest request) - Overrides:
validatein classorg.apache.struts.action.ActionForm
-
validateBillingFields
public void validateBillingFields()Validates the billing fields of this form. First, this method loops through the fields in the "billingRequired" setting and check that each of the corresponding properties of this form are populated. Second, it loops through the fields in the "billingValidated" setting and ensures the field values are valid. (For example, that the email is in valid form.) -
isBillingFieldValid
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
-
validateBillingStateField
public void validateBillingStateField()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. -
stateAndCountryMatch
Checks to make sure this form's state and country match. In other words, if the given state is contained in thesscStatetable, the given country must correspond to that state's country. If the given state is a 'Other' state, the given country must have its allowOtherStates flag set.- Parameters:
state- The string representing the state to be checked. This will be the two-letter state code from thecodefield of thesscStatetable, or some other string inputted by the user (if it is a 'Other' state).country- The string representing the country to be checked. This will be the two-letter country code from thecodefield of thesscCountrytable.- Returns:
- true, if the state and country match.
-
prepareStateAndOtherFields
Prepares the billingState and billingOther fields for presentation in a form. Determines if a givenCustomer's billing address uses a 'Other' state and if so populates the billingOther and billingState fields accordingly. If it does use a 'Other' state, this method populates the billingState field with the string "Other" and populates the billingOther field with the value of billingState, so the address forms will accurately represent the customer's state.- Parameters:
customer- The given customer whose address fields are being prepared.
-
prepareStateAndOtherFields
Prepares the billingState and billingOther fields for presentation in a form. Determines if a givenOrder's billing address uses a 'Other' state and if so populates the billingOther and billingState fields accordingly. If it does use a 'Other' state, this method populates the billingState field with the string "Other" and populates the billingOther field with the value of billingState, so the address forms will accurately represent the customer's state.- Parameters:
order- The given order whose address fields are being prepared.
-
isOtherState
Determines if a given state is a 'Other' state. In other words, determines if the value of the state is contained in thesscStatedatabase table or if it corresponds to a state or province in a foreign country not supported bysscState.- Parameters:
state- The string representing the state to be checked. This will be the two-letter state code from thecodefield of thesscStatetable, or some other string inputted by the user (if it is a 'Other' state).- Returns:
- true, if the given state is a 'Other' state.
-
doesCountryAllowOtherStates
Determines if a given country is set to allow 'Other' states.- Parameters:
country- The string representing the country to be checked. This will be the two-letter country code from thecodefield of thesscCountrytable.- Returns:
- true, if the given country is set to allow 'Other' states.
-