[ 
https://issues.jboss.org/browse/RF-12281?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel
 ]

Brian Leathem updated RF-12281:
-------------------------------

    Story Points: 8

    
> rich:tree is iterated multiple times when item is selected
> ----------------------------------------------------------
>
>                 Key: RF-12281
>                 URL: https://issues.jboss.org/browse/RF-12281
>             Project: RichFaces
>          Issue Type: Bug
>      Security Level: Public(Everyone can see) 
>          Components: component-tree
>    Affects Versions: 4.2.2.Final
>            Reporter: Alex Vb
>             Fix For: 4.3.0.Milestone2
>
>
> I have a decently sized tree and I'm using the selectionChangeListener in 
> combination with toggleType="client" selectionType="ajax" render="node" to 
> trigger a selection event on the server. The panelGroup "node" is re-rendered 
> afterwards but it takes 1-2 seconds for each request. After enabling some 
> debug logging I noticed that the entire tree is iterated 4 times for each 
> request. Note a small test-tree exhibiting the same behavior:
> 2012-05-22 08:39:29.287 DEBUG CustomPhaseListener - Before phase: 
> APPLY_REQUEST_VALUES 2
> 2012-05-22 08:39:29.287 DEBUG TreeNodeBase - getChildrenKeysIterator(0)
> 2012-05-22 08:39:29.287 DEBUG TreeNodeBase - getChild(1)
> 2012-05-22 08:39:29.287 DEBUG TreeNodeBase - getChildrenKeysIterator(1)
> 2012-05-22 08:39:29.287 DEBUG TreeNodeBase - getChild(2)
> 2012-05-22 08:39:29.287 DEBUG TreeNodeBase - getChild(2)
> 2012-05-22 08:39:29.287 DEBUG TreeNodeBase - getChild(2)
> 2012-05-22 08:39:29.287 DEBUG Bean - selectionChanged()
> 2012-05-22 08:39:29.287 DEBUG CustomPhaseListener - After phase: 
> APPLY_REQUEST_VALUES 2
> 2012-05-22 08:39:29.287 DEBUG CustomPhaseListener - Before phase: 
> PROCESS_VALIDATIONS 3
> 2012-05-22 08:39:29.287 DEBUG TreeNodeBase - getChildrenKeysIterator(0)
> 2012-05-22 08:39:29.287 DEBUG TreeNodeBase - getChild(1)
> 2012-05-22 08:39:29.287 DEBUG TreeNodeBase - getChildrenKeysIterator(1)
> 2012-05-22 08:39:29.287 DEBUG TreeNodeBase - getChild(2)
> 2012-05-22 08:39:29.302 DEBUG TreeNodeBase - getChild(2)
> 2012-05-22 08:39:29.302 DEBUG CustomPhaseListener - After phase: 
> PROCESS_VALIDATIONS 3
> 2012-05-22 08:39:29.302 DEBUG CustomPhaseListener - Before phase: 
> UPDATE_MODEL_VALUES 4
> 2012-05-22 08:39:29.302 DEBUG TreeNodeBase - getChildrenKeysIterator(0)
> 2012-05-22 08:39:29.302 DEBUG TreeNodeBase - getChild(1)
> 2012-05-22 08:39:29.302 DEBUG TreeNodeBase - getChildrenKeysIterator(1)
> 2012-05-22 08:39:29.302 DEBUG TreeNodeBase - getChild(2)
> 2012-05-22 08:39:29.302 DEBUG TreeNodeBase - getChild(2)
> 2012-05-22 08:39:29.302 DEBUG CustomPhaseListener - After phase: 
> UPDATE_MODEL_VALUES 4
> 2012-05-22 08:39:29.302 DEBUG CustomPhaseListener - Before phase: 
> INVOKE_APPLICATION 5
> 2012-05-22 08:39:29.302 DEBUG CustomPhaseListener - After phase: 
> INVOKE_APPLICATION 5
> 2012-05-22 08:39:29.302 DEBUG CustomPhaseListener - Before phase: 
> RENDER_RESPONSE 6
> 2012-05-22 08:39:29.302 DEBUG TreeNodeBase - getChild(2)
> 2012-05-22 08:39:29.318 DEBUG TreeNodeBase - getChildrenKeysIterator(0)
> 2012-05-22 08:39:29.318 DEBUG TreeNodeBase - getChild(1)
> 2012-05-22 08:39:29.318 DEBUG TreeNodeBase - getChildrenKeysIterator(1)
> 2012-05-22 08:39:29.318 DEBUG TreeNodeBase - getChild(2)
> 2012-05-22 08:39:29.318 DEBUG TreeNodeBase - getChild(2)
> 2012-05-22 08:39:29.318 DEBUG CustomPhaseListener - After phase: 
> RENDER_RESPONSE 6
> On the rather large tree each iteration takes 300-500 ms which explains the 
> slow behavior. I have played around with every setting I could find, if 
> selectionType is set to "client" the tree is iterated only once (during the 
> render response phase) but the selection event does not seem to be triggered. 
> If toggleType is set to ajax, only the "expanded" parts of the tree are 
> iterated.
> I have no idea why the iteration is necessary for all these phases but I 
> "fixed" it in my implementation by recompiling the 
> org.richfaces.component.TreeRange class with an updated method:
>     public boolean shouldIterateChildren() {
>       if (tree.isLeaf())
>               return false;
>       else {
>               char separatorChar = 
> UINamingContainer.getSeparatorChar(FacesContext.getCurrentInstance());
>               String clientId = tree.getClientId();
>               boolean render = false;
>               for (String idToRender : 
> FacesContext.getCurrentInstance().getPartialViewContext().getRenderIds()) {
>                       // render the tree if you explicitly mention either the 
> client id (e.g. "menuForm:tree") or the parent component client id (e.g. 
> "menuForm")
>                       // note that when clicking on an object in the tree, 
> the following render target is requested: menuForm:tree@selection
>                       if (clientId.equals(idToRender) || 
> clientId.matches(idToRender + separatorChar + ".*")) {
>                               render = true;
>                               break;
>                       }
>               }
>               // always render if it's not a postback
>               return render || 
> !FacesContext.getCurrentInstance().isPostback();
>           }
>     }

--
This message is automatically generated by JIRA.
If you think it was sent incorrectly, please contact your JIRA administrators: 
https://issues.jboss.org/secure/ContactAdministrators!default.jspa
For more information on JIRA, see: http://www.atlassian.com/software/jira

        
_______________________________________________
richfaces-issues mailing list
[email protected]
https://lists.jboss.org/mailman/listinfo/richfaces-issues

Reply via email to