Uploaded image for project: 'PUBLIC - Liferay Faces'
  1. PUBLIC - Liferay Faces
  2. FACES-3234

Replace FacesRequestContext with FacesContextHelperMethods storing scripts in a FacesContext attribute



      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) {
          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.




            • Assignee:
              kyle.stiemann Kyle Stiemann
              kyle.stiemann Kyle Stiemann
              Participants of an Issue:
            • Votes:
              0 Vote for this issue
              0 Start watching this issue


              • Created: