Component binding and SessionScope  XML
Forum Index -> General Help
Author Message

Joined: 24/Sep/2008 00:00:00
Messages: 4


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)

Greetings Luca

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.
 Filename jsf-binding-test.zip [Disk] Download
 Filesize 6 Kbytes
 Downloaded:  254 time(s)


Joined: 26/Oct/2004 00:00:00
Messages: 874

The main concern with binding and session scope is that a single user can open multiple browser windows, causing the binding to refer to a single instance of a component attached to two different views, effectively corrupting the component tree hierarchy. So, it is certainly legal, but it is important that the user not open multiple browser windows onto the same page.

findComponent() is definitely safer than component bindings, so it is unfortunate that performance was not sufficient with that approach.

Joined: 24/Sep/2008 00:00:00
Messages: 4

Thanks for your explanation, Ted. I understand but i think the multi window problem can be solved with the icefaces windowscope? :)

Nevertheless the origin problem (duplicate ids after adding manipulated childs to the binding) exists also with the icefaces window scope. There exists a ticket in the mojarra jira, that i think is related to the problem: http://java.net/jira/browse/JAVASERVERFACES-1411 . I will later respond to this ticket.

For now we try to get better performance with the findComponent() approach. The problem with this approach is that the RESTORE_VIEW phase consume a lot of time (2 seconds). Our dynamic part can be complex (i dumped the dynamic created tree and it contains in a "real world example" near 3k of jsf components).

We now try to reduce the overall component count to an minimum.

There are any other tips how the RESTORE_VIEW phase can be optimized?
Forum Index -> General Help
Go to:   
Powered by JForum 2.1.7ice © JForum Team