Package org.apache.myfaces.view.facelets
Class PartialStateManagementStrategy
- java.lang.Object
- 
- jakarta.faces.view.StateManagementStrategy
- 
- org.apache.myfaces.view.facelets.PartialStateManagementStrategy
 
 
- 
 public class PartialStateManagementStrategy extends StateManagementStrategy This class implements partial state saving feature when facelets is used to render pages. (Theorically it could be applied on jsp case too, but all considerations below should be true before apply it). The following considerations apply for this class: 1. This StateManagementStrategy should only be active if jakarta.faces.PARTIAL_STATE_SAVING config param is active(true). See javadoc on StateManager for details. 2. A map using component clientId as keys are used to hold the state. 3. Each component has a valid id after ViewDeclarationLanguage.buildView(). This implies that somewhere, every TagHandler that create an UIComponent instance should call setId and assign it. 4. Every TagHandler that create an UIComponent instance should call markInitialState after the component is populated. Otherwise, full state is always saved. 5. A SystemEventListener is used to keep track for added and removed components, listen PostAddToViewEvent and PreRemoveFromViewEvent event triggered by UIComponent.setParent() method. 6. It is not possible to use jakarta.faces.component.visit API to traverse the component tree during save/restore, because UIData.visitTree traverse all rows and we only need to restore state per component (not per row). 7. It is necessary to preserve the order of the children added/removed between requests. 8. Added and removed components could be seen as subtrees. This imply that we need to save the structure of the added components subtree and remove one component could be remove all its children and facets from view inclusive. 9. It is necessary to save and restore the list of added/removed components between several requests. 10.All components ids removed in any moment of time must be preserved. 11.Each component must be restored only once. 11.The order is important for ids added when it is traversed the tree, otherwise the algorithm could change the order in which components will be restored.- Since:
- 2.0
- Version:
- $Revision$ $Date$
- Author:
- Leonardo Uribe (latest modification by $Author$)
 
- 
- 
Nested Class SummaryNested Classes Modifier and Type Class Description static classPartialStateManagementStrategy.AddComponentCallbackstatic classPartialStateManagementStrategy.PostAddPreRemoveFromViewListenerstatic classPartialStateManagementStrategy.RemoveComponentCallbackstatic classPartialStateManagementStrategy.TreeStructComponent
 - 
Field SummaryFields Modifier and Type Field Description static StringCLIENTIDS_ADDEDstatic StringCLIENTIDS_REMOVEDstatic StringCOMPONENT_ADDED_AFTER_BUILD_VIEWKey used on component attribute map to indicate if a component was added after build view, so itself and all descendants should not use partial state saving.
 - 
Constructor SummaryConstructors Constructor Description PartialStateManagementStrategy()PartialStateManagementStrategy(FacesContext context)
 - 
Method SummaryAll Methods Instance Methods Concrete Methods Modifier and Type Method Description protected voidensureClearInitialState(UIComponent c)protected RenderKitFactorygetRenderKitFactory()protected VisitContextFactorygetVisitContextFactory()voidhandleDynamicAddedRemovedComponents(FacesContext context, UIViewRoot view, Map<String,Object> states)UIViewRootrestoreView(FacesContext context, String viewId, String renderKitId)ObjectsaveView(FacesContext context)voidsuscribeListeners(UIViewRoot uiViewRoot)
 
- 
- 
- 
Field Detail- 
CLIENTIDS_ADDEDpublic static final String CLIENTIDS_ADDED - See Also:
- Constant Field Values
 
 - 
CLIENTIDS_REMOVEDpublic static final String CLIENTIDS_REMOVED - See Also:
- Constant Field Values
 
 - 
COMPONENT_ADDED_AFTER_BUILD_VIEWpublic static final String COMPONENT_ADDED_AFTER_BUILD_VIEW Key used on component attribute map to indicate if a component was added after build view, so itself and all descendants should not use partial state saving. There are two possible values: Key not present: The component uses pss. ComponentState.ADD: The component was added to the view after build view. ComponentState.REMOVE_ADD: The component was removed/added to the view. Itself and all descendants should be saved and restored, but we have to unregister/register from CLIENTIDS_ADDED and CLIENTIDS_REMOVED lists. See ComponentSupport.markComponentToRestoreFully for details. ComponentState.ADDED: The component has been added or removed/added, but it has been already processed.- See Also:
- Constant Field Values
 
 
- 
 - 
Constructor Detail- 
PartialStateManagementStrategypublic PartialStateManagementStrategy() 
 - 
PartialStateManagementStrategypublic PartialStateManagementStrategy(FacesContext context) 
 
- 
 - 
Method Detail- 
restoreViewpublic UIViewRoot restoreView(FacesContext context, String viewId, String renderKitId) - Specified by:
- restoreViewin class- StateManagementStrategy
 
 - 
handleDynamicAddedRemovedComponentspublic void handleDynamicAddedRemovedComponents(FacesContext context, UIViewRoot view, Map<String,Object> states) 
 - 
saveViewpublic Object saveView(FacesContext context) - Specified by:
- saveViewin class- StateManagementStrategy
 
 - 
ensureClearInitialStateprotected void ensureClearInitialState(UIComponent c) 
 - 
suscribeListenerspublic void suscribeListeners(UIViewRoot uiViewRoot) 
 - 
getRenderKitFactoryprotected RenderKitFactory getRenderKitFactory() 
 - 
getVisitContextFactoryprotected VisitContextFactory getVisitContextFactory() 
 
- 
 
-