All Downloads are FREE. Search and download functionalities are using the official Maven repository.

com.aoindustries.website.signup.SignupBusinessActionHelper Maven / Gradle / Ivy

/*
 * Copyright 2007-2009, 2015, 2016 by AO Industries, Inc.,
 * 7262 Bull Pen Cir, Mobile, Alabama, 36695, U.S.A.
 * All rights reserved.
 */
package com.aoindustries.website.signup;

import com.aoindustries.aoserv.client.AOServConnector;
import com.aoindustries.aoserv.client.CountryCode;
import com.aoindustries.encoding.ChainWriter;
import com.aoindustries.website.SiteSettings;
import static com.aoindustries.website.signup.ApplicationResources.accessor;
import java.io.IOException;
import java.sql.SQLException;
import java.util.ArrayList;
import java.util.List;
import javax.servlet.ServletContext;
import javax.servlet.http.HttpServletRequest;
import org.apache.commons.validator.GenericValidator;

/**
 * Managed3Action and Dedicated3Action both use this to setup the request attributes.  This is implemented
 * here because inheritance is not possible and neither one is logically above the other.
 *
 * @author  AO Industries, Inc.
 */
final public class SignupBusinessActionHelper {

	/**
	 * Make no instances.
	 */
	private SignupBusinessActionHelper() {}

	public static void setRequestAttributes(
		ServletContext servletContext,
		HttpServletRequest request
	) throws IOException, SQLException {
		AOServConnector rootConn=SiteSettings.getInstance(servletContext).getRootAOServConnector();

		// Build the list of countries
		List countryOptions = getCountryOptions(rootConn);

		// Store to the request
		request.setAttribute("countryOptions", countryOptions);
	}

	/**
	 * Gets the options for use in a country list.
	 * Note: you probably want to use the RootAOServConnector to provide a more helpful list than a
	 * default user connector.
	 *
	 * @see  RootAOServConnector
	 */
	public static List getCountryOptions(AOServConnector aoConn) throws IOException, SQLException {
		// Build the list of countries
		List countryOptions = new ArrayList();
		countryOptions.add(new CountryOption("", "---"));
		final int prioritySize = 10;
		int[] priorityCounter = new int[1];
		boolean selectedOne = false;
	List cc = aoConn.getCountryCodes().getCountryCodesByPriority(prioritySize, priorityCounter);
	for (int i = 0; i\n"
					 + "        ").print(accessor.getMessage("signup.required")).print("\n"
					 + "        ").print(accessor.getMessage("signupBusinessForm.businessName.prompt")).print("\n"
					 + "        ").encodeXhtml(signupBusinessForm.getBusinessName()).print("\n"
					 + "    \n"
					 + "    \n"
					 + "        ").print(accessor.getMessage("signup.required")).print("\n"
					 + "        ").print(accessor.getMessage("signupBusinessForm.businessPhone.prompt")).print("\n"
					 + "        ").encodeXhtml(signupBusinessForm.getBusinessPhone()).print("\n"
					 + "    \n"
					 + "    \n"
					 + "        ").print(accessor.getMessage("signup.notRequired")).print("\n"
					 + "        ").print(accessor.getMessage("signupBusinessForm.businessFax.prompt")).print("\n"
					 + "        ").encodeXhtml(signupBusinessForm.getBusinessFax()).print("\n"
					 + "    \n"
					 + "    \n"
					 + "        ").print(accessor.getMessage("signup.required")).print("\n"
					 + "        ").print(accessor.getMessage("signupBusinessForm.businessAddress1.prompt")).print("\n"
					 + "        ").encodeXhtml(signupBusinessForm.getBusinessAddress1()).print("\n"
					 + "    \n");
		if(!GenericValidator.isBlankOrNull(signupBusinessForm.getBusinessAddress2())) {
			emailOut.print("    \n"
						 + "        ").print(accessor.getMessage("signup.notRequired")).print("\n"
						 + "        ").print(accessor.getMessage("signupBusinessForm.businessAddress2.prompt")).print("\n"
						 + "        ").encodeXhtml(signupBusinessForm.getBusinessAddress2()).print("\n"
						 + "    \n");
		}
		emailOut.print("    \n"
					 + "        ").print(accessor.getMessage("signup.required")).print("\n"
					 + "        ").print(accessor.getMessage("signupBusinessForm.businessCity.prompt")).print("\n"
					 + "        ").encodeXhtml(signupBusinessForm.getBusinessCity()).print("\n"
					 + "    \n"
					 + "    \n"
					 + "        ").print(accessor.getMessage("signup.notRequired")).print("\n"
					 + "        ").print(accessor.getMessage("signupBusinessForm.businessState.prompt")).print("\n"
					 + "        ").encodeXhtml(signupBusinessForm.getBusinessState()).print("\n"
					 + "    \n"
					 + "    \n"
					 + "        ").print(accessor.getMessage("signup.required")).print("\n"
					 + "        ").print(accessor.getMessage("signupBusinessForm.businessCountry.prompt")).print("\n"
					 + "        ").encodeXhtml(getBusinessCountry(rootConn, signupBusinessForm)).print("\n"
					 + "    \n"
					 + "    \n"
					 + "        ").print(accessor.getMessage("signup.notRequired")).print("\n"
					 + "        ").print(accessor.getMessage("signupBusinessForm.businessZip.prompt")).print("\n"
					 + "        ").encodeXhtml(signupBusinessForm.getBusinessZip()).print("\n"
					 + "    \n");
	}
}




© 2015 - 2025 Weber Informatics LLC | Privacy Policy