myfaces-users mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Rob Decker" <...@objectsource.org>
Subject Re: HtmlTree.processChildNodes
Date Wed, 30 Mar 2005 20:00:56 GMT
Without the check for expanded nodes the tree tries load all 90,000+ objects (which 
just isn't going to happen). I ready an earlier post of yours that HtmlTree can be 
extended. How do I inform faces to use my subclass? Do I have to register a new 
component and renderer? This tree is my jsf experience so I'm fairly clueless...but 
it's just the solution I need. Is this all I need:

	<component>
          <component-type>org.apache.myfaces.HtmlTree</component-type>
          <component-class>net.objectsource.ui.BigTree</component-class>
	</component>

or do I need to specify the renderer too?

I don't think that the issue you've pointed out affects the server-side so the 
isClientSideToggle method would probably work to improve performance on the server-
side. On the server side the whole visible tree reloads on both expand and collapse so 
you can't click a 'previously closed' node where it's expanded state was lost. I did 
some opening and closing of nodes (particularly of ones that I opened, closed and 
opend again to test the caching of my objects that I'm doing) and had no problems. I 
haven't used any navigation rules yet but I suppose I will (once I figure out how) and 
I'll need to fix that anyway if it is an issue so I'll let you know if you want to 
hold off on the clientsidetoggle method until then.

But since it'll be awhile for a release I'll just have to extend HtmlTree. That may be 
just as well because I'd like to add 'previous' and 'next' pseudo leaf links for 
branches where there are alot of children.

I wrote up an example of my tree node implementation and I will send it to you once I 
get the extended class working (it would load chilren forever if it didn't check if 
the node was expanded first). 

--
Rob

@objectsource.org


---------- Original Message -----------
From: Sean Schofield <sean.schofield@gmail.com>
To: MyFaces Discussion <myfaces-user@incubator.apache.org>
Sent: Wed, 30 Mar 2005 12:15:52 -0500
Subject: Re: HtmlTree.processChildNodes

> Rob,
> 
> Funny you should mention that suggestion.  I recently *removed* what
> you are suggesting from the code because it was causing problems.  I
> had thought (like you) that this would be a nice performance saver but
> it caused issues.
> 
> The problem had to do with navigation rules not being processed
> properly.  In the client-side toggle you could open the nodes on the
> client-side without posting to the server (which is much faster if you
> have a reasonable sized tree.)  When you do finally click a leaf node
> the nodes that you opened are *eventually* added to the list of
> expanded nodes.
> 
> The problem was that the leaf node clicked was sometimes contained
> within a node that was previously closed.  At the point where
> processChildNodes is called, we do not yet know that the node was
> expanded.  Therefore the child node never gets a chance to handle the
> ActionEvent and invoke the navigation rule.  On the subsequent attempt
> to click the node everything worked but that was because eventually
> the new list of expanded nodes was added.
> 
> Maybe we could look into the timing of the cookie processing on the
> client-side mode to see if we could prevent this from happening.  If
> we could solve that problem then we could go with what you are
> suggesting.  I agree that it would be more efficient but like I said,
> it was causing problems.  I can't remember if the problem also
> occurred on the server side or not.  If it doesn't then maybe we could
> change to:
> 
> if (isNodeExpandd() || isClientSideToggle())
> 
> There is curently no isClientSideToggle() method but you get the idea.
>  Just curious but did you notice a performance difference with this? 
> If you are using server-side toggle I would imagine your tree size
> would be limited and that you wouldn't actually notice any difference.
> 
> sean
> 
> > I implemented the TreeNode interface to wrap my objects for display in a Tree2.

Since
> > I currently have 90,000 objects in the database loading them all would be too slow.
> > But they are a tree and each level is relatively small. So the tree works great
for
> > displaying them.
> > 
> > I had to pull the Tree2 code out of myfaces to figure out how to write the TreeNode
> > implementation I needed so it would load only the nodes that were visible to the

user.
> > Turns out it worked great (and a little extra caching behind the scenes made it

pretty
> > responsive) but I had to add one line in HtmlTree.processChildNodes.
> > 
> > Before:
> > 
> >     protected void processChildNodes(FacesContext context, TreeNode parentNode,
int
> > processAction)
> >     {
> >         super.processChildNodes(context, parentNode, processAction);
> >     }
> > 
> > After:
> > 
> >     protected void processChildNodes(FacesContext context, TreeNode parentNode,
int
> > processAction)
> >     {
> >         if (isNodeExpanded())
> >                 super.processChildNodes(context, parentNode, processAction);
> >     }
> > 
> > If this can be merged into the official release I can use the myfaces.jar in my
> > project and possibly provide more insights on using the tree with a large amount
of
> > data.
> > 
> > --
> > Rob
> > 
> > @objectsource.org
> > 
> >
------- End of Original Message -------


Mime
View raw message