- java.lang.Object
-
- jakarta.faces.view.facelets.TagHandler
-
- org.omnifaces.taghandler.LoadBundle
-
- All Implemented Interfaces:
FaceletHandler
public class LoadBundle extends TagHandler
The
<o:loadBundle>
taghandler basically extends the standard<f:loadBundle>
with a newloader
attribute allowing you to explicitly set the desiredClassLoader
where the resource bundle should be looked up. Also theLocale
of the bundle is obtained with better default values than the default Faces implementation.You can use the
loader
attribute to specify an object whose class loader will be used to load the resource bundle specified in thebasename
attribute. The class loader of the given object is resolved as specified inUtils.getClassLoader(Object)
. In the end this should allow you to use a more specific resource bundle when there are duplicate instances in the runtime classpath, e.g. via multiple (plugin) libraries.The locale of the resource bundle is obtained as specified in
Faces.getLocale()
.Usage
You can use it the same way as
<f:loadBundle>
, you only need to changef:
intoo:
to get the extra support forloader
attribute and the improved locale resolving.- Since:
- 4.3
- Author:
- Bauke Scholtz
-
-
Field Summary
-
Fields inherited from class jakarta.faces.view.facelets.TagHandler
nextHandler, tag, tagId
-
-
Constructor Summary
Constructors Constructor Description LoadBundle(TagConfig config)
The tag constructor.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description void
apply(FaceletContext context, UIComponent parent)
First obtain the resource bundle by its name as specified in thebasename
attribute with the locale which is obtained as specified inFaces.getLocale()
and the class loader which is obtained as specified inUtils.getClassLoader(Object)
with theloader
attribute as argument.-
Methods inherited from class jakarta.faces.view.facelets.TagHandler
getAttribute, getRequiredAttribute, toString
-
-
-
-
Constructor Detail
-
LoadBundle
public LoadBundle(TagConfig config)
The tag constructor.- Parameters:
config
- The tag config.
-
-
Method Detail
-
apply
public void apply(FaceletContext context, UIComponent parent) throws IOException
First obtain the resource bundle by its name as specified in thebasename
attribute with the locale which is obtained as specified inFaces.getLocale()
and the class loader which is obtained as specified inUtils.getClassLoader(Object)
with theloader
attribute as argument. Finally set the resource bundle in the request scope by the name as specified in thevar
attribute.- Throws:
IOException
-
-