Class ViewPoolProcessor


  • public class ViewPoolProcessor
    extends Object
    This class is reponsible for all processing tasks related to the view pool. For enable the pool only for a subset of your views, you can add an entry inside faces-config.xml file like this:
     
     <faces-config-extension>
       <view-pool-mapping>
          <url-pattern>/*</url-pattern>
          <parameter>
              <name>org.apache.myfaces.VIEW_POOL_MAX_POOL_SIZE</name>
              <value>5</value>
          </parameter>
      </view-pool-mapping>
     </faces-config-extension>
     
     
    Author:
    Leonardo Uribe
    • Field Detail

      • ENABLE_VIEW_POOL

        public static final String ENABLE_VIEW_POOL
        UIViewRoot attribute to enable/disable the view for use pooling.
        See Also:
        Constant Field Values
      • FORCE_HARD_RESET

        public static final String FORCE_HARD_RESET
        Flag that indicates to the StateManagementStrategy that no state needs to be stored and we are using saveState() to dispose the view and store it into the pool directly.
        See Also:
        Constant Field Values
      • DISPOSE_VIEW_NAVIGATION

        public static final String DISPOSE_VIEW_NAVIGATION
        Flag to indicate that dispose this view on navigation is valid.
        See Also:
        Constant Field Values
      • RESET_SAVE_STATE_MODE_KEY

        public static final String RESET_SAVE_STATE_MODE_KEY
        Attribute of UIViewRoot that indicates if a soft (1) or hard(2) (reset and check) reset is required in the call to saveState().
        See Also:
        Constant Field Values
      • RESET_MODE_OFF

        public static final Integer RESET_MODE_OFF
        Indicates no reset should be done on this state saving
      • RESET_MODE_SOFT

        public static final Integer RESET_MODE_SOFT
        Indicates a soft reset should be done when saveState(...) is performed, which means all transient state should be cleared but the delta state should not be destroyed in the process.
      • RESET_MODE_HARD

        public static final Integer RESET_MODE_HARD
        Indicates a hard reset should be done when saveState(...) is performed, which means all transient and delta state should be cleared, destroying all existing state in the process. If something cannot be reseted, the state should return non null, so the algorithm can remove the component from the tree and mark the tree as partial (requires refresh before reuse).
      • INVOKE_DEFERRED_NAVIGATION

        public static final String INVOKE_DEFERRED_NAVIGATION
        Param used to indicate a "deferred navigation" needs to be done. To allow the view pool to dispose the view properly (and reuse it later), it is necessary to ensure the view is not being used at the moment. If the navigation call occur inside an action listener, the current view is being used and cannot be disposed (because it conflicts with hard/soft reset). This extension allows to call handleNavigation() before end invoke application phase, but after traverse the component tree.
        See Also:
        Constant Field Values
    • Constructor Detail

      • ViewPoolProcessor

        public ViewPoolProcessor​(FacesContext context)
    • Method Detail

      • initialize

        public static void initialize​(FacesContext context)
        This method should be called at startup to decide if a view processor should be provided or not to the runtime.
        Parameters:
        context -
      • isViewPoolEnabledForThisView

        public boolean isViewPoolEnabledForThisView​(FacesContext context,
                                                    UIViewRoot root)
      • isViewPoolStrategyAllowedForThisView

        public boolean isViewPoolStrategyAllowedForThisView​(FacesContext context,
                                                            UIViewRoot root)
      • setViewPoolDisabledOnThisView

        public void setViewPoolDisabledOnThisView​(FacesContext context,
                                                  UIViewRoot root,
                                                  boolean value)
      • cloneAndRestoreView

        public void cloneAndRestoreView​(FacesContext context,
                                        UIViewRoot newView,
                                        ViewEntry entry,
                                        ViewStructureMetadata metadata)
        Takes the newView and restore the state taken as base the provided ViewEntry, and then move all child components from oldView to newView, to finally obtain a clean component tree.
        Parameters:
        context -
        newView -
        entry -
      • storeViewStructureMetadata

        public void storeViewStructureMetadata​(FacesContext context,
                                               UIViewRoot root)
      • clearTransientAndNonFaceletComponentsForStaticView

        protected void clearTransientAndNonFaceletComponentsForStaticView​(FacesContext context,
                                                                          UIViewRoot root)
      • processDeferredNavigation

        public void processDeferredNavigation​(FacesContext facesContext)