-
1. Re: Tree selection stops working after 1-2 clicks
andrew.rw.robinson Mar 28, 2007 7:17 PM (in response to andrew.rw.robinson)I get this error in the LOG on the client. After this error, the tree selection stops working:
debug[17:13:26,148]: Evaluate script replaced area in document: // Richfaces_Tree_zfpForm_memberSelectionDialog_memberSelectorTree.getNodeElements(Richfaces_Tree_zfpForm_memberSelectionDialog_memberSelectorTree, "zfpForm:memberSelectionDialog:memberSelectorTree:6");Richfaces_Tree_zfpForm_memberSelectionDialog_memberSelectorTree.getNodeElements(Richfaces_Tree_zfpForm_memberSelectionDialog_memberSelectorTree, "zfpForm:memberSelectionDialog:memberSelectorTree:3"); // //
error[17:13:26,153]: . Error message: item has no properties -
2. Re: Tree selection stops working after 1-2 clicks
andrew.rw.robinson Mar 28, 2007 8:30 PM (in response to andrew.rw.robinson)More information:
The "Tree.SelectionManager.prototype"'s method setSelection:setSelection:function(item){item.toggleSelection();
Is called with item as "undefined" (causes the error).
I can't get much more information than that because the JavaScript is horribly formatted in the browser (no newlines), so I can't get accurate line debugging. -
3. Re: Tree selection stops working after 1-2 clicks
andrew.rw.robinson Mar 29, 2007 11:06 AM (in response to andrew.rw.robinson)It looks like the input value's "object" of the tree is null:
restoreSelection: function() { if (this.tree.input.value && $(this.tree.input.value)) { this.setSelection(($(this.tree.input.value)).object); } },
I'm not sure where "$(this.tree.input.value)).object" comes from, but this is the problem.
Any help? Or is no one working on the tree or is everyone just ignoring my posts? -
4. Re: Tree selection stops working after 1-2 clicks
andrew.rw.robinson Mar 29, 2007 3:39 PM (in response to andrew.rw.robinson)More information again. After reading up on prototype.js and looking at all the tree*.js code in the rich faces source, I now understand what is happening to a limited degree. I went into the JavaScript code and added LOG statements to all of the following events:
tree.js->Tree.prototype->initialize
tree.js->Tree.prototype->getNodeElements
tree-item.js->Tree.item.prototype->initialize
tree-item.js->Tree.item.prototype->getElements
tree-selection.js->Tree.SelectionManager.prototype->setSelection (if item argument is null)
This is the output when the tree breaks:debug[13:29:46,190]: ***** TreeItem getElements. id: zfpForm:memberSelectionDialog:memberSelectorTree:0. This: [object Object] warn[13:29:46,192]: ***** TreeSelection setSelection. item is null. ID: zfpForm:memberSelectionDialog:memberSelectorTree:3 debug[13:29:46,193]: ***** Tree getNodeElements Input ID: zfpForm:memberSelectionDialog:memberSelectorTree:input. Input: [object HTMLInputElement] debug[13:29:46,193]: ***** TreeItem getElements. id: zfpForm:memberSelectionDialog:memberSelectorTree:3. This: [object Object] debug[13:29:46,195]: ***** Tree getNodeElements Input ID: zfpForm:memberSelectionDialog:memberSelectorTree:input. Input: [object HTMLInputElement]
As you can see, the setSelection is being called BEFORE the getElements and getNodeElements. Which means that the code is attempting to use variables before they are initialized.
Now I am not yet sure why the timing is off, but I am leaning towards a bug with code in Ajax4Jsf that uses code like "window.setTimeout(script, 50);" to evaluate the inline code in the page. If this is true that means that the tree only works if you are lucky enough to have the scripts run in the correct order. I will keep looking into this.
Once I get enough information I will create a bug (blocker) for this issue as it causes the tree to be inoperable (not to mention any other A4j or RichFaces controls that depend on prototype code. -
5. Re: Tree selection stops working after 1-2 clicks
nbelaevski Mar 29, 2007 3:50 PM (in response to andrew.rw.robinson)Andrew,
Thank you for reporting! I'll investigate the problem you've described. Can you please post code sample causing tree to stop working? Thank you! -
6. Re: Tree selection stops working after 1-2 clicks
andrew.rw.robinson Mar 29, 2007 3:59 PM (in response to andrew.rw.robinson)I tracked down the issue to when more than one node is updated per-request. I logged the bug and mentioned the simple fix.
http://jira.jboss.com/jira/browse/RF-50 -
7. Re: Tree selection stops working after 1-2 clicks
andrew.rw.robinson Mar 29, 2007 4:56 PM (in response to andrew.rw.robinson)I don't have any pre-packaged code, but I can tell you how to reproduce it.
Use a NodeSelectionEvent listener method in a backing bean, and then update a few nodes in that bean in the event.
Java code snippets:public void onTreeNodeSelection(NodeSelectedEvent evt) { HtmlTree tree; if (evt.getComponent() instanceof UITreeNode) tree = (HtmlTree)evt.getComponent().getParent(); else tree = (HtmlTree)evt.getComponent(); TreeRowKey key = (TreeRowKey)tree.getRowKey(); Set keys = tree.getAjaxKeys(); if (keys == null) { keys = new HashSet(); tree.setAjaxKeys(keys); } AjaxContext ajaxCtx = AjaxContext.getCurrentInstance(); FacesContext fctx = FacesContext.getCurrentInstance(); tree.setRowKey(null); // Force more than one node to update here: for (int i = 0; i < 5; i++) { ListRowKey dirtyKey = new ListRowKey(Integer.toString(i)); keys.add(dirtyKey); tree.setRowKey(dirtyKey); ajaxCtx.getAjaxAreasToRender().add(tree.getClientId(fctx)); } tree.setRowKey(key); }
TreeNodeImpl rootNode = new TreeNodeImpl(); rootNode.setData("Root node"); for (int i = 0; i < 10; i++) { TreeNodeImpl child = new TreeNodeImpl(); String id = Integer.toString(i); child.setData("Node: " + id); rootNode.addChild(id, child); }
XHTML:<rf:tree id="testTree" var="_data" switchType="ajax" ajaxSubmitSelection="true" preserveModel="none" binding="#{testTree}" value="#{ajaxTreeTest.rootNode}" nodeSelectListener="#{ajaxTreeTest.onTreeNodeSelection}" nodeFace="node"> <rf:treeNode type="node"> #{_data} </rf:treeNode> </rf:tree>
I didn't test this example, but it *should* re-produce the problem. What you want to have happen is the getNodeElements for a node that is not the previous select to execute before the node that was the previous selection. That way the "($(this.tree.input.value)).object" will be null (since AJAX just replaced this element in the page, but the prototype isn't bound to that element yet) -
8. Re: Tree selection stops working after 1-2 clicks
nbelaevski Mar 30, 2007 2:58 PM (in response to andrew.rw.robinson)Hello Andrew!
Looks like the problem is caused by incorrect DOM structure inserted after AJAX request. I'll investigate the problem and will see what can be done to fix it. -
9. Re: Tree selection stops working after 1-2 clicks
nbelaevski Apr 3, 2007 3:16 PM (in response to andrew.rw.robinson)Hello Andrew!
Thank you for the sample! The problem is fixed in trunk now.