tree
tree
hojas. Mueve los nodos arriba y abajo usando los Botones de Comandos de la parte inferior
de la página.
Employees
Western
Smith, Ethan
Smith, Jacob
Williams, Daniel
Brown, Andrew
Central
Brown, Joshua
Brown, Christopher
Miller, Vincent
Davis, Matthew
Eastern
Garcia, Alexander
Garcia, Jacob
Garcia, Benjamin
Rodriguez, Joshua
EmployeeUserObject.java
/* MPL License text (see http://www.mozilla.org/MPL/) */
package org.icefaces.application.showcase.view.bean.examples.component.tr
ee;
import org.icefaces.application.showcase.model.entity.Employee;
import javax.swing.tree.DefaultMutableTreeNode;
package org.icefaces.application.showcase.view.bean.examples.component.tr
ee;
import com.icesoft.faces.component.tree.IceUserObject;
import javax.swing.tree.DefaultMutableTreeNode;
setLeafIcon("tree_document.gif");
setBranchContractedIcon("tree_folder_closed.gif");
setBranchExpandedIcon("tree_folder_open.gif");
setExpanded(true);
}
TreeController.java
/* MPL License text (see http://www.mozilla.org/MPL/) */
package org.icefaces.application.showcase.view.bean.examples.component.tr
ee;
import com.icesoft.faces.component.dragdrop.DropEvent;
import com.icesoft.faces.component.ext.HtmlPanelGroup;
import com.icesoft.faces.component.tree.IceUserObject;
import org.icefaces.application.showcase.model.entity.Employee;
import org.icefaces.application.showcase.util.FacesUtils;
import org.icefaces.application.showcase.view.bean.BaseBean;
import javax.faces.event.ActionEvent;
import javax.swing.tree.DefaultMutableTreeNode;
import javax.swing.tree.DefaultTreeModel;
import javax.swing.tree.MutableTreeNode;
import java.util.ArrayList;
import java.util.Enumeration;
import java.io.Serializable;
/**
* <p>The TreeBean class is the backing bean for the Tree Component showc
ase
* demonstration. It is used to store and display the selected tree node<
/p>
*
* @see NodeUserObject
* @since 0.3.0
*/
public class TreeController extends BaseBean implements Serializable {
/**
* Construct the default tree structure by combining tree nodes.
*/
public TreeController() {
init();
}
if (node1.isNodeDescendant(node2)) {
while (node2.getChildCount() > 0) {
node1.insert((MutableTreeNode) node2.getFirstChild(), chi
ldCount++);
}
if (node1PrevNode == node1Parent ||
(node1PrevNode.isNodeSibling(node1) && !
node1PrevNode.getAllowsChildren())) {
node1Parent.insert(node2, node1Parent.getIndex(node1));
} else if (node1PrevNode.getAllowsChildren()) {
node1PrevNode.add(node2);
} else {
node1PrevNodeParent.add(node2);
}
return;
}
if (node2.getAllowsChildren()) {
node2.insert(node1, 0);
} else {
node1.removeFromParent();
node2Parent.insert(node1, node2Parent.getIndex(node2) + 1);
}
}
if (dragNode.isNodeDescendant(dropNode)) return;
if (dropNode.getAllowsChildren()) {
dropNode.insert(dragNode, 0);
} else {
dragNode.removeFromParent();
dropNodeParent.insert(dragNode, dropNodeParent.getIndex(dropN
ode) + 1);
}
}
return node;
}
tree.jspx
// MPL License text (see http://www.mozilla.org/MPL/)
<ice:panelGroup styleClass="componentBox"
xmlns:h="http://java.sun.com/jsf/html"
xmlns:f="http://java.sun.com/jsf/core"
xmlns:ice="http://www.icesoft.com/icefaces/component">
<ice:panelGroup styleClass="synopsisBox">
<ice:outputText value="#{msgs['page.tree.synopsis']}"/>
<ice:outputText value="#{msgs['page.tree.explanation']}"/>
</ice:panelGroup>
<ice:panelGroup styleClass="exampleBox">
<ice:tree id="tree"
value="#{treeController.model}"
var="node"
hideRootNode="false"
hideNavigation="false"
imageDir="#{styleBean.imageDirectory}">
<ice:treeNode>
<f:facet name="icon">
<ice:panelGroup
style="display: inline" >
<ice:graphicImage
value="/xmlhttp/css/#{styleBean.currentStyle}/
css-images/#{node.userObject.icon}"/>
</ice:panelGroup>
</f:facet>
<f:facet name="content">
<ice:panelGroup
styleClass="selectedNode#{node.userObject eq tree
Controller.selectedUserObject}"
style="display: inline" >
<ice:commandLink
actionListener="#{treeController.employeeNode
Selected}">
<f:param name="employeeId" value="#{node.userObje
ct.employee.id}" />
<ice:outputText id="TreeNode"
value="#{node.userObject.text}"/>
</ice:commandLink>
</ice:panelGroup>
</f:facet>
</ice:treeNode>
</ice:tree>
<br/>
<ice:commandButton id="moveUp"
value="#{msgs['page.tree.move.up.label']}"
disabled="#{treeController.moveUpDisabled}"
actionListener="#{treeController.moveUp}"/>
<ice:commandButton id="moveDown"
value="#{msgs['page.tree.move.down.label']}"
disabled="#{treeController.moveDownDisabled}"
actionListener="#{treeController.moveDown}"/>
</ice:panelGroup>
<ice:outputLabel value="#{msgs['page.tree.path.label'
]}"/>
<ice:panelSeries id="icePnlSrs"
value="#{treeController.selectedTree
Path}"
var="treePath">
<ice:graphicImage
width="11" height="8"
style="margin-left:3px;margin-right:3px;"
value="/xmlhttp/css/rime/css-images/
bullet.gif" />
<ice:outputText id="treePath" value="#{treePath}"
/>
</ice:panelSeries>
<ice:outputLabel value="#{msgs['page.tree.employee.id
.label']}"/>
<ice:outputText id="employeeID"
value="#{treeController.selectedUserObject.em
ployee.id}"/>
<ice:outputLabel value="#{msgs['page.tree.employee.na
me.label']}"/>
<ice:outputText id="employeeName"
value="#{treeController.selectedUserObject.em
ployee.firstName} #{treeController.selectedUserObject.employee.lastName}"
/>
<ice:outputLabel value="#{msgs['page.tree.employee.ph
one.label']}"/>
<ice:outputText id="employeePhone"
value="#{treeController.selectedUserObject.em
ployee.phone}"/>
</ice:panelGrid>
</ice:panelGroup>
</ice:panelGroup>
</ice:panelGroup>
</ice:panelGroup>
tree
The tree component displays hierarchical data as a "tree" of branches and leaf nodes.
Optionally, the tree may also display navigation controls for the dynamic expansion and
collapse of branch nodes. Nodes may also support an action event when clicked that can be
used to respond to user click events.
The tree component uses a TreeModel defined in an application backing bean. The
TreeModel must contain a tree of DefaultMutableTreeNode instances. Each
DefaultMutableTreeNode instance encapsultes an IceUserObject. The IceUserObject is the
extension point for the application developer. The leaf attribute of the IceUserObject
defines the type of the tree node. By default the leaf attribute is false and tree nodes will be
folders unless the leaf attribute is set to true.
The tree component can be used in cases where a hierarchical data structure must be
viewed and navigated. It is typically used for menu-style applications, where the user
selects a tree node and the application responds with an action related to the selected node.
Example
<ice:tree
id="myTree"
value="#{treeBean.model}"
hideRootNode="false"
action="#{treeBean.treeSelectionAction}"
binding="#{treeBean.treeComponent}"
/>
Tag Summary
tag-name: <ice:tree>
tag-class: com.icesoft.faces.component.tree.TreeTag
component-class: com.icesoft.faces.component.tree.Tree
component-type: com.icesoft.faces.TreeView
component-family: com.icesoft.faces.TreeView
renderer-class: com.icesoft.faces.component.tree.TreeRenderer
renderer-type: com.icesoft.faces.View
Tag Information
Tag Class com.icesoft.faces.component.tree.TreeTag
TagExtraInfo Class None
Body Content JSP
Display Name None
Attributes
Require Reques
Name Type Description
d t-time
action false false java.lang.Stri MethodBinding
ng
representing the
application action to
invoke when this
component is activated by
the user. The expression
must evaluate to a either a
String or a public method
that takes no parameters,
and returns a String (the
logical outcome) which is
passed to the
NavigationHandler for
this application.
actionListener false false java.lang.Stri MethodBinding
ng
representing an action
listener method that will
be notified when this
component is activated by
the user. The expression
must evaluate to a public
method that takes an
ActionEvent parameter,
with a return type of void.
binding false false java.lang.Stri The value binding
ng
expression linking this
component to a property
in a backing bean
documentImage false false java.lang.Stri
ng
iceTree
iceTreeRow
value false false java.lang.Stri Sets the component's
ng
model value, which must
be a JSF value binding
expression to an
implementation of the
"javax.swing.tree.TreeMo
del" interface.
var false false java.lang.Stri Name of a request-scope
ng
attribute under which the
model data for the row
selected by the current
value of the "rowIndex"
property (i.e. also the
current value of the
"rowData" property) will
be exposed.
Variables
No Variables Defined.
Overview
Library Tag Help
FRAMES NO FRAMES All Tags
Output Generated by Tag Library Documentation Generator. Java, JSP, and JavaServer Pages are
trademarks or registered trademarks of Sun Microsystems, Inc. in the US and other countries. Copyright
2002-4 Sun Microsystems, Inc. 4150 Network Circle Santa Clara, CA 95054, U.S.A. All Rights Reserved.
Tag Information
Tag Class com.icesoft.faces.component.tree.TreeNodeTag
TagExtraInfo Class None
Body Content JSP
Display Name None
Attributes
Request-
Name Required Type Description
time
binding false false java.lang.String The value binding expression linking
this component to a property in a
backing bean
id false false java.lang.String The component identifier for this
component. This value must be
unique within the closest parent
component that is a naming
container.
rendered false false java.lang.String Flag indicating whether or not this
component should be rendered
(during Render Response Phase), or
processed on any subsequent form
submit.
Variables
No Variables Defined.
Overview
Library Tag Help
FRAMES NO FRAMES All Tags
Output Generated by Tag Library Documentation Generator. Java, JSP, and JavaServer Pages are
trademarks or registered trademarks of Sun Microsystems, Inc. in the US and other countries. Copyright
2002-4 Sun Microsystems, Inc. 4150 Network Circle Santa Clara, CA 95054, U.S.A. All Rights Reserved.