Reputation: 1082
I've been working with this dynamic list component:
How to implement a dynamic list with a JSF 2.0 Composite Component?
One of the things I'd like to do is cache the original value of "list" so that, when a user adds or removes something from this list...I know which ones were added/removed so that I can do something different with them. For example, a "removed" item would simply have a strikethrough instead. Or, an "added" item would have a different background to show that it was recently added.
The only way I seem to have this working right now is for the component itself to take in 3 different lists
<mycomp:dynamicList list="#{bean.list}" addList="#{bean.addList}"
deleteList="#{bean.deleteList}"/>
This seems overly burdensome. Only the web page/component needs to know about the differences in these three lists...once the form is actually submitted, the backing bean only needs to know the new value of "list". So, ideally, I'd just like to use:
<mycomp:dynamicList list="#{bean.list}"/>
Upvotes: 2
Views: 367
Reputation: 1108632
Make use of the JSF view state as available by inherited getStateHelper()
method. This basically acts like the JSF view scope.
Make sure that you don't store/copy/duplicate whole model (the list) in the JSF view state, but only the indexes of added/removed items.
Upvotes: 2