org.apache.myfaces.view.facelets
Class DefaultFaceletsStateManagementStrategy
java.lang.Object
javax.faces.view.StateManagementStrategy
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.
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: 1570404 $ $Date: 2014-02-20 19:41:33 -0500 (Thu, 20 Feb 2014) $
- Author:
- Leonardo Uribe (latest modification by $Author: lu4242 $)
Methods inherited from class java.lang.Object |
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
CLIENTIDS_ADDED
public static final String CLIENTIDS_ADDED
- See Also:
- Constant Field Values
CLIENTIDS_REMOVED
public static final String CLIENTIDS_REMOVED
- See Also:
- Constant Field Values
COMPONENT_ADDED_AFTER_BUILD_VIEW
public 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
SAVE_STATE_WITH_VISIT_TREE_ON_PSS
@Deprecated
@JSFWebConfigParam(since="2.0.8, 2.1.2",
defaultValue="true",
expectedValues="true, false",
group="state",
tags="performance",
deprecated=true)
public static final String SAVE_STATE_WITH_VISIT_TREE_ON_PSS
- Deprecated. JSF 2.2 change enforces tree visiting as the preferred way. Performance tests shows that plain
visit is faster but the difference is negligible.
- If this param is set to true (by default), when pss algorithm is executed to save state, a visit tree
traversal is done, instead a plain traversal like previous versions (2.0.7/2.1.1 and earlier) of MyFaces Core.
This param is just provided to preserve backwards behavior.
- See Also:
- Constant Field Values
CHECK_ID_PRODUCTION_MODE
@JSFWebConfigParam(since="2.0.12, 2.1.6",
defaultValue="auto",
expectedValues="true, auto, false",
group="state",
tags="performance")
public static final String CHECK_ID_PRODUCTION_MODE
- Define how duplicate ids are checked when ProjectStage is Production, by default (auto) it only check ids of
components that does not encapsulate markup (like facelets UILeaf).
- true: check all ids, including ids for components that are transient and encapsulate markup.
- auto: (default) check ids of components that does not encapsulate markup (like facelets UILeaf).
Note ids of UILeaf instances are generated by facelets vdl, start with "j_id", are never rendered
into the response and UILeaf instances are never used as a target for listeners, so in practice
there is no need to check such ids. This reduce the overhead associated with generate client ids.
- false: do not do any check when ProjectStage is Production
According to specification, identifiers must be unique within the scope of the nearest ancestor to
the component that is a naming container.
- See Also:
- Constant Field Values
DefaultFaceletsStateManagementStrategy
public DefaultFaceletsStateManagementStrategy()
DefaultFaceletsStateManagementStrategy
public DefaultFaceletsStateManagementStrategy(FacesContext context)
restoreView
public UIViewRoot restoreView(FacesContext context,
String viewId,
String renderKitId)
- Specified by:
restoreView
in class StateManagementStrategy
handleDynamicAddedRemovedComponents
public void handleDynamicAddedRemovedComponents(FacesContext context,
UIViewRoot view,
Map<String,Object> states)
saveView
public Object saveView(FacesContext context)
- Specified by:
saveView
in class StateManagementStrategy
ensureClearInitialState
protected void ensureClearInitialState(UIComponent c)
suscribeListeners
public void suscribeListeners(UIViewRoot uiViewRoot)
getRenderKitFactory
protected RenderKitFactory getRenderKitFactory()
getVisitContextFactory
protected VisitContextFactory getVisitContextFactory()
getCheckIdProductionMode
protected String getCheckIdProductionMode(FacesContext facesContext)
Copyright © 2014 The Apache Software Foundation. All rights reserved.