Manipulating the view state via JavaScript can be quite overwhelming. The following table illustrates the differences between various scenarios.
The table below assumes that some view state has been set via JavaScript after a page load to a view state field.
Persisted on browser refresh (F5)
No
Yes
Yes
Persisted on WEM application event
Yes
Yes
Yes
Removed when the widget is unloaded
Yes
Depends
Depends
Removed when the browser tab is closed
Yes
Yes
No
Removed when the browser is closed
Yes
Yes
No
Removed when your computer is hit by a meteor
Yes
Yes
Yes
In the case of a widget being unloaded, there are two scenarios where the outcome depends on specific conditions. As discussed in the previous chapter, we have the option to manually clear the state of localStorage
and sessionStorage
in the unloadscript
block.