use of com.sun.faces.application.ApplicationResourceBundle in project mojarra by eclipse-ee4j.
the class ApplicationConfigProcessor method addResouceBundle.
private void addResouceBundle(ApplicationAssociate associate, Node resourceBundle) {
if (resourceBundle != null) {
NodeList children = resourceBundle.getChildNodes();
if (children != null) {
String baseName = null;
String var = null;
List<Node> descriptions = null;
List<Node> displayNames = null;
for (int i = 0, size = children.getLength(); i < size; i++) {
Node n = children.item(i);
if (n.getNodeType() == Node.ELEMENT_NODE) {
switch(n.getLocalName()) {
case BASE_NAME:
baseName = getNodeText(n);
break;
case VAR:
var = getNodeText(n);
break;
case RES_DESCRIPTIONS:
if (descriptions == null) {
descriptions = new ArrayList<>(2);
}
descriptions.add(n);
break;
case RES_DISPLAY_NAMES:
if (displayNames == null) {
displayNames = new ArrayList<>(2);
}
displayNames.add(n);
break;
}
}
}
if (baseName != null && var != null) {
associate.addResourceBundle(var, new ApplicationResourceBundle(baseName, getTextMap(displayNames), getTextMap(descriptions)));
}
}
}
}
use of com.sun.faces.application.ApplicationResourceBundle in project mojarra by eclipse-ee4j.
the class FacesResourceBundleELResolver method getFeatureDescriptors.
@Override
public Iterator<FeatureDescriptor> getFeatureDescriptors(ELContext context, Object base) {
if (base != null) {
return null;
}
ArrayList<FeatureDescriptor> list = new ArrayList<>();
FacesContext facesContext = (FacesContext) context.getContext(FacesContext.class);
ApplicationAssociate associate = ApplicationAssociate.getCurrentInstance();
Map<String, ApplicationResourceBundle> rbMap = associate.getResourceBundles();
if (rbMap == null) {
return list.iterator();
}
// iterate over the list of managed beans
for (Iterator<Map.Entry<String, ApplicationResourceBundle>> i = rbMap.entrySet().iterator(); i.hasNext(); ) {
Map.Entry<String, ApplicationResourceBundle> entry = i.next();
String var = entry.getKey();
ApplicationResourceBundle bundle = entry.getValue();
if (bundle != null) {
Locale curLocale = Util.getLocaleFromContextOrSystem(facesContext);
String description = bundle.getDescription(curLocale);
String displayName = bundle.getDisplayName(curLocale);
list.add(Util.getFeatureDescriptor(var, displayName, description, false, false, true, ResourceBundle.class, Boolean.TRUE));
}
}
return list.iterator();
}
use of com.sun.faces.application.ApplicationResourceBundle in project ctsms by phoenixctms.
the class WebUtil method clearResourceBundleCache.
public static void clearResourceBundleCache() throws Exception {
getServiceLocator().getToolsService().clearResourceBundleCache();
// https://stackoverflow.com/questions/4325164/how-to-reload-resource-bundle-in-web-application
ResourceBundle.clearCache(Thread.currentThread().getContextClassLoader());
Iterator<ApplicationResourceBundle> it = ApplicationAssociate.getCurrentInstance().getResourceBundles().values().iterator();
while (it.hasNext()) {
ApplicationResourceBundle appBundle = it.next();
Map<Locale, ResourceBundle> resources = CommonUtil.getDeclaredFieldValue(appBundle, "resources");
resources.clear();
}
}
Aggregations