Thank you Andrew, works like a charm.
The example I looked was at http://www.irian.at/myfaces/tree2.jsf, and in
tree2.jsf they used a new facet for each new root node. Thats why I thought
that I need to create new facet for each node
Thank you,
Roman.
On 11/5/07, Andrew Robinson <[EMAIL PROTECTED] > wrote:
>
> You only create facets for each node that you would want to render
> differently.
>
> So if all folders look the same, you just create one facet.
>
> If you want two types of nodes, one for files, one for folders, use to
> facets (name=file and name=folder for example).
>
> There is no need to create multiple folder facets unless you want the
> folders to be rendered differently.
>
> The tree iterates over each node, gets the facet, and renders it. It
> works much like the swing tree control does with tree node renderers.
>
> Very high level overview of how tree2 renderer works:
>
> start of the tree: render the HTML at the beginning
> move to the first node
> get the facet for that node
> render the facet
> move to the next node
> repeat above steps for every node
> write the end HTML
>
> So the facet is re-used for each node of that type.
>
> So, in your case, your nodes should have a type of "file" and
> "folder". There are two corresponding facets -- "file" and "folder".
> The "file" facet will be used to render file nodes and the "folder"
> facet will be used to render folder nodes.
>
> Think of tree2 the same way as dataTable -- you don't create
> components for every row of the data table, you just create the
> columns. The node facets of tree2 behave in a similar way to the
> columns (except that only one is rendered per row)
>
> -Andrew
>
>
>
> On 11/5/07, Roman <[EMAIL PROTECTED] > wrote:
> > Thank you again Andrew,
> >
> > I was looking at Tomahawk example for the tree2 and it looks like for
> each
> > folder node and child folder node you need to create separate facet.
> > I guess thats where I am getting confused.
> >
> > For example:
> >
> > Root Folder
> > --->Folder 1
> > -->Sub Folder 1
> > -->SomeFile1.zip
> > -->SomeFile2.zip
> >
> > --->Folder 2
> > -->Sub Folder 2
> > -->Sub-Sub Folder 2
> > -->SomeFileSub2.zip
> > -->SomeFileSub2.zip
> >
> > --->Folder 3
> > -->Sub Folder 3
> > -->Sub-Sub Folder 3
> > --> SomeFilesSubSubFolder3.zip
> >
> > For that case I would need to have 5 facets:
> >
> > First one for Root folder
> >
> > <f:facet name="folder">
> > .....
> > </f:facet>
> >
> > Second one for Folder 1, Folder 2, Folder 3 (first level)
> >
> > <f:facet name="folderFirstLevel">
> > .....
> > </f:facet>
> >
> > Third one for Sub Folder 1,Sub Folder 2,Sub Folder 3 (second level)
> >
> > <f:facet name="folderSecondLevel">
> > .....
> > </f:facet>
> >
> > Forth for Sub-Sub Folder 1,Sub-Sub Folder 2,Sub-Sub Folder 3 (third
> level)
> >
> > <f:facet name="folderThirdLevel">
> > .....
> > </f:facet>
> >
> > And fifth one for files
> >
> > <f:facet name="files">
> > .....
> > </f:facet>
> >
> > Now if I don't know how many levels or sub-levels would be, how would I
> > implement that solution???
> >
> > Roman.
> >
> >
> > On 11/5/07, Andrew Robinson <[EMAIL PROTECTED]> wrote:
> > > Sure,
> > >
> > > I would recommend that you have a look at the Tomahawk examples for
> > > tree2 and go from there. You will only need one or two facets,
> > > depending on if you decide to show the files in the tree or not.
> > > Example:
> > >
> > > <t:tree2 var="_folder" value=#{bean.folderModel}">
> > > <f:facet name="folder">
> > > <t:commandLink action="#{ bean.loadContents">
> > > <t:updateActionListener
> > > property="#{bean.selectedFolder}"
> > > value="#{_folder}" />
> > > </t:commandLink>
> > > </f:facet>
> > > </t:tree2>
> > >
> > >
> > >
> > > On 11/5/07, Roman < [EMAIL PROTECTED]> wrote:
> > > > Thank you,
> > > >
> > > > I was just thinking of using tree2 for file browsing on the server.
> Can
> > this
> > > > be accomplished with tree2??
> > > >
> > > >
> > > >
> > > > On 11/5/07, Andrew Robinson < [EMAIL PROTECTED]> wrote:
> > > > > No, this should not work to my knowledge
> > > > >
> > > > > The reason is that the facet is a key in a map to a component.
> Hash
> > > > > map keys are not dynamic. If they even stored an EL expression,
> they
> > > > > would not be evaluated at the right time for what you are trying
> to
> > > > > do.
> > > > >
> > > > > If you use JSP, you could use ${}, and for facelets, this would be
> > > > > evaluated at compile time. Either way, the var would not be
> populated.
> > > > >
> > > > > The very nature of what you are trying to do is wrong I am afraid.
> A
> > > > > facet is a component. Components are built during compile time.
> Data
> > > > > tables are evaluated at run time. As a result, you are trying to
> have
> > > > > the data table dynamically add and remove facets from a component
> > > > > while the loop is occurring.
> > > > >
> > > > > To do this, you will have to either (1) create a facet for every
> > > > > possible folder type or (2) use c:forEach to build the components
> > > > > during compile time.
> > > > >
> > > > > In addition, I don't even see why you would want to do this. You
> only
> > > > > have one facet, so all nodes would look the same, what would
> changing
> > > > > the name of the facet give you? Just use one node type in building
> > > > > your tree model for folders.
> > > > >
> > > > > On 11/5/07, Roman < [EMAIL PROTECTED]> wrote:
> > > > > > Hi,
> > > > > >
> > > > > > Is it possible to use dynamic values in f:facet inside name
> > property???
> > > > > > Something like that:
> > > > > >
> > > > > > <t:dataList value="#{treeBacker.folderList }" var="folder">
> > > > > >
> > > > > > <t:tree2 id="clientTree" value="#{ treeBacker.treeData}"
> > > > var="node"
> > > > > > varNodeToggler="t">
> > > > > > <f:facet name="#{ folder.name}">
> > > > > > <h:panelGroup>
> > > > > > <f:facet name="expand">
> > > > > > <t:graphicImage
> > > > > > value="images/yellow- folder-open.png" rendered="#{
> t.nodeExpanded}"
> > > > > > border="0"/>
> > > > > > </f:facet>
> > > > > > <f:facet name="collapse">
> > > > > > <t:graphicImage
> > > > > > value="images/yellow-folder-closed.png"
> > rendered="#{!t.nodeExpanded}"
> > > > > > border="0"/>
> > > > > > </f:facet>
> > > > > > <h:outputText
> > value="#{node.description}"
> > > > > > styleClass="nodeFolder"/>
> > > > > > </h:panelGroup>
> > > > > > </f:facet>
> > > > > > </t:tree2>
> > > > > >
> > > > > >
> > > > > > </t:dataList>
> > > > > >
> > > > > > Thank you,
> > > > > > Roman.
> > > > > >
> > > > > >
> > > > >
> > > >
> > > >
> > >
> >
> >
>