voyent
Tree Component  XML
Forum Index -> General Help
Author Message
burferd

Joined: 04/May/2006 00:00:00
Messages: 381
Offline


How do I add more nodes to a tree component?

I tried the obvious by adding a tree node component, but I get the following error message when I try to run:

com.sun.rave.web.ui.appbase.ApplicationException: Can't parse stream for /MainLoginPage.jsp The tree tag requires a single child treeNode tag. Found [2]

Here is the jsp code:

<ice:tree binding="#{MainLoginPage.tree1}" folderImage="/icons/dbmenu.gif" hideRootNode="true" id="tree1"
style="height: 230px; top: 200px; position: absolute; width: 200px" value="#{MainLoginPage.tree1Model.model}" var="item">
<ice:treeNode binding="#{MainLoginPage.treeNode1}" id="treeNode1">
<f:facet name="icon">
<ice:panelGroup binding="#{MainLoginPage.panelGroup1}" id="panelGroup1" style="display: inline">
<ice:graphicImage binding="#{MainLoginPage.graphicImage2}" id="graphicImage2" value="#{item.userObject.icon}"/>
</ice:panelGroup>
</f:facet>
<f:facet name="content">
<ice:outputText binding="#{MainLoginPage.outputText1}" id="outputText1" value="#{item.userObject.text}"/>
</f:facet>
</ice:treeNode>
<ice:treeNode binding="#{MainLoginPage.treeNode2}" id="treeNode2">
<f:facet name="icon">
<ice:panelGroup binding="#{MainLoginPage.panelGroup2}" id="panelGroup2">
<ice:graphicImage binding="#{MainLoginPage.graphicImage3}" id="graphicImage3" value="#{item.userObject.icon}"/>
</ice:panelGroup>
</f:facet>
<f:facet name="content">
<ice:outputText binding="#{MainLoginPage.outputText2}" id="outputText2" value="#{item.userObject.text}"/>
</f:facet>
</ice:treeNode>
</ice:tree>

If I leave out the second treeNode component, it will run, but only with a single node and single element under that node. What I want is:

Node1
-- Item1
-- Item2
-- Itme3
Node2
-- Item4
-- Item5
-- Item6
-- Item7
Node3
-- Item8
-- Item9
philip.breau


Joined: 08/May/2006 00:00:00
Messages: 2989
Offline


Hi,

You need to add nodes to the tree through the TreeModel API. The <ice:tree> tag only takes one defined <ice:treeNode> in the JSF markup. Please see http://resources.icefaces.org/tutorials/tree-tutorial.html for a tutorial on using trees.

Thanks,
Philip

.
burferd

Joined: 04/May/2006 00:00:00
Messages: 381
Offline


I tried usng the basic example in the following page fragment (Fragment2.jspf):

<?xml version="1.0" encoding="UTF-8"?>
<div style="-rave-layout: grid; width: 165px; height: 200px" xmlns:f="http://java.sun.com/jsf/core" xmlns:ice="http://www.icesoft.com/icefaces/component">
<f:subview id="Fragment2">
<ice:form binding="#{Fragment2.form1}" id="form1" style="height: 288px; left: 0px; top: 0px; position: absolute; width: 168px">
<ice:tree hideNavigation="false" hideRootNode="false" id="tree" imageDir="./xmlhttp/css/xp/css-images/"
style="height: 381px; position: absolute; width: 190px" value="#{TreeSessionBean.model}" var="item">
<ice:treeNode>
<f:facet name="content">
<ice:panelGroup style="display: inline">
<ice:outputText value="#{item.userObject.text}"/>
</ice:panelGroup>
</f:facet>
</ice:treeNode>
</ice:tree>
</ice:form>
</f:subview>
</div>


I have a Session bean (TreeSessionBean.java) that is a copy of the TreeBean code in the example..

I have encountered 2 items:
1) The page displays OK, but the node does not collapse like the example. I get a "page error" that I cannot locate.
2) The page is "invisible" to the 'design' view in JSC2-1.

Any idea how I might be able to change these behaviors so I can collapse the tree and see the components in the designer??
burferd

Joined: 04/May/2006 00:00:00
Messages: 381
Offline


I tried moving this to a separate page rather than a page fragment and it seems to work OK.

There appears to be an issue with using the tree in a page fragment.

My intent was to use this as a collapsable menu and I thought it would be better to use it in a page fragment so I could just copy the page fragment to each page that needed a menu. However, this does not appear to be applicable now.

After looking into it some more, the behavior is not well suited to my intent for the following:
1) You have to retain the small button with the +/- (you cannot click on the text and have it expand/collapse the node.
2) Nodes have to be specifically expanded and collapsed. Once it is open, it stays open until you close it by clicking on the (+/-) button. I could not see how do collapse or expand by program control.

In addition, the control does not appear to be compatible with IDE design windows. I needed to remove the component binding (in the JSC2-1 sense) althghether and have the component be constructed by a bean in order to make it work. This seems a bit inconsistent with most of the other components.

The positive side of this is that you can have a bean control the building and complexity of the component.

The down side is that you have to build the component within a bean rather than in an IDE designer window.
 
Forum Index -> General Help
Go to:   
Powered by JForum 2.1.7ice © JForum Team