-
Type:
New Feature
-
Status: Closed
-
Priority:
Critical
-
Resolution: Fixed
-
Affects Version/s: None
-
Fix Version/s: util-3.2.0, portal-3.0.4, showcase-3.0.4
-
Component/s: JSF Showcase, Liferay Faces Portal / Demos / Tests, Liferay Faces Util
-
Labels:None
This task involves adding the following methods to FacesContextHelper (and corresponding static methods to FacesContextHelperUtil):
public void addScript(Script script) { FacesContext facesContext = FacesContext.getCurrentInstance(); addScript(facesContext, script); } public void addScript(String script) { FacesContext facesContext = FacesContext.getCurrentInstance(); addScript(facesContext, script); } public void addScript(FacesContext facesContext, Script script) { getMutableScripts(facesContext).add(script); } public void addScript(FacesContext facesContext, String script) { ExternalContext externalContext = facesContext.getExternalContext(); Script scriptInstance = ScriptFactory.getScriptInstance(externalContext, script); addScript(facesContext, scriptInstance); } public List<Script> getScripts() { FacesContext facesContext = FacesContext.getCurrentInstance(); return getScripts(facesContext); } public static List<Script> getScripts(FacesContext facesContext) { return Collections.unmodifiableList(getModifiableScripts(facesContext)); } private static List<Script> getModifiableScripts(FacesContext facesContext) { Map<Object, Object> attributes = facesContext.getAttributes(); List<Script> scripts = (List<Script>) attributes.get(ScriptUtil.class.getClass()); if (scripts == null) { scripts = new ArrayList<Script>(); attributes.put(ScriptUtil.class.getClass(), scripts); } return scripts; }
These methods will replace the FacesRequestContext class which can be removed in Util 4.0.0. In all other branches FacesRequestContext should be deprecated and call through to this static utility.
The benefit of removing FacesRequestContext is that Util's FacesContextFactoryUtilImpl and all FacesRequestContext code can be removed. Also, there will be one less ThreadLocal singleton during each request because FacesRequestContext won't exist.
- is a dependency of
-
FACES-3278 Remove FacesRequestContext where possible
-
- Open
-
-
FACES-3424 Replace deprecated FacesRequestContext with FacesContextHelper methods storing scripts in a FacesContext attribute
-
- Open
-