org.apache.myfaces.view.facelets
Class DefaultFaceletsStateManagementStrategy

java.lang.Object
  extended by javax.faces.view.StateManagementStrategy
      extended by org.apache.myfaces.view.facelets.DefaultFaceletsStateManagementStrategy

public class DefaultFaceletsStateManagementStrategy
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 javax.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 javax.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.

Since:
2.0
Version:
$Revision: 793245 $ $Date: 2009-07-11 18:50:53 -0500 (Sat, 11 Jul 2009) $
Author:
Leonardo Uribe (latest modification by $Author: lu4242 $)

Nested Class Summary
static class DefaultFaceletsStateManagementStrategy.PostAddPreRemoveFromViewListener
           
static class DefaultFaceletsStateManagementStrategy.TreeStructComponent
           
 
Constructor Summary
DefaultFaceletsStateManagementStrategy(ViewDeclarationLanguage vdl)
           
 
Method Summary
 UIViewRoot restoreView(FacesContext context, java.lang.String viewId, java.lang.String renderKitId)
           
 java.lang.Object saveView(FacesContext context)
           
 void suscribeListeners(UIViewRoot uiViewRoot)
           
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

DefaultFaceletsStateManagementStrategy

public DefaultFaceletsStateManagementStrategy(ViewDeclarationLanguage vdl)
Method Detail

restoreView

public UIViewRoot restoreView(FacesContext context,
                              java.lang.String viewId,
                              java.lang.String renderKitId)
Specified by:
restoreView in class StateManagementStrategy

saveView

public java.lang.Object saveView(FacesContext context)
Specified by:
saveView in class StateManagementStrategy

suscribeListeners

public void suscribeListeners(UIViewRoot uiViewRoot)


Copyright © 2009 The Apache Software Foundation. All Rights Reserved.