You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@myfaces.apache.org by Gosuin Gilles <gi...@chirec.be> on 2004/11/19 15:05:32 UTC

Some tree-related problems

Hi !

I'm facing some problems to get what I really want out of MyFaces' tree
component.

First of all : why did you design it so "poorly" ? (sorry 'bout that, I do
appreciate your work *a lot*, but this "everything-in-the-model-thing",
except for the iconProvider and the impotent selectionListener, is really
making this component user-unfriendly).

Most of the time, trees are used to navigate through a hierarchical
structure, and then get details about some node (like a File Explorer, for
instance) in some other pane.

Well, how do you do that in practice ? You usually make two frames, the left
one with the tree, the right one with the info you need. Then how do you
pass the selected node to the other frame ? Well, the only way seems to
acces FacesContext and put the selected node into the session map... Quite
boring... What's more, once this is done, YOU STILL CAN'T UPDATE THE RIGHT
PANEL WITHOUT TAKING SOME OTHER ACTION (clicking on a button, most of the
time). You did have the good idea to render the tree nodes as html links...
great ! Why can't we add an action to these links ? I did try to manipulate
the nodes programmatically, but I do not have sufficient comprehension of
the JSF structure to be able to do that... And I think one shouldn't...
After all, we're users and should be "protected" from the implementation
part, shouldn't we ? IMHO, only the model should be accessed from within
Java code, not the underlying JSF renderers...

What about some additionnal provider ? Something like an "URLProvider" or
some "getAction()" and "getTarget()" methods inside the selection listener;
when a node is clicked, one could then provide dynamically the action to be
taken (the page to display), and the target (the frame where it should be
displayed). A bit less powerful solution (because a bit more "monolithic")
would be to add "action" and "target" attributes to the tree tag... It would
be quite normal, since there IS a form behind that component, isn't it ? But
the only thing it's intended to do, is refreshing the tree's frame...

Actually, all this would not be necessary if you don't use frames... the
whole page gets refreshed, and everything works fine... But, come on... 99%
of the time, one will want to be able to scroll the right panel while
keeping the tree accessible...

So, I thought "Right, I'll give iframes a try"... I'll put the tree in the
first column of a panelGrid, and the table containing the info on the second
one, inside an iframe... Well, MyFaces seems not to be able to handle
iframes...

My code looks like this :

<h:panelGrid columns="2">
	<x:tree (...)>
		(...)
	</x:tree>
	<f:verbatim>
		<iframe src="(...)"/>
	</f:verbatim>
</h:panelGrid>

I tried surrounding the verbatim tags with a subview tag, it doesn't change
anything. The error I get when I click anywhere on the tree is a Javascript
error : "Object expected".

Sorry if this mail is a bit lengthy, but this problem really matters to me,
and I wanted to describe the problem as thoroughly as possible, and propose
constructive solutions.

Thanks a lot in advance !

GG.