KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > apache > webapp > admin > SetLocaleForm


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 JavaDoc;
22 import javax.servlet.http.HttpSession JavaDoc;
23 import javax.servlet.http.HttpSessionBindingEvent JavaDoc;
24 import javax.servlet.http.HttpSessionBindingListener JavaDoc;
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 JavaDoc {
40
41
42     // ------------------------------------------------------------- Properties
43

44
45     /**
46      * The name of the locale we are currently running.
47      */

48     String JavaDoc locale = null;
49
50     public String JavaDoc getLocale() {
51         return (this.locale);
52     }
53
54     public void setLocale(String JavaDoc 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 JavaDoc event) {
67
68         HttpSession JavaDoc session = event.getSession();
69         Locale JavaDoc current = (Locale JavaDoc) 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 JavaDoc event) {
80
81         locale = null;
82
83     }
84
85
86 }
87
Popular Tags