|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Object org.apache.shale.util.LoadBundle
public class LoadBundle
Utility class emulating the behavior of the standard JSF Core Library
tag <f:loadBundle>
. This class is designed to be used
as a managed bean, and exposes a map
property containing the
messages in the resoruce bundle specified by the basename
property, localized for the Locale
specified on the current
request.
A typical use of this class would be to declare a managed bean like this:
<managed-bean> <managed-bean-name>bundle</managed-bean-name> <managed-bean-class> org.apache.shale.util.LoadBundle </managed-bean-class> <managed-bean-scope>request</managed-bean-scope> <managed-property> <property-name>basename</property-name> <value>com.mycompany.mypackage.Bundle</value> </managed-property> </managed-bean>
This will result in creation of a request scope object whose map
property will return a Map
representing the localized messages for
the com.mycompany.mypackage.Bundle
resource bundle. You can look
up localized messages in this Map
by evaluating a value binding
expression like this:
#{messages.['message.key']}
where message.key
is the key for which to retrieve a
localized message.
(Since 1.0.1) IMPLEMENTATION NOTE - For backwards compatibility in applications that utilized the 1.0.0 version of this class, the following sort of expression resolves to the same value:
#{messages.map['message.key']}
Constructor Summary | |
---|---|
LoadBundle()
Creates a new instance of LoadBundle. |
|
LoadBundle(String basename)
Creates a new instance of LoadBundle for the specified bundle. |
Method Summary | |
---|---|
String |
getBasename()
Return the base resource bundle name for this LoadBundle
instance. |
Map |
getMap()
Return a Map whose keys and values represent the content
of the application resource bundle specified by the basename
property, localized for the Locale stored in the
UIViewRoot for the current request. |
void |
setBasename(String basename)
Set the base resource bundle name for this LoadBundle
instance. |
Methods inherited from class java.lang.Object |
---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Constructor Detail |
---|
public LoadBundle()
public LoadBundle(String basename)
Creates a new instance of LoadBundle for the specified bundle.
basename
- Base resource bundle name for this LoadBundle
Method Detail |
---|
public String getBasename()
Return the base resource bundle name for this LoadBundle
instance.
public void setBasename(String basename)
Set the base resource bundle name for this LoadBundle
instance.
basename
- The new base resource bundle namepublic Map getMap() throws IllegalStateException
Return a Map
whose keys and values represent the content
of the application resource bundle specified by the basename
property, localized for the Locale
stored in the
UIViewRoot
for the current request.
IllegalStateException
- if we are not inside a Faces request,
or if there is not a current view root with a valid locale
|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |