01: // Copyright 2006, 2007 The Apache Software Foundation
02: //
03: // Licensed under the Apache License, Version 2.0 (the "License");
04: // you may not use this file except in compliance with the License.
05: // You may obtain a copy of the License at
06: //
07: // http://www.apache.org/licenses/LICENSE-2.0
08: //
09: // Unless required by applicable law or agreed to in writing, software
10: // distributed under the License is distributed on an "AS IS" BASIS,
11: // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12: // See the License for the specific language governing permissions and
13: // limitations under the License.
14:
15: package org.apache.tapestry.integration.app1.pages;
16:
17: import java.util.Locale;
18:
19: import org.apache.tapestry.annotations.Inject;
20: import org.apache.tapestry.annotations.Service;
21: import org.apache.tapestry.ioc.Messages;
22: import org.apache.tapestry.ioc.services.ClassFactory;
23: import org.apache.tapestry.services.PersistentLocale;
24: import org.apache.tapestry.services.Request;
25:
26: public class Localization {
27: @Inject
28: private Messages _messages;
29:
30: @Inject
31: @Service("ClassFactory")
32: private ClassFactory _iocClassFactory;
33:
34: @Inject
35: @Service("ComponentClassFactory")
36: private ClassFactory _componentClassFactory;
37:
38: @Inject
39: private Locale _locale;
40:
41: @Inject
42: private Request _request;
43:
44: @Inject
45: private PersistentLocale _persistentLocale;
46:
47: public Locale getLocale() {
48: return _locale;
49: }
50:
51: public Request getRequest() {
52: return _request;
53: }
54:
55: public String getInjectedMessage() {
56: return _messages.get("via-inject");
57: }
58:
59: public ClassFactory getComponentClassFactory() {
60: return _componentClassFactory;
61: }
62:
63: public ClassFactory getIocClassFactory() {
64: return _iocClassFactory;
65: }
66:
67: public void onActionFromFrench() {
68: _persistentLocale.set(Locale.FRENCH);
69: }
70:
71: public void onActionFromEnglish() {
72: _persistentLocale.set(Locale.ENGLISH);
73: }
74:
75: }
|