You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@myfaces.apache.org by Oliver Rossmueller <ol...@tuxerra.com> on 2005/02/01 22:10:40 UTC
Re: Improvements to MyFaces custom tree component
In fact the tree was created with the swing tree component in mind as
might also be stated somewhere in the comments of the sources. In fact
the myfaces TreeNode interface is a clone of the swing TreeNode
interface. Reason is that I did not like the idea of having myfaces
depend on swing because of that interface.
And to answer the question why children() returns an Iterator and not an
Enumeration: well, I prefer Iterator because of it's interface which I
know from other languages. There is no deeper reason than that. If you
like I'm just following the Enumeration javadoc: ' New implementations
should consider using Iterator in preference to Enumeration.' :-)
Oliver
Heath Borders wrote:
>I'm in favor of using the Swing TreeNode interface. I'd really like
>to see this whole thing implemented exactly like the swing JTree with
>the models they have.
>
>
>On Sun, 30 Jan 2005 12:08:54 -0500, Sean Schofield
><se...@gmail.com> wrote:
>
>
>>One revision to my suggestion would be to not have a separate
>>interface for branch vs. regular node. We can probably use the
>>existing MyFaces TreeNode interface which has an isLeaf method. It
>>turns out this is how its done in the Swing version of TreeNode so we
>>should probably conform to that.
>>
>>One question for Oliver would be why the children() method returns an
>>Interrator instead of Enumeration as in the Swing version? Other than
>>this method the TreeNode interface seems to match the Swing version.
>>
>>Also, would it be appropriate to just use the
>>javax.swing.tree.TreeNode interface? If the interfaces are identical
>>maybe we could just use the one in the java API. Its a little odd
>>perhaps but I can't really think of a good reason not to do so.
>>
>>sean
>>
>>
>>
>
>
>
>
--
Oliver Rossmueller
Software Engineer and IT-Consultant
Hamburg, Germany
http://www.rossmueller.com
Re: Improvements to MyFaces custom tree component
Posted by Sean Schofield <se...@gmail.com>.
I was just flipping through my O'Reilly JSF book (which I never
finished reading) and I saw that they have an example of a custom tree
component.
I'll have to read the details later tonight but interestingly they
also chose to use facets. Our tree will ultimately be more robust
than a book example but there might be some good ideas in there. Hans
Bergsten is certainly an authority on JSF.
sean
Re: Improvements to MyFaces custom tree component
Posted by Oliver Rossmueller <ol...@tuxerra.com>.
Sean Schofield wrote:
>>So will TreeData replace TreeModel? Or will TreeData hold the state of
>>expanded/collapsed nodes as HtmlTreeNode does at the moment?
>>
>>
>
>I am thinking that TreeData is a superclass for HtmlTree. This would
>be similar to how UIData is the parent class for HtmlDataTable.
>
>
Ok, now I got it. But maybe the name should be UITree then?
>I still need to give some thought as to how to store the state of the
>expanded and collapsed nodes.
>
>
JSF takes care for saving the component state, have a look at the
saveState/restoreState methods of HtmlTree and HtmlTreeNode for example.
The trick there is that the root HtmlTreeNode is an internal facet of
HtmlTree and this way is stored/restored with the tree by the JSF impl.
Any HtmlTreeNode holds a list of child nodes which is also
stored/restored by the JSF impl and this way the current state of the
tree is stored.
>
>There are some advantages to having the nodes be unaware of whether
>their own expand/collapse state. I would prefer to think of the node
>as a strictly a data container. It should have type information (to
>assist in rendering) and other nodes plus a description and id.
>That's it. Whether or not the node is expanded is really a "view"
>detail.
>
>I'm thinking that the renderer would keep track of the open and expand
>portion. That would seem appropriate because only the renderer really
>needs to know (so it can render outgoing HTML correctly.) Of course a
>*change* in the nodes expand/collapse state is important beyond the
>renderer. But that change in state could be handled by action
>listeners.
>
>
>
>>I guess you will iterate over the list of nodes visible in the tree
>>(meaning all the expanded nodes plus their respective children) but not
>>over all the nodes in the tree model. I see a need to refactor the way
>>the state of a tree is stored as the rendering using facets will be
>>different to how rendering is done today. If that's what TreeData is for
>>then it's ok to me but maybe a little bit confusing to the user:
>>"TreeModel? TreeData? What's the difference?"
>>
>>
>
>In my app at work we store the expand/collapse state in cookies. This
>way every time they click on a leaf and the tree is re-rendered, the
>same nodes are open as before. (If they don't have cookies no big
>deal, tree starts off closed again.)
>
>We probably can do better than cookies in the JSF version. I haven't
>thought it through all of the way yet. But this would be another
>reason to break the expand/collapse state away from the nodes. This
>information could be persisted seperately from the data model.
>
>Anyways, these are just some ideas. I am open to any
>suggestions/questions/critcism...
>
>
>
>>Oliver
>>
>>
>
>sean
>
>
--
Oliver Rossmueller
Software Engineer and IT-Consultant
Hamburg, Germany
http://www.rossmueller.com
Re: Improvements to MyFaces custom tree component
Posted by Sean Schofield <se...@gmail.com>.
> So will TreeData replace TreeModel? Or will TreeData hold the state of
> expanded/collapsed nodes as HtmlTreeNode does at the moment?
I am thinking that TreeData is a superclass for HtmlTree. This would
be similar to how UIData is the parent class for HtmlDataTable.
I still need to give some thought as to how to store the state of the
expanded and collapsed nodes.
There are some advantages to having the nodes be unaware of whether
their own expand/collapse state. I would prefer to think of the node
as a strictly a data container. It should have type information (to
assist in rendering) and other nodes plus a description and id.
That's it. Whether or not the node is expanded is really a "view"
detail.
I'm thinking that the renderer would keep track of the open and expand
portion. That would seem appropriate because only the renderer really
needs to know (so it can render outgoing HTML correctly.) Of course a
*change* in the nodes expand/collapse state is important beyond the
renderer. But that change in state could be handled by action
listeners.
> I guess you will iterate over the list of nodes visible in the tree
> (meaning all the expanded nodes plus their respective children) but not
> over all the nodes in the tree model. I see a need to refactor the way
> the state of a tree is stored as the rendering using facets will be
> different to how rendering is done today. If that's what TreeData is for
> then it's ok to me but maybe a little bit confusing to the user:
> "TreeModel? TreeData? What's the difference?"
In my app at work we store the expand/collapse state in cookies. This
way every time they click on a leaf and the tree is re-rendered, the
same nodes are open as before. (If they don't have cookies no big
deal, tree starts off closed again.)
We probably can do better than cookies in the JSF version. I haven't
thought it through all of the way yet. But this would be another
reason to break the expand/collapse state away from the nodes. This
information could be persisted seperately from the data model.
Anyways, these are just some ideas. I am open to any
suggestions/questions/critcism...
> Oliver
sean
Re: Improvements to MyFaces custom tree component
Posted by Oliver Rossmueller <ol...@tuxerra.com>.
Sean Schofield wrote:
>Oliver,
>
>I am starting to work on some of the new classes (and changes to
>existing classes) for the Tree.
>
>I was wondering if we really need the stuff concerning
>TreeModelListener. I'm imagining this would be a server-side
>implementation rquirement but I still can't figure out why we would
>need it.
>
>I am planning on adding a new class TreeData (similar to UIData). The
>plan is that It will iterrate over the entire list of nodes and ask
>the renderer to render the node based on the matching facet. The
>dynamic changes to the data model would happen before the
>RendersResponse phase so I'm thinking that the tree does not need to
>worry about whether or not the model has changed. Its going to render
>whatever is in the model at that time.
>
>What do you think about this approach?
>
>
So will TreeData replace TreeModel? Or will TreeData hold the state of
expanded/collapsed nodes as HtmlTreeNode does at the moment?
I guess you will iterate over the list of nodes visible in the tree
(meaning all the expanded nodes plus their respective children) but not
over all the nodes in the tree model. I see a need to refactor the way
the state of a tree is stored as the rendering using facets will be
different to how rendering is done today. If that's what TreeData is for
then it's ok to me but maybe a little bit confusing to the user:
"TreeModel? TreeData? What's the difference?"
Oliver
>sean
>
>
>On Tue, 01 Feb 2005 22:10:40 +0100, Oliver Rossmueller
><ol...@tuxerra.com> wrote:
>
>
>>In fact the tree was created with the swing tree component in mind as
>>might also be stated somewhere in the comments of the sources. In fact
>>the myfaces TreeNode interface is a clone of the swing TreeNode
>>interface. Reason is that I did not like the idea of having myfaces
>>depend on swing because of that interface.
>>
>>And to answer the question why children() returns an Iterator and not an
>>Enumeration: well, I prefer Iterator because of it's interface which I
>>know from other languages. There is no deeper reason than that. If you
>>like I'm just following the Enumeration javadoc: ' New implementations
>>should consider using Iterator in preference to Enumeration.' :-)
>>
>>Oliver
>>
>>
>>Heath Borders wrote:
>>
>>
>>
>>>I'm in favor of using the Swing TreeNode interface. I'd really like
>>>to see this whole thing implemented exactly like the swing JTree with
>>>the models they have.
>>>
>>>
>>>On Sun, 30 Jan 2005 12:08:54 -0500, Sean Schofield
>>><se...@gmail.com> wrote:
>>>
>>>
>>>
>>>
>>>>One revision to my suggestion would be to not have a separate
>>>>interface for branch vs. regular node. We can probably use the
>>>>existing MyFaces TreeNode interface which has an isLeaf method. It
>>>>turns out this is how its done in the Swing version of TreeNode so we
>>>>should probably conform to that.
>>>>
>>>>One question for Oliver would be why the children() method returns an
>>>>Interrator instead of Enumeration as in the Swing version? Other than
>>>>this method the TreeNode interface seems to match the Swing version.
>>>>
>>>>Also, would it be appropriate to just use the
>>>>javax.swing.tree.TreeNode interface? If the interfaces are identical
>>>>maybe we could just use the one in the java API. Its a little odd
>>>>perhaps but I can't really think of a good reason not to do so.
>>>>
>>>>sean
>>>>
>>>>
>>>>
>>>>
>>>>
>>>
>>>
>>>
>>>
>>--
>>Oliver Rossmueller
>>Software Engineer and IT-Consultant
>>Hamburg, Germany
>>http://www.rossmueller.com
>>
>>
>>
>>
--
Oliver Rossmueller
Software Engineer and IT-Consultant
Hamburg, Germany
http://www.rossmueller.com
Re: Improvements to MyFaces custom tree component
Posted by Sean Schofield <se...@gmail.com>.
Oliver,
I am starting to work on some of the new classes (and changes to
existing classes) for the Tree.
I was wondering if we really need the stuff concerning
TreeModelListener. I'm imagining this would be a server-side
implementation rquirement but I still can't figure out why we would
need it.
I am planning on adding a new class TreeData (similar to UIData). The
plan is that It will iterrate over the entire list of nodes and ask
the renderer to render the node based on the matching facet. The
dynamic changes to the data model would happen before the
RendersResponse phase so I'm thinking that the tree does not need to
worry about whether or not the model has changed. Its going to render
whatever is in the model at that time.
What do you think about this approach?
sean
On Tue, 01 Feb 2005 22:10:40 +0100, Oliver Rossmueller
<ol...@tuxerra.com> wrote:
> In fact the tree was created with the swing tree component in mind as
> might also be stated somewhere in the comments of the sources. In fact
> the myfaces TreeNode interface is a clone of the swing TreeNode
> interface. Reason is that I did not like the idea of having myfaces
> depend on swing because of that interface.
>
> And to answer the question why children() returns an Iterator and not an
> Enumeration: well, I prefer Iterator because of it's interface which I
> know from other languages. There is no deeper reason than that. If you
> like I'm just following the Enumeration javadoc: ' New implementations
> should consider using Iterator in preference to Enumeration.' :-)
>
> Oliver
>
>
> Heath Borders wrote:
>
> >I'm in favor of using the Swing TreeNode interface. I'd really like
> >to see this whole thing implemented exactly like the swing JTree with
> >the models they have.
> >
> >
> >On Sun, 30 Jan 2005 12:08:54 -0500, Sean Schofield
> ><se...@gmail.com> wrote:
> >
> >
> >>One revision to my suggestion would be to not have a separate
> >>interface for branch vs. regular node. We can probably use the
> >>existing MyFaces TreeNode interface which has an isLeaf method. It
> >>turns out this is how its done in the Swing version of TreeNode so we
> >>should probably conform to that.
> >>
> >>One question for Oliver would be why the children() method returns an
> >>Interrator instead of Enumeration as in the Swing version? Other than
> >>this method the TreeNode interface seems to match the Swing version.
> >>
> >>Also, would it be appropriate to just use the
> >>javax.swing.tree.TreeNode interface? If the interfaces are identical
> >>maybe we could just use the one in the java API. Its a little odd
> >>perhaps but I can't really think of a good reason not to do so.
> >>
> >>sean
> >>
> >>
> >>
> >
> >
> >
> >
>
> --
> Oliver Rossmueller
> Software Engineer and IT-Consultant
> Hamburg, Germany
> http://www.rossmueller.com
>
>
Re: Improvements to MyFaces custom tree component
Posted by Sean Schofield <se...@gmail.com>.
> Reason is that I did not like the idea of having myfaces
> depend on swing because of that interface.
That was the best reason I could think of. I'm not wild about seeing
"javax.swing" in my faces import statements either :-)
> Oliver
sean