-
1. Re: Is there any way to only rerender the contents of a specific HtmlTreeNodesAdaptor?
lrp May 6, 2010 1:20 PM (in response to lrp)Does really no one have an idea as to how this can be done? When I drop elements on the adaptor node, I'm able to access the row key from the drop event, so I really see no reason it shouldn't be possible to access it at other times too, I just need some way to translate from an HtmlTreeNodesAdaptor or an HtmlTreeNode object to one or more row keys.
At the moment I'm rerendering the entire tree on changes, but that's not very performance friendly when many branches are open. It would be a huge boost if I was able to just rerender the adaptor or node for the branch that the change happened in.
-
2. Re: Is there any way to only rerender the contents of a specific HtmlTreeNodesAdaptor?
nbelaevski May 7, 2010 6:19 AM (in response to lrp)1 of 1 people found this helpfulHi,
To create row key use TreeRowKey that contains org.richfaces.model.StackingTreeModelKey as generic value type.
-
3. Re: Is there any way to only rerender the contents of a specific HtmlTreeNodesAdaptor?
lrp May 7, 2010 8:03 AM (in response to nbelaevski)Hey Nick. I tried doing the following:
List<StackingTreeModelKey<Integer>> keyList = new ArrayList<StackingTreeModelKey<Integer>>(); keyList.add(new StackingTreeModelKey<Integer>("idOfAdaptor", 0)); TreeRowKey<StackingTreeModelKey<Integer>> key = new ListRowKey<StackingTreeModelKey<Integer>>(keyList); tree.addRequestKey(key);
I figured that this would give me the key for the node at index 0 in the adaptor with the specified id. However, that results in the following exception:
java.lang.NullPointerException at org.richfaces.model.StackingTreeModel.getInternalModelById(StackingTreeModel.java:354) at org.richfaces.model.StackingTreeModel.doSetupKey(StackingTreeModel.java:154) at org.richfaces.model.StackingTreeModel.setupKey(StackingTreeModel.java:191) at org.richfaces.model.StackingTreeModel.setRowKey(StackingTreeModel.java:497) at org.richfaces.model.StackingTreeModel.setRowKey(StackingTreeModel.java:493) at org.ajax4jsf.component.UIDataAdaptorBase.setRowKey(UIDataAdaptorBase.java:351) at org.richfaces.renderkit.TreeRendererBase.encodeAjaxChildren(TreeRendererBase.java:457) at org.ajax4jsf.component.UIDataAdaptorBase.encodeAjaxChild(UIDataAdaptorBase.java:454) at
So I'm guessing I've set the key up incorrectly. Could you possibly clarify the steps for making a key a little more?
-
4. Re: Is there any way to only rerender the contents of a specific HtmlTreeNodesAdaptor?
nbelaevski May 7, 2010 5:05 PM (in response to lrp)As far as I remember, this is correct way to create key for these models. How does page code look like?
-
5. Re: Is there any way to only rerender the contents of a specific HtmlTreeNodesAdaptor?
lrp May 10, 2010 4:34 AM (in response to nbelaevski)The code is a bit big and complex, so I don't think it'll help much to show it here in any detail. I'll see if I can find the time to make a small example project that reproduces the problem.
-
6. Re: Is there any way to only rerender the contents of a specific HtmlTreeNodesAdaptor?
nbelaevski May 10, 2010 7:19 AM (in response to lrp)To be sure, you can compare existing rowKey (taken from "rowKeyVar" or just UITree component) with the manually created in debugger.
-
7. Re: Is there any way to only rerender the contents of a specific HtmlTreeNodesAdaptor?
lrp May 10, 2010 9:29 AM (in response to nbelaevski)I'll try that.
By the way, this isn't a recursive adaptor, but an adaptor nested in another adaptor. Could that be causing problems when making the key (and only referring to the id of the innermost adaptor)?
-
8. Re: Is there any way to only rerender the contents of a specific HtmlTreeNodesAdaptor?
nbelaevski May 10, 2010 9:45 AM (in response to lrp)1 of 1 people found this helpfulYes, this can be a problem. Key should include IDs & keys of all ancestor adaptors, not the innermost one.
-
9. Re: Is there any way to only rerender the contents of a specific HtmlTreeNodesAdaptor?
lrp May 10, 2010 10:03 AM (in response to nbelaevski)Yes, I can see that it doesn't give an error when trying the same approach on one of the top level adaptors.
I just tried doing as pasted below:
List<StackingTreeModelKey<Integer>> keyList = new ArrayList<StackingTreeModelKey<Integer>>(); keyList.add(new StackingTreeModelKey<Integer>("topLevelAdaptorId", 0)); keyList.add(new StackingTreeModelKey<Integer>("innermostAdaptorId", 0)); TreeRowKey<StackingTreeModelKey<Integer>> key = new ListRowKey<StackingTreeModelKey<Integer>>(keyList);
This seems to work, and it gives no errors. Am I right in assuming that this would give me a key for "topLevelAdaptorId:0:innermostAdaptorId:0" and only rerender the innermost one, without rerendering the entire top level one?
-
10. Re: Is there any way to only rerender the contents of a specific HtmlTreeNodesAdaptor?
nbelaevski May 10, 2010 10:30 AM (in response to lrp)Yes, that's right.
-
11. Re: Is there any way to only rerender the contents of a specific HtmlTreeNodesAdaptor?
lrp May 10, 2010 10:35 AM (in response to nbelaevski)Excellent. Thanks a lot, I doubt I'd have been able to figure this out without your help!