public class EnableRestorableView extends TagHandler
The <o:enableRestorableView>
taghandler instructs the view handler to recreate the entire view
whenever the view has been expired, i.e. whenever ViewHandler.restoreView(FacesContext, String)
returns
null
and the current request is a postback. This effectively prevents ViewExpiredException
on
the view. This tag needs to be placed in <f:metadata>
of the view.
There are however technical design limitations: the recreated view is exactly the same as during the initial
request. In other words, the view has lost its state. Any modifications which were made after the original initial
request, either by taghandlers or (ajax) conditionally rendered components based on some view or even session
scoped variables, are completely lost. Thus, the view should be designed that way that it can be used with a request
scoped bean. You can use it with a view scoped bean, but then you should add a @PostConstruct
which checks if the request is a postback and then fill the missing bean properties based on request parameters.
To enable the restorable view, just add the <enableRestorableView>
to the view metadata.
<f:metadata> <o:enableRestorableView/> </f:metadata>
Since Mojarra 2.1.19, about 2 months after OmniFaces introduced the <o:enableRestorableView>
,
it's possible to enable a stateless mode on the view by simply setting its transient
attribute to
true
:
<f:view transient="true"> ... </f:view>
This goes actually a step further than <o:enableRestorableView>
as no state would be saved at all.
However, on those kind of pages where <o:enableRestorableView>
would work just fine, this
statelessness should not form any problem at all. So, if you have at least Mojarra 2.1.19 at hands, use the
transient="true"
instead.
RestorableViewHandler
nextHandler, tag, tagId
Constructor and Description |
---|
EnableRestorableView(TagConfig config)
The tag constructor.
|
Modifier and Type | Method and Description |
---|---|
void |
apply(FaceletContext context,
UIComponent parent)
Enable the current view to be restorable.
|
getAttribute, getRequiredAttribute, toString
public EnableRestorableView(TagConfig config)
config
- The tag config.public void apply(FaceletContext context, UIComponent parent) throws IOException
RestorableViewHandler
could intercept on.IllegalArgumentException
- When given parent is not an instance of UIViewRoot
.IOException
Copyright © 2012–2014 OmniFaces. All rights reserved.