There are frequent changes to attributes of components due to end user interaction. For example the 'displayIndex' value of a custom 'column' component changes whenever user reorders the column in a table. SessionChangeManager records such changes on certain attributes of certain components and restores it as 'preference' / 'personalization' for that user for future 'GET' requests on the page. While this is generally desirable, it sometimes could interfere with expectations of other components. For example a custom 'query' component may choose to allow users to save keyed by a 'name' the 'search criteria', and then additionally the 'layout' of the results area, which most likely is a table. The changes on the table (or any other component on results area) that the SessionChangeManager frequently saves and restores interferes with the component's feature to save and restore the layout of the results area / table. We need some ChangeManager API to reduce this interference.
This proposal is to add APIs to ChangeManager that components can call to:
1. Remove the ChangeManager changes for the result area subtree when it switches to a saved search that includes layout.
2. Add back the ChangeManager changes for the result area subtree when user switches to a saved search that does not include a layout.
Specifically proposing the following new APIs (two public methods) on ChangeManager class:
- Removes all changes that the ChangeManager holds for components in a subtree.
- Note that the ChangeManager would still continue to record any new changes on the
- components in the subtree.
- @param subTreeRoot The UIComponent that is the root of the component subtree for which the
- changes are to be removed. Note that if the viewroot is suplied, the
- changes for the entire view are removed.
- @return Object a Serializable Object of all the component changes for the subtree that was
- just removed. This value can be passed back to
- restoreComponentChangesForSubtree() to restore the changes.
public Object removeComponentChangesForSubtree(FacesContext context, UIComponent subTreeRoot)
- Restores the component changes to the ChangeManager for components in a subtree.
- Before adding the changes, if there are existing changes to the subtree it will be removed.
- @param changes The Serializable Object of the component changes as returned by
public void restoreComponentChangesForSubtree(FacesContext context, Object changes)
These methods will be implemented in SessionChangeManager, and will be a no-op in the document based ChangeManager implementations.