1 /* 2 * Copyright 2001,2004 The Apache Software Foundation. 3 * 4 * Licensed under the Apache License, Version 2.0 (the "License"); 5 * you may not use this file except in compliance with the License. 6 * You may obtain a copy of the License at 7 * 8 * http://www.apache.org/licenses/LICENSE-2.0 9 * 10 * Unless required by applicable law or agreed to in writing, software 11 * distributed under the License is distributed on an "AS IS" BASIS, 12 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 * See the License for the specific language governing permissions and 14 * limitations under the License. 15 */ 16 17 18 package org.apache.webapp.admin; 19 20 21 import java.util.Locale; 22 import javax.servlet.http.HttpSession; 23 import javax.servlet.http.HttpSessionBindingEvent; 24 import javax.servlet.http.HttpSessionBindingListener; 25 import org.apache.struts.Globals; 26 import org.apache.struts.action.ActionForm; 27 28 29 /** 30 * Form bean for the set locale page. The actual value is copied when this 31 * bean is added as a session attribute. 32 * 33 * @author Craig R. McClanahan 34 * @version $Revision: 1.3 $ $Date: 2004/07/10 06:56:14 $ 35 */ 36 37 public final class SetLocaleForm 38 extends ActionForm 39 implements HttpSessionBindingListener { 40 41 42 // ------------------------------------------------------------- Properties 43 44 45 /** 46 * The name of the locale we are currently running. 47 */ 48 String locale = null; 49 50 public String getLocale() { 51 return (this.locale); 52 } 53 54 public void setLocale(String locale) { 55 this.locale = locale; 56 } 57 58 59 // ------------------------------------- HttpSessionBindingListener Methods 60 61 62 /** 63 * When this form bean is bound into the session, pick up the user's 64 * current Locale object and set the current value. 65 */ 66 public void valueBound(HttpSessionBindingEvent event) { 67 68 HttpSession session = event.getSession(); 69 Locale current = (Locale) session.getAttribute(Globals.LOCALE_KEY); 70 if (current != null) 71 locale = current.toString(); 72 73 } 74 75 76 /** 77 * No action is required when this object is unbound. 78 */ 79 public void valueUnbound(HttpSessionBindingEvent event) { 80 81 locale = null; 82 83 } 84 85 86 } 87