- java.lang.Object
-
- javax.faces.view.StateManagementStrategy
-
public abstract class StateManagementStrategy extends Object
Encapsulate the saving and restoring of the view to enable the VDL to take over the responsibility for handling this feature. Because
ViewDeclarationLanguage.getStateManagementStrategy(javax.faces.context.FacesContext, java.lang.String)
is required to returnnull
for JSP views and non-null
for views authored in Facelets for JSF 2, this specification only applys to Facelets for JSF 2.Implementations must call
UIComponent.visitTree(javax.faces.component.visit.VisitContext, javax.faces.component.visit.VisitCallback)
on theUIViewRoot
to perform the saving and restoring of the view in thesaveView(javax.faces.context.FacesContext)
andrestoreView(javax.faces.context.FacesContext, java.lang.String, java.lang.String)
methods, respectively.- Since:
- 2.0
-
-
Constructor Summary
Constructors Constructor and Description StateManagementStrategy()
-
Method Summary
All Methods Instance Methods Abstract Methods Modifier and Type Method and Description abstract UIViewRoot
restoreView(FacesContext context, String viewId, String renderKitId)
Restore the state of the view with information in the request.
abstract Object
saveView(FacesContext context)
Return the state of the current view in an
Object
that implementsSerializable
and can be passed tojava.io.ObjectOutputStream.writeObject()
without causing ajava.io.NotSerializableException
to be thrown. The default implementation must perform the following algorithm or its semantic equivalent, explicitly performing all the steps listed here.
-
-
-
Method Detail
-
saveView
public abstract Object saveView(FacesContext context)
Return the state of the current view in an
Object
that implementsSerializable
and can be passed tojava.io.ObjectOutputStream.writeObject()
without causing ajava.io.NotSerializableException
to be thrown. The default implementation must perform the following algorithm or its semantic equivalent, explicitly performing all the steps listed here.If the
UIViewRoot
of the current view is markedtransient
, returnnull
immediately.Traverse the view and verify that each of the client ids are unique. Throw
IllegalStateException
if more than one client id are the same.Visit the tree using
UIComponent.visitTree(javax.faces.component.visit.VisitContext, javax.faces.component.visit.VisitCallback)
. For each node, callStateHolder.saveState(javax.faces.context.FacesContext)
, saving the returnedObject
in a way such that it can be restored given only its client id. Special care must be taken to handle the case of components that were added or deleted programmatically during this lifecycle traversal, rather than by the VDL.
The implementation must ensure that the
StateHolder.saveState(javax.faces.context.FacesContext)
method is called for each node in the tree.The data structure used to save the state obtained by executing the above algorithm must be
Serializable
, and all of the elements within the data structure must also beSerializable
.- Parameters:
context
- theFacesContext
for this request.- Since:
- 2.0
-
restoreView
public abstract UIViewRoot restoreView(FacesContext context, String viewId, String renderKitId)
Restore the state of the view with information in the request. The default implementation must perform the following algorithm or its semantic equivalent.
-
As in the case of restore view on an initial request, the view metadata must be restored and properly handled as well. Obtain the
ViewMetadata
for the currentviewId
, and from that callViewMetadata.createMetadataView(javax.faces.context.FacesContext)
. Store the resultantUIViewRoot
in theFacesContext
. Obtain the state of theUIViewRoot
from the stateObject
returned fromResponseStateManager.getState(javax.faces.context.FacesContext, java.lang.String)
and pass that toUIViewRoot.restoreViewScopeState(javax.faces.context.FacesContext, java.lang.Object)
.Build the view from the markup. For all components in the view that do not have an explicitly assigned id in the markup, the values of those ids must be the same as on an initial request for this view. This view will not contain any components programmatically added during the previous lifecycle run, and it will contain components that were programmatically deleted on the previous lifecycle run. Both of these cases must be handled.
Call
ResponseStateManager.getState(javax.faces.context.FacesContext, java.lang.String)
to obtain the data structure returned from the previous call tosaveView(javax.faces.context.FacesContext)
.Visit the tree using
UIComponent.visitTree(javax.faces.component.visit.VisitContext, javax.faces.component.visit.VisitCallback)
. For each node, callStateHolder.restoreState(javax.faces.context.FacesContext, java.lang.Object)
, passing the state saved corresponding to the current client id.Ensure that any programmatically deleted components are removed.
Ensure any programmatically added components are added.
The implementation must ensure that the
StateHolder.restoreState(javax.faces.context.FacesContext, java.lang.Object)
method is called for each node in the tree, except for those that were programmatically deleted on the previous run through the lifecycle.- Parameters:
context
- theFacesContext
for this requestviewId
- the view identifier for which the state should be restoredrenderKitId
- the render kit id for this state.- Since:
- 2.0
-
-
-
Nederlandse vertaling
U hebt gevraagd om deze site in het Nederlands te bezoeken. Voor nu wordt alleen de interface vertaald, maar nog niet alle inhoud.Als je me wilt helpen met vertalingen, is je bijdrage welkom. Het enige dat u hoeft te doen, is u op de site registreren en mij een bericht sturen waarin u wordt gevraagd om u toe te voegen aan de groep vertalers, zodat u de gewenste pagina's kunt vertalen. Een link onderaan elke vertaalde pagina geeft aan dat u de vertaler bent en heeft een link naar uw profiel.
Bij voorbaat dank.
Document heeft de 11/06/2005 gemaakt, de laatste keer de 18/08/2025 gewijzigd
Bron van het afgedrukte document:https://www.gaudry.be/nl/java-api-javaee-rf-javax/faces/view/statemanagementstrategy.html
De infobrol is een persoonlijke site waarvan de inhoud uitsluitend mijn verantwoordelijkheid is. De tekst is beschikbaar onder CreativeCommons-licentie (BY-NC-SA). Meer info op de gebruiksvoorwaarden en de auteur.
Referenties
Deze verwijzingen en links verwijzen naar documenten die geraadpleegd zijn tijdens het schrijven van deze pagina, of die aanvullende informatie kunnen geven, maar de auteurs van deze bronnen kunnen niet verantwoordelijk worden gehouden voor de inhoud van deze pagina.
De auteur van deze site is als enige verantwoordelijk voor de manier waarop de verschillende concepten, en de vrijheden die met de referentiewerken worden genomen, hier worden gepresenteerd. Vergeet niet dat u meerdere broninformatie moet doorgeven om het risico op fouten te verkleinen.