we are implementing an application/module that heavily relies on component binding. The main part of the views are generated dynamic at runtime and added to an HtmlPanelGroup that is binded to a managed bean through the "binding" attribute.
Because we don't want to rebuild the dynamic part on every request we made the bean that is responsable for building the dynamic part (and also contains the binded PanelGroup) SessionScoped.
At the first look this works fine ... But we have situations where the dynamic part change (add/remove components for example).
If the dynamic part has changed we do something like this:
private HtmlPanelGroup binding;
public void addComponent()
UIComponent modifiedContent = rebuildContent();
binding.getChildren().add( modifiedContent );
This works also fine on the first look, but on the next request we get an "Duplicate-Key Exception".
We have inspected that a bit deeper. It looks that JSF add the old (in the last request removed childs) in Phase1 (RESTORE_VIEW) again as childs.
Now the binded component (binding) contains duplicate childs (the new (added in the action in the last request) + the old (removed in the last request, but again added in the RESTORE_VIEW)) and the Exception is thrown.
The Ice Faces docs recommends to use Session-/WindowScope because of a Bug in Mojarra (ViewScope). But if i search through the forum i often read "Don't use binding and SessionScope" together.
It is legal to use SessionScope and Binding together?
I added a simple example project (mvn) where the behaviour can be reproduced.
We are using icefaces-2.0.1 on Glassfish 3.1 (mojarra-2.1.0-b11)
P.S. We have tried to use UIComponent.findComponent() instead of using a binding, but this leads to poor performance compared to the session scoped binding approach.