State management
As told on the core feature list at the beginning, it is possible to maintain the dynaWidget grid´s state over multiple requests.
What makes the dynaWidget grid´s state?
The grid´s state is made up of the properties from all widgets in the grid. If you had a look in the
examples section
you´re already familiar with some default widget properties, e.g.
title, position, commandEdit, ...
When does the state change?
On the first load of a dynaWidget grid the so called
initialState is taken as the grid state. Afterwards each dynamic modification of the grid (move widget, collapse/expand widget, add/remove widget, change a widget´s property, ...)
will update the grid´s state depending on the state management strategy.
State management strategies
There are four options for managing the grid´s state:
- Do not maintain the state (initial state will be restored on
each request - this is default)
- Maintain the state in a client side cookie (cookie state will be
restored on each request)
- Maintain the state on the server side (state will be restored
from server session on each request)
- Implement your own state management (state might be restored
from a database, etc.)
The State state management strategy to be used can be configured on the dynaWidget grid component:
<dwComp:dynaWidgetGrid id="myFirstGrid" columns="2"
defaultStateStore="server|cookie"
stateStore="#{myOwnStateStoreImplementationBean}"
templateBaseUrl="widgetContent" width="500"
initialState="{...}" />
What´s important here:
- the attribute defaultStateStore can be used to define one of the default options server, cookie . Without the attribute state keeping is disabled.
- instead, the attribute stateStore can be used to define a custom state store implementation, see above.
Implement you own state store
You can implement your own state store by implementing the
WidgetStateStore interface.
For using your implementation just set it to the
stateStore attribute of the dynaWidget grid.