|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Objectorg.apache.click.util.MessagesMap
public class MessagesMap
Provides a localized read only messages Map for Page and Control classes.
A MessagesMap instance is available in each Velocity page using the name "messages". For example suppose you have a localized page title, which is stored in the Page's properties file. You can access page "title" message in your page template via:
$messages.title
This is roughly equivalent to making the call:
public void onInit() { .. addModel("title", getMessage("title"); }Please note if the specified message does not exist in your Page's properties file, or if the Page does not have a properties file, then a MissingResourceException will be thrown. The ClickServlet adds a MessagesMap instance to the Velocity Context before it is merged with the page template.
Nested Class Summary |
---|
Nested classes/interfaces inherited from interface java.util.Map |
---|
Map.Entry<K,V> |
Field Summary | |
---|---|
protected Class |
baseClass
The base class. |
protected static Object |
CACHE_LOAD_LOCK
The cache key set load lock. |
protected String |
globalBaseName
The class global resource bundle base name. |
protected Locale |
locale
The resource bundle locale. |
protected Map |
messages
The map of localized messages. |
protected static Map |
MESSAGES_CACHE
Cache of messages keyed by bundleName + Locale name. |
protected static Set |
NOT_FOUND_CACHE
Cache of resource bundle and locales which were not found. |
Constructor Summary | |
---|---|
MessagesMap(Class baseClass,
String globalResource)
Create a resource bundle messages Map adaptor for the given object's class resource bundle, the global resource bundle and Context. |
Method Summary | |
---|---|
void |
clear()
This method is not supported and will throw UnsupportedOperationException if invoked. |
boolean |
containsKey(Object key)
|
boolean |
containsValue(Object value)
|
Set |
entrySet()
|
String |
get(Object key)
Return localized resource message for the given key. |
boolean |
isEmpty()
|
Set |
keySet()
|
String |
put(String key,
String value)
This method is not supported and will throw UnsupportedOperationException if invoked. |
void |
putAll(Map map)
This method is not supported and will throw UnsupportedOperationException if invoked. |
String |
remove(Object key)
This method is not supported and will throw UnsupportedOperationException if invoked. |
int |
size()
|
String |
toString()
|
Collection |
values()
|
Methods inherited from class java.lang.Object |
---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait |
Methods inherited from interface java.util.Map |
---|
equals, hashCode |
Field Detail |
---|
protected static final Set NOT_FOUND_CACHE
protected static final Map MESSAGES_CACHE
protected static final Object CACHE_LOAD_LOCK
protected final Class baseClass
protected final String globalBaseName
protected Map messages
protected final Locale locale
Constructor Detail |
---|
public MessagesMap(Class baseClass, String globalResource)
baseClass
- the target classglobalResource
- the global resource bundle nameMethod Detail |
---|
public int size()
size
in interface Map<String,String>
Map.size()
public boolean isEmpty()
isEmpty
in interface Map<String,String>
Map.isEmpty()
public boolean containsKey(Object key)
containsKey
in interface Map<String,String>
Map.containsKey(Object)
public boolean containsValue(Object value)
containsValue
in interface Map<String,String>
Map.containsValue(Object)
public String get(Object key)
get
in interface Map<String,String>
MissingResourceException
- if the given key was not foundMap.get(Object)
public String put(String key, String value)
put
in interface Map<String,String>
Map.put(Object, Object)
public String remove(Object key)
remove
in interface Map<String,String>
Map.remove(Object)
public void putAll(Map map)
putAll
in interface Map<String,String>
Map.putAll(Map)
public void clear()
clear
in interface Map<String,String>
Map.clear()
public Set keySet()
keySet
in interface Map<String,String>
Map.keySet()
public Collection values()
values
in interface Map<String,String>
Map.values()
public Set entrySet()
entrySet
in interface Map<String,String>
Map.entrySet()
public String toString()
toString
in class Object
toString()
|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |