You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@tomcat.apache.org by cr...@apache.org on 2001/10/25 18:37:38 UTC
cvs commit: jakarta-tomcat-4.0/webapps/admin/WEB-INF/classes/org/apache/webapp/admin ApplicationLocales.java ApplicationResources_en.properties ApplicationResources_es.properties ApplicationServlet.java LogOutAction.java SampleAction.java SampleForm.java SetLocaleAction.java SetLocaleForm.java
craigmcc 01/10/25 09:37:38
Added: webapps/admin/WEB-INF/classes/org/apache/webapp/admin
ApplicationLocales.java
ApplicationResources_en.properties
ApplicationResources_es.properties
ApplicationServlet.java LogOutAction.java
SampleAction.java SampleForm.java
SetLocaleAction.java SetLocaleForm.java
Log:
Java classes and application resources for the infrastructure of the
Config/Admin application.
Revision Changes Path
1.1 jakarta-tomcat-4.0/webapps/admin/WEB-INF/classes/org/apache/webapp/admin/ApplicationLocales.java
Index: ApplicationLocales.java
===================================================================
/*
* $Header: /home/cvs/jakarta-tomcat-4.0/webapps/admin/WEB-INF/classes/org/apache/webapp/admin/ApplicationLocales.java,v 1.1 2001/10/25 16:37:38 craigmcc Exp $
* $Revision: 1.1 $
* $Date: 2001/10/25 16:37:38 $
*
* ====================================================================
*
* The Apache Software License, Version 1.1
*
* Copyright (c) 2001 The Apache Software Foundation. All rights
* reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
* are met:
*
* 1. Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer.
*
* 2. Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in
* the documentation and/or other materials provided with the
* distribution.
*
* 3. The end-user documentation included with the redistribution, if
* any, must include the following acknowlegement:
* "This product includes software developed by the
* Apache Software Foundation (http://www.apache.org/)."
* Alternately, this acknowlegement may appear in the software itself,
* if and wherever such third-party acknowlegements normally appear.
*
* 4. The names "The Jakarta Project", "Struts", and "Apache Software
* Foundation" must not be used to endorse or promote products derived
* from this software without prior written permission. For written
* permission, please contact apache@apache.org.
*
* 5. Products derived from this software may not be called "Apache"
* nor may "Apache" appear in their names without prior written
* permission of the Apache Group.
*
* THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED
* WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
* OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
* DISCLAIMED. IN NO EVENT SHALL THE APACHE SOFTWARE FOUNDATION OR
* ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
* LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF
* USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
* ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
* OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT
* OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
* SUCH DAMAGE.
* ====================================================================
*
* This software consists of voluntary contributions made by many
* individuals on behalf of the Apache Software Foundation. For more
* information on the Apache Software Foundation, please see
* <http://www.apache.org/>.
*
*/
package org.apache.webapp.admin;
import java.util.ArrayList;
import java.util.List;
import java.util.Locale;
import java.util.ResourceBundle;
import org.apache.struts.action.ActionServlet;
import org.apache.struts.util.MessageResources;
/**
* Class to hold the Locales supported by this package.
*
* @author Patrick Luby
* @author Craig R. McClanahan
* @version $Revision: 1.1 $ $Date: 2001/10/25 16:37:38 $
*/
public final class ApplicationLocales {
// ----------------------------------------------------------- Constructors
/**
* Initialize the set of Locales supported by this application.
*
* @param servlet ActionServlet we are associated with
*/
public ApplicationLocales(ActionServlet servlet) {
super();
Locale list[] = Locale.getAvailableLocales();
MessageResources resources = servlet.getResources();
if (resources == null)
return;
String config = resources.getConfig();
if (config == null)
return;
for (int i = 0; i < list.length; i++) {
ResourceBundle bundle =
ResourceBundle.getBundle(config, list[i]);
if (bundle == null)
continue;
if (list[i].equals(bundle.getLocale())) {
localeLabels.add(list[i].getDisplayName());
localeValues.add(list[i].toString());
supportedLocales.add(list[i]);
}
}
}
// ----------------------------------------------------- Instance Variables
/**
* The set of Locale labels supported by this application.
*/
protected ArrayList localeLabels = new ArrayList();
/**
* The set of Locale values supported by this application.
*/
protected ArrayList localeValues = new ArrayList();
/**
* The set of supported Locales for this application.
*/
protected ArrayList supportedLocales = new ArrayList();
// --------------------------------------------------------- Public Methods
/**
* Return the set of Locale labels supported by this application.
*/
public List getLocaleLabels() {
return (localeLabels);
}
/**
* Return the set of Locale values supported by this application.
*/
public List getLocaleValues() {
return (localeValues);
}
/**
* Return the set of Locales supported by this application.
*/
public List getSupportedLocales() {
return (supportedLocales);
}
}
1.1 jakarta-tomcat-4.0/webapps/admin/WEB-INF/classes/org/apache/webapp/admin/ApplicationResources_en.properties
Index: ApplicationResources_en.properties
===================================================================
application.title=Tomcat Server Configuration
errors.header=<h2><font color="red">Validation Errors</font></h2>You must correct the following errors before proceeding:<ul>
errors.footer=</ul><hr>
error.login=<li>Invalid username or password</li>
prompt.username=Username
prompt.password=Password
button.login=Login
button.reset=Reset
button.save=Save
button.change=Change
login.enter=Enter a username and password to start a new session
login.changeLanguage=Change the language
index.success=Login successful!
index.logout=To end this session, click
index.here=here
error.login=Invalid username or password, please try again
error.tryagain=To try again, click
error.here=here
prompt.someText=Some Text
prompt.moreText=More Text
sample.someText.required=<li>"Some Text" cannot be empty</li>
sample.moreText.required=<li>"More Text" cannot be empty</li>
1.1 jakarta-tomcat-4.0/webapps/admin/WEB-INF/classes/org/apache/webapp/admin/ApplicationResources_es.properties
Index: ApplicationResources_es.properties
===================================================================
application.title=Configuraci\u00f3n de Servidor de Tomcat
errors.header=<h3><font color="red">Fallos de Validaci\u00f3n</font></h3>Debe correctar los fallos siguientes antes de proceder:<ul>
errors.footer=</ul><hr>
error.login=<li>Nombre de usuario inv\u00e1lido o contrase\u00f1a inv\u00e1lida</li>
prompt.username=Nombre de Usuario
prompt.password=Contrase\u00f1a
button.login=Autenticar
button.reset=Reiniciar
button.save=Guardar
button.change=Cambiar
login.enter=Introduzca un nombre de usuario y una contrase\u00f1a que empezar una sesi\u00f3n nueva
login.changeLanguage=Cambie el idioma
index.success=\u00a1Autenticaci\u00f3n tiene \u00e9xito!
index.logout=Para terminar esta sesi\u00f3n, pulse
index.here=aqu\u00ed
error.tryagain=Para intentar de nuevo, pulse
error.here=aqu\u00ed
prompt.someText=Alg\u00fan Texto
prompt.moreText=M\u00e1s Texto
sample.someText.required=<li>\u00abAlg\u00fan Texto\u00bb no puede ser vac\u00edo</li>
sample.moreText.required=<li>\u00abM\u00e1s Texto\u00bb no puede ser vac\u00edo</li>
1.1 jakarta-tomcat-4.0/webapps/admin/WEB-INF/classes/org/apache/webapp/admin/ApplicationServlet.java
Index: ApplicationServlet.java
===================================================================
/*
* $Header: /home/cvs/jakarta-tomcat-4.0/webapps/admin/WEB-INF/classes/org/apache/webapp/admin/ApplicationServlet.java,v 1.1 2001/10/25 16:37:38 craigmcc Exp $
* $Revision: 1.1 $
* $Date: 2001/10/25 16:37:38 $
*
* ====================================================================
*
* The Apache Software License, Version 1.1
*
* Copyright (c) 2001 The Apache Software Foundation. All rights
* reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
* are met:
*
* 1. Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer.
*
* 2. Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in
* the documentation and/or other materials provided with the
* distribution.
*
* 3. The end-user documentation included with the redistribution, if
* any, must include the following acknowlegement:
* "This product includes software developed by the
* Apache Software Foundation (http://www.apache.org/)."
* Alternately, this acknowlegement may appear in the software itself,
* if and wherever such third-party acknowlegements normally appear.
*
* 4. The names "The Jakarta Project", "Struts", and "Apache Software
* Foundation" must not be used to endorse or promote products derived
* from this software without prior written permission. For written
* permission, please contact apache@apache.org.
*
* 5. Products derived from this software may not be called "Apache"
* nor may "Apache" appear in their names without prior written
* permission of the Apache Group.
*
* THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED
* WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
* OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
* DISCLAIMED. IN NO EVENT SHALL THE APACHE SOFTWARE FOUNDATION OR
* ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
* LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF
* USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
* ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
* OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT
* OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
* SUCH DAMAGE.
* ====================================================================
*
* This software consists of voluntary contributions made by many
* individuals on behalf of the Apache Software Foundation. For more
* information on the Apache Software Foundation, please see
* <http://www.apache.org/>.
*
*/
package org.apache.webapp.admin;
import java.text.DateFormat;
import java.util.HashSet;
import java.util.Locale;
import java.util.ResourceBundle;
import javax.servlet.ServletException;
import org.apache.struts.action.ActionServlet;
import org.apache.struts.util.MessageResources;
/**
* Subclass of ActionServlet that adds caching of the supported locales in the
* ApplicationLocales class.
*
* @author Patrick Luby
* @version $Revision: 1.1 $ $Date: 2001/10/25 16:37:38 $
*/
public class ApplicationServlet extends ActionServlet {
// ----------------------------------------------------- Manifest Constants
/**
* The application scope key under which we store our
* <code>ApplicationLocales</code> instance.
*/
public static final String LOCALES_KEY = "applicationLocales";
// --------------------------------------------------------- Public Methods
/**
* Initialize this servlet.
*/
public void init() throws javax.servlet.ServletException {
// Perform normal superclass initialization
super.init();
// Create an ApplicationLocales object
ApplicationLocales locales = new ApplicationLocales(this);
getServletContext().setAttribute(LOCALES_KEY, locales);
}
}
1.1 jakarta-tomcat-4.0/webapps/admin/WEB-INF/classes/org/apache/webapp/admin/LogOutAction.java
Index: LogOutAction.java
===================================================================
/*
* $Header: /home/cvs/jakarta-tomcat-4.0/webapps/admin/WEB-INF/classes/org/apache/webapp/admin/LogOutAction.java,v 1.1 2001/10/25 16:37:38 craigmcc Exp $
* $Revision: 1.1 $
* $Date: 2001/10/25 16:37:38 $
*
* ====================================================================
*
* The Apache Software License, Version 1.1
*
* Copyright (c) 2001 The Apache Software Foundation. All rights
* reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
* are met:
*
* 1. Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer.
*
* 2. Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in
* the documentation and/or other materials provided with the
* distribution.
*
* 3. The end-user documentation included with the redistribution, if
* any, must include the following acknowlegement:
* "This product includes software developed by the
* Apache Software Foundation (http://www.apache.org/)."
* Alternately, this acknowlegement may appear in the software itself,
* if and wherever such third-party acknowlegements normally appear.
*
* 4. The names "The Jakarta Project", "Struts", and "Apache Software
* Foundation" must not be used to endorse or promote products derived
* from this software without prior written permission. For written
* permission, please contact apache@apache.org.
*
* 5. Products derived from this software may not be called "Apache"
* nor may "Apache" appear in their names without prior written
* permission of the Apache Group.
*
* THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED
* WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
* OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
* DISCLAIMED. IN NO EVENT SHALL THE APACHE SOFTWARE FOUNDATION OR
* ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
* LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF
* USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
* ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
* OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT
* OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
* SUCH DAMAGE.
* ====================================================================
*
* This software consists of voluntary contributions made by many
* individuals on behalf of the Apache Software Foundation. For more
* information on the Apache Software Foundation, please see
* <http://www.apache.org/>.
*
*/
package org.apache.webapp.admin;
import java.io.IOException;
import java.util.Iterator;
import java.util.List;
import java.util.Locale;
import javax.servlet.ServletException;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import javax.servlet.http.HttpSession;
import org.apache.struts.action.Action;
import org.apache.struts.action.ActionErrors;
import org.apache.struts.action.ActionForm;
import org.apache.struts.action.ActionForward;
import org.apache.struts.action.ActionMapping;
/**
* Implementation of <strong>Action</strong> that logs out of the current
* session and returns to the main menu (which will trigger the login form).
*
* @author Craig R. McClanahan
* @version $Revision: 1.1 $ $Date: 2001/10/25 16:37:38 $
*/
public final class LogOutAction extends Action {
// --------------------------------------------------------- Public Methods
/**
* Process the specified HTTP request, and create the corresponding HTTP
* response (or forward to another web component that will create it).
* Return an <code>ActionForward</code> instance describing where and how
* control should be forwarded, or <code>null</code> if the response has
* already been completed.
*
* @param mapping The ActionMapping used to select this instance
* @param actionForm The optional ActionForm bean for this request (if any)
* @param request The HTTP request we are processing
* @param response The HTTP response we are creating
*
* @exception IOException if an input/output error occurs
* @exception ServletException if a servlet exception occurs
*/
public ActionForward perform(ActionMapping mapping,
ActionForm form,
HttpServletRequest request,
HttpServletResponse response)
throws IOException, ServletException {
// Invalidate the current session and create a new one
HttpSession session = request.getSession();
session.invalidate();
session = request.getSession(true);
// Forward control back to the main menu
return (mapping.findForward("Main Menu"));
}
}
1.1 jakarta-tomcat-4.0/webapps/admin/WEB-INF/classes/org/apache/webapp/admin/SampleAction.java
Index: SampleAction.java
===================================================================
/*
* $Header: /home/cvs/jakarta-tomcat-4.0/webapps/admin/WEB-INF/classes/org/apache/webapp/admin/SampleAction.java,v 1.1 2001/10/25 16:37:38 craigmcc Exp $
* $Revision: 1.1 $
* $Date: 2001/10/25 16:37:38 $
*
* ====================================================================
*
* The Apache Software License, Version 1.1
*
* Copyright (c) 2001 The Apache Software Foundation. All rights
* reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
* are met:
*
* 1. Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer.
*
* 2. Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in
* the documentation and/or other materials provided with the
* distribution.
*
* 3. The end-user documentation included with the redistribution, if
* any, must include the following acknowlegement:
* "This product includes software developed by the
* Apache Software Foundation (http://www.apache.org/)."
* Alternately, this acknowlegement may appear in the software itself,
* if and wherever such third-party acknowlegements normally appear.
*
* 4. The names "The Jakarta Project", "Struts", and "Apache Software
* Foundation" must not be used to endorse or promote products derived
* from this software without prior written permission. For written
* permission, please contact apache@apache.org.
*
* 5. Products derived from this software may not be called "Apache"
* nor may "Apache" appear in their names without prior written
* permission of the Apache Group.
*
* THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED
* WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
* OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
* DISCLAIMED. IN NO EVENT SHALL THE APACHE SOFTWARE FOUNDATION OR
* ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
* LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF
* USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
* ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
* OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT
* OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
* SUCH DAMAGE.
* ====================================================================
*
* This software consists of voluntary contributions made by many
* individuals on behalf of the Apache Software Foundation. For more
* information on the Apache Software Foundation, please see
* <http://www.apache.org/>.
*
*/
package org.apache.webapp.admin;
import java.io.IOException;
import javax.servlet.ServletException;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import org.apache.struts.action.Action;
import org.apache.struts.action.ActionErrors;
import org.apache.struts.action.ActionForm;
import org.apache.struts.action.ActionForward;
import org.apache.struts.action.ActionMapping;
/**
* Implementation of <strong>Action</strong> that validates a user logon.
*
* @author Patrick Luby
* @version $Revision: 1.1 $ $Date: 2001/10/25 16:37:38 $
*/
public final class SampleAction extends Action {
// --------------------------------------------------------- Public Methods
/**
* Process the specified HTTP request, and create the corresponding HTTP
* response (or forward to another web component that will create it).
* Return an <code>ActionForward</code> instance describing where and how
* control should be forwarded, or <code>null</code> if the response has
* already been completed.
*
* @param mapping The ActionMapping used to select this instance
* @param actionForm The optional ActionForm bean for this request (if any)
* @param request The HTTP request we are processing
* @param response The HTTP response we are creating
*
* @exception IOException if an input/output error occurs
* @exception ServletException if a servlet exception occurs
*/
public ActionForward perform(ActionMapping mapping,
ActionForm form,
HttpServletRequest request,
HttpServletResponse response)
throws IOException, ServletException {
// Always return to the input page. This method only saves the form
// data and redisplays the data with the saved values.
return new ActionForward(mapping.getInput());
}
}
1.1 jakarta-tomcat-4.0/webapps/admin/WEB-INF/classes/org/apache/webapp/admin/SampleForm.java
Index: SampleForm.java
===================================================================
/*
* $Header: /home/cvs/jakarta-tomcat-4.0/webapps/admin/WEB-INF/classes/org/apache/webapp/admin/SampleForm.java,v 1.1 2001/10/25 16:37:38 craigmcc Exp $
* $Revision: 1.1 $
* $Date: 2001/10/25 16:37:38 $
*
* ====================================================================
*
* The Apache Software License, Version 1.1
*
* Copyright (c) 2001 The Apache Software Foundation. All rights
* reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
* are met:
*
* 1. Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer.
*
* 2. Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in
* the documentation and/or other materials provided with the
* distribution.
*
* 3. The end-user documentation included with the redistribution, if
* any, must include the following acknowlegement:
* "This product includes software developed by the
* Apache Software Foundation (http://www.apache.org/)."
* Alternately, this acknowlegement may appear in the software itself,
* if and wherever such third-party acknowlegements normally appear.
*
* 4. The names "The Jakarta Project", "Struts", and "Apache Software
* Foundation" must not be used to endorse or promote products derived
* from this software without prior written permission. For written
* permission, please contact apache@apache.org.
*
* 5. Products derived from this software may not be called "Apache"
* nor may "Apache" appear in their names without prior written
* permission of the Apache Group.
*
* THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED
* WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
* OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
* DISCLAIMED. IN NO EVENT SHALL THE APACHE SOFTWARE FOUNDATION OR
* ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
* LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF
* USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
* ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
* OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT
* OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
* SUCH DAMAGE.
* ====================================================================
*
* This software consists of voluntary contributions made by many
* individuals on behalf of the Apache Software Foundation. For more
* information on the Apache Software Foundation, please see
* <http://www.apache.org/>.
*
*/
package org.apache.webapp.admin;
import javax.servlet.http.HttpServletRequest;
import org.apache.struts.action.ActionError;
import org.apache.struts.action.ActionErrors;
import org.apache.struts.action.ActionForm;
import org.apache.struts.action.ActionMapping;
/**
* Form bean for the user locale page. This form has the following fields,
* with default values in square brackets:
* <ul>
* <li><b>someText</b> - Entered text value
* <li><b>moreText</b> - Entered text value
* </ul>
*
* @author Patrick Luby
* @version $Revision: 1.1 $ $Date: 2001/10/25 16:37:38 $
*/
public final class SampleForm extends ActionForm {
// ----------------------------------------------------- Instance Variables
/**
* The someText.
*/
private String someText = null;
/**
* The moreText.
*/
private String moreText = null;
// ------------------------------------------------------------- Properties
/**
* Return the someText.
*/
public String getSomeText() {
return this.someText;
}
/**
* Set the someText.
*/
public void setSomeText(String someText) {
this.someText = someText;
}
/**
* Return the moreText.
*/
public String getMoreText() {
return this.moreText;
}
/**
* Set the moreText.
*/
public void setMoreText(String moreText) {
this.moreText = moreText;
}
// --------------------------------------------------------- Public Methods
/**
* Reset all properties to their default values.
*
* @param mapping The mapping used to select this instance
* @param request The servlet request we are processing
*/
public void reset(ActionMapping mapping, HttpServletRequest request) {
this.someText = null;
this.moreText = null;
}
/**
* Validate the properties that have been set from this HTTP request,
* and return an <code>ActionErrors</code> object that encapsulates any
* validation errors that have been found. If no errors are found, return
* <code>null</code> or an <code>ActionErrors</code> object with no
* recorded error messages.
*
* @param mapping The mapping used to select this instance
* @param request The servlet request we are processing
*/
public ActionErrors validate(ActionMapping mapping,
HttpServletRequest request) {
ActionErrors errors = new ActionErrors();
if ((someText == null) || (someText.length() < 1))
errors.add("someText", new ActionError("sample.someText.required"));
if ((moreText == null) || (moreText.length() < 1))
errors.add("moreText", new ActionError("sample.moreText.required"));
return errors;
}
}
1.1 jakarta-tomcat-4.0/webapps/admin/WEB-INF/classes/org/apache/webapp/admin/SetLocaleAction.java
Index: SetLocaleAction.java
===================================================================
/*
* $Header: /home/cvs/jakarta-tomcat-4.0/webapps/admin/WEB-INF/classes/org/apache/webapp/admin/SetLocaleAction.java,v 1.1 2001/10/25 16:37:38 craigmcc Exp $
* $Revision: 1.1 $
* $Date: 2001/10/25 16:37:38 $
*
* ====================================================================
*
* The Apache Software License, Version 1.1
*
* Copyright (c) 2001 The Apache Software Foundation. All rights
* reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
* are met:
*
* 1. Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer.
*
* 2. Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in
* the documentation and/or other materials provided with the
* distribution.
*
* 3. The end-user documentation included with the redistribution, if
* any, must include the following acknowlegement:
* "This product includes software developed by the
* Apache Software Foundation (http://www.apache.org/)."
* Alternately, this acknowlegement may appear in the software itself,
* if and wherever such third-party acknowlegements normally appear.
*
* 4. The names "The Jakarta Project", "Struts", and "Apache Software
* Foundation" must not be used to endorse or promote products derived
* from this software without prior written permission. For written
* permission, please contact apache@apache.org.
*
* 5. Products derived from this software may not be called "Apache"
* nor may "Apache" appear in their names without prior written
* permission of the Apache Group.
*
* THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED
* WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
* OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
* DISCLAIMED. IN NO EVENT SHALL THE APACHE SOFTWARE FOUNDATION OR
* ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
* LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF
* USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
* ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
* OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT
* OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
* SUCH DAMAGE.
* ====================================================================
*
* This software consists of voluntary contributions made by many
* individuals on behalf of the Apache Software Foundation. For more
* information on the Apache Software Foundation, please see
* <http://www.apache.org/>.
*
*/
package org.apache.webapp.admin;
import java.io.IOException;
import java.util.Iterator;
import java.util.List;
import java.util.Locale;
import javax.servlet.ServletException;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import javax.servlet.http.HttpSession;
import org.apache.struts.action.Action;
import org.apache.struts.action.ActionErrors;
import org.apache.struts.action.ActionForm;
import org.apache.struts.action.ActionForward;
import org.apache.struts.action.ActionMapping;
/**
* Implementation of <strong>Action</strong> that sets the current Locale
* to the one specified by the <code>locale</code> request parameter.
*
* @author Craig R. McClanahan
* @version $Revision: 1.1 $ $Date: 2001/10/25 16:37:38 $
*/
public final class SetLocaleAction extends Action {
// --------------------------------------------------------- Public Methods
/**
* Process the specified HTTP request, and create the corresponding HTTP
* response (or forward to another web component that will create it).
* Return an <code>ActionForward</code> instance describing where and how
* control should be forwarded, or <code>null</code> if the response has
* already been completed.
*
* @param mapping The ActionMapping used to select this instance
* @param actionForm The optional ActionForm bean for this request (if any)
* @param request The HTTP request we are processing
* @param response The HTTP response we are creating
*
* @exception IOException if an input/output error occurs
* @exception ServletException if a servlet exception occurs
*/
public ActionForward perform(ActionMapping mapping,
ActionForm form,
HttpServletRequest request,
HttpServletResponse response)
throws IOException, ServletException {
// What locale does the user want to switch to?
String requestedLocale = ((SetLocaleForm) form).getLocale();
// Switch to the specified locale, if it exists
if (requestedLocale != null) {
ApplicationLocales locales = (ApplicationLocales)
getServlet().getServletContext().getAttribute
(ApplicationServlet.LOCALES_KEY);
Iterator iterator = locales.getSupportedLocales().iterator();
Locale currentLocale = null;
while (iterator.hasNext()) {
currentLocale = (Locale) iterator.next();
if (requestedLocale.equals(currentLocale.toString())) {
HttpSession session = request.getSession();
session.setAttribute(Action.LOCALE_KEY, currentLocale);
// Remove form bean so it will get recreated next time
session.removeAttribute(mapping.getAttribute());
break;
}
}
}
// Forward control back to the main menu
return (mapping.findForward("Main Menu"));
}
}
1.1 jakarta-tomcat-4.0/webapps/admin/WEB-INF/classes/org/apache/webapp/admin/SetLocaleForm.java
Index: SetLocaleForm.java
===================================================================
/*
* $Header: /home/cvs/jakarta-tomcat-4.0/webapps/admin/WEB-INF/classes/org/apache/webapp/admin/SetLocaleForm.java,v 1.1 2001/10/25 16:37:38 craigmcc Exp $
* $Revision: 1.1 $
* $Date: 2001/10/25 16:37:38 $
*
* ====================================================================
*
* The Apache Software License, Version 1.1
*
* Copyright (c) 2001 The Apache Software Foundation. All rights
* reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
* are met:
*
* 1. Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer.
*
* 2. Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in
* the documentation and/or other materials provided with the
* distribution.
*
* 3. The end-user documentation included with the redistribution, if
* any, must include the following acknowlegement:
* "This product includes software developed by the
* Apache Software Foundation (http://www.apache.org/)."
* Alternately, this acknowlegement may appear in the software itself,
* if and wherever such third-party acknowlegements normally appear.
*
* 4. The names "The Jakarta Project", "Struts", and "Apache Software
* Foundation" must not be used to endorse or promote products derived
* from this software without prior written permission. For written
* permission, please contact apache@apache.org.
*
* 5. Products derived from this software may not be called "Apache"
* nor may "Apache" appear in their names without prior written
* permission of the Apache Group.
*
* THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED
* WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
* OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
* DISCLAIMED. IN NO EVENT SHALL THE APACHE SOFTWARE FOUNDATION OR
* ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
* LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF
* USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
* ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
* OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT
* OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
* SUCH DAMAGE.
* ====================================================================
*
* This software consists of voluntary contributions made by many
* individuals on behalf of the Apache Software Foundation. For more
* information on the Apache Software Foundation, please see
* <http://www.apache.org/>.
*
*/
package org.apache.webapp.admin;
import java.util.Locale;
import javax.servlet.http.HttpSession;
import javax.servlet.http.HttpSessionBindingEvent;
import javax.servlet.http.HttpSessionBindingListener;
import org.apache.struts.action.Action;
import org.apache.struts.action.ActionForm;
/**
* Form bean for the set locale page. The actual value is copied when this
* bean is added as a session attribute.
*
* @author Craig R. McClanahan
* @version $Revision: 1.1 $ $Date: 2001/10/25 16:37:38 $
*/
public final class SetLocaleForm
extends ActionForm
implements HttpSessionBindingListener {
// ------------------------------------------------------------- Properties
/**
* The name of the locale we are currently running.
*/
String locale = null;
public String getLocale() {
return (this.locale);
}
public void setLocale(String locale) {
this.locale = locale;
}
// ------------------------------------- HttpSessionBindingListener Methods
/**
* When this form bean is bound into the session, pick up the user's
* current Locale object and set the current value.
*/
public void valueBound(HttpSessionBindingEvent event) {
HttpSession session = event.getSession();
Locale current = (Locale) session.getAttribute(Action.LOCALE_KEY);
if (current != null)
locale = current.toString();
}
/**
* No action is required when this object is unbound.
*/
public void valueUnbound(HttpSessionBindingEvent event) {
locale = null;
}
}