1 23 package com.sun.enterprise.tools.jsfext.resource; 24 25 import com.sun.enterprise.tools.jsfext.layout.descriptor.Resource; 26 import com.sun.enterprise.tools.jsfext.util.Util; 27 28 import java.util.Locale ; 29 import java.util.Map ; 30 31 import javax.faces.component.UIViewRoot; 32 import javax.faces.context.FacesContext; 33 34 35 48 public class ResourceBundleFactory implements ResourceFactory { 49 50 64 public Object getResource(FacesContext context, Resource descriptor) { 65 String id = descriptor.getId(); 68 Map map = context.getExternalContext().getRequestMap(); 69 if (map.containsKey(id)) { 70 return map.get(id); 72 } 73 74 Object resource = ResourceBundleManager.getInstance().getBundle( 76 descriptor.getExtraInfo(), getLocale(context)); 77 78 map.put(id, resource); 80 81 return resource; 82 } 83 84 87 public static Locale getLocale(FacesContext context) { 88 Locale locale = null; 89 if (context != null) { 90 UIViewRoot root = context.getViewRoot(); 92 if (root != null) { 93 locale = root.getLocale(); 94 } 95 } 96 97 return (locale == null) ? Locale.getDefault() : locale; 99 } 100 } 101 | Popular Tags |