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

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

Go to download

Core API for legacy Struts-based site framework with AOServ Platform control panels.

There is a newer version: 2.0.0
Show newest version
/*
 * aoweb-struts-core - Core API for legacy Struts-based site framework with AOServ Platform control panels.
 * Copyright (C) 2007-2009, 2015, 2016  AO Industries, Inc.
 *     [email protected]
 *     7262 Bull Pen Cir
 *     Mobile, AL 36695
 *
 * This file is part of aoweb-struts-core.
 *
 * aoweb-struts-core is free software: you can redistribute it and/or modify
 * it under the terms of the GNU Lesser General Public License as published by
 * the Free Software Foundation, either version 3 of the License, or
 * (at your option) any later version.
 *
 * aoweb-struts-core is distributed in the hope that it will be useful,
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 * GNU Lesser General Public License for more details.
 *
 * You should have received a copy of the GNU Lesser General Public License
 * along with aoweb-struts-core.  If not, see .
 */
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  SiteSettings#getRootAOServConnector()
	 */
	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