> This is something I want to do that, for all I know, could be easy, or
> perhaps it is very hard.
It looks pretty easy to me. More below.
> I need a tree widget, like a directory browser. The widget should
> display a tree where each node is a hyper-link that performs an action
> to browse and re-render the tree. (In HTML terms, this could be
> implemented as nested unordered lists, or alternatively as a table.)
I strongly suggest a list here. :)
> Each hyper-link represents either a branch or a terminal node, like a
> directory or a file. If the user clicks on a branch link, I want the
> widget to "open" that branch and display its children, and close
> anything that was "open" before.
>
> Associated with some nodes would be additional links that the user
> could click on to perform some other actions.
>
> Q: Using Weblocks, would it be necessary to render each of the tree
> browser links as a hyper-link to the entire page and redisplay the
> entire tree?
You never need to reload the entire page, because even if you
want to take the easy road and just re-render the tree it can
be done via AJAX.
But you don't even need to reload the tree.
First define a widget for displaying a branch node.
Clicking on a node invokes an action that toggles the state of
it. When the state changed from closed to open you just set
the currently open node to closed (keep a pointer to it in
the tree object).
Rendering behavior: a closed node just renders itself,
an open node renders itself and all of its children.
This way a maximum of two small widgets will need to be
reloaded on each click.
> Maybe I should be looking beyond Weblocks to do this?
I think Weblocks is an exceptionally good match for what you
are trying to do here.
But I'm curious, what made you think it might not?
Leslie
You could also implement a weblocks back-end for the YUI TreeView:
http://developer.yahoo.com/yui/treeview/
which would give you all the functionality you will ever need plus a
well-tested browser widget.
This is what I'd do.
--J.
> You could also implement a weblocks back-end for the YUI TreeView:
> http://developer.yahoo.com/yui/treeview/
>
> which would give you all the functionality you will ever need plus a
> well-tested browser widget.
At the expense of taking away non-AJAX compatibility and having to
load a host of YUI scripts of course, yielding a less general
solution. And it's not Lisp. :)
NB: I don't mean to denigrate the JS approach (which surely has its
own merits), but the disadvantages need to be pointed out.
Leslie
All true. But then it would be more responsive, and some of us load the
YUI modules anyway (on-demand of course).
I tend to worry less and less about non-Javascript compatibility. I
tried to use the web recently without Javascript and found that most
things people care about are unusable (youtube being an example). I am
not sure this is an issue anymore, even mobile browsers implement
Javascript correctly. And libraries such as YUI place a huge emphasis on
accessibility.
--J.