You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@myfaces.apache.org by Gregg Bolinger <to...@embeddedthought.com> on 2004/12/21 23:25:36 UTC
Tree Node Selection Events
I can't seem to find any documentation on how to handle node selection
events with the Tree component. Does anyone have any information on
this? Thanks.
Gregg
Re: DefaultTreeModel: nodeStructureChanged + Tree Reloading
Posted by Oliver Rossmueller <ol...@tuxerra.com>.
David,
the tree adds itself to the list of model listeners, see method
HtmlTree.addToModelListeners().
Oliver
David Le Strat wrote:
>All,
>
>I have been trying to reflect changes on the tree
>after an action occurs in an action form. In my
>scenario, I am adding a node to the tree.
>
>My front uses the tree / tree table tags.
>
><h:form name="roleSelectManyCheckboxForm">
><x:selectManyCheckbox id="roleSelectManyCheckbox"
>value="#{roleActionForm.selectedRoles}"
>layout="spread" />
>
><x:tree id="tree"
> value="#{roleTreeTable.treeModel}"
> var="roleTreeItem"
> styleClass="tree"
> nodeClass="tree-node"
> headerClass="portlet-table-header"
> footerClass="portlet-table-footer"
> rowClasses="portlet-table-row1,
>portlet-table-row2"
> columnClasses="portlet-table-col1,
>portlet-table-col2"
> selectedNodeClass="tree-node-selected"
> expandRoot="true">
>
> <h:column>
> <f:facet name="header">
> <h:outputText
>value="#{roleMgtMessages['selectHeader']}" />
> </f:facet>
> <x:treeCheckbox for="roleSelectManyCheckbox"
>itemValue="#{roleTreeItem.fullPath}" />
> </h:column>
> <x:treeColumn>
> <f:facet name="header">
> <h:outputText
>value="#{roleMgtMessages['roleHierarchy']}" />
> </f:facet>
> <h:commandLink action="none">
> <h:outputText value="#{roleTreeItem.roleName}"
>/>
> <f:param name="addRoleToParam"
>value="#{roleTreeItem.fullPath}"/>
> <f:actionListener
>type="org.apache.jetspeed.portlets.security.rolemgt.AddRoleCommandLinkActionListener"
>/>
> </h:commandLink>
> </x:treeColumn>
>
>Upon click on the commandLink, the event is
>intercepted by AddRoleCommandLinkActionListener which
>in processAction set the node to add an element to and
>present a form to do so. In the new form, upon adding
>an element to the node, a RoleActionForm is invoked
>that adds the provided element to the selected node
>element.
>
>Until now, everything work well, I now resolve the
>tree table with the intent of refreshing the tree
>model. I have been stuck on this since.
>
>// Resolve the tree table.
>FacesContext facesContext =
>FacesContext.getCurrentInstance();
>VariableResolver vr =
>facesContext.getApplication().getVariableResolver();
>
>RoleTreeTable roleTree = (RoleTreeTable)
>vr.resolveVariable(facesContext,
>RoleTreeTable.ROLE_TREE_TABLE);
>
>roleTree.setTreeModel(SecurityApplicationUtils.buildRoleTreeModel());
>
>roleTree.getTreeModel().nodeStructureChanged(SecurityApplicationUtils.findTreeNode(roleTree,
> getParentRole().getFullPath()));
>
>I don't understand how any of the DefaultTreeModel
>change method are supposed to work. The
>nodeStructureChanged is invoked properly in this case
>but starts with a check for:
>
>if (listeners.isEmpty())
>{
> // nobody cares
> return;
>}
>
>where listeners is always empty.
>
>I feel like I am missing something basic here. How do
>listeners get added to the DefaultTreeModel? The
>DefaultTreeModel seem to have everything necessary to
>trigger tree changes, if only I could figure out what
>is the hook with the listeners.
>
>I am looking forward to your input.
>
>Regards,
>
>David Le Strat.
>
>
>
>
>__________________________________
>Do you Yahoo!?
>Read only the mail you want - Yahoo! Mail SpamGuard.
>http://promotions.yahoo.com/new_mail
>
>
--
Oliver Rossmueller
Software Engineer and IT-Consultant
Hamburg, Germany
http://www.rossmueller.com
DefaultTreeModel: nodeStructureChanged + Tree Reloading
Posted by David Le Strat <dl...@yahoo.com>.
All,
I have been trying to reflect changes on the tree
after an action occurs in an action form. In my
scenario, I am adding a node to the tree.
My front uses the tree / tree table tags.
<h:form name="roleSelectManyCheckboxForm">
<x:selectManyCheckbox id="roleSelectManyCheckbox"
value="#{roleActionForm.selectedRoles}"
layout="spread" />
<x:tree id="tree"
value="#{roleTreeTable.treeModel}"
var="roleTreeItem"
styleClass="tree"
nodeClass="tree-node"
headerClass="portlet-table-header"
footerClass="portlet-table-footer"
rowClasses="portlet-table-row1,
portlet-table-row2"
columnClasses="portlet-table-col1,
portlet-table-col2"
selectedNodeClass="tree-node-selected"
expandRoot="true">
<h:column>
<f:facet name="header">
<h:outputText
value="#{roleMgtMessages['selectHeader']}" />
</f:facet>
<x:treeCheckbox for="roleSelectManyCheckbox"
itemValue="#{roleTreeItem.fullPath}" />
</h:column>
<x:treeColumn>
<f:facet name="header">
<h:outputText
value="#{roleMgtMessages['roleHierarchy']}" />
</f:facet>
<h:commandLink action="none">
<h:outputText value="#{roleTreeItem.roleName}"
/>
<f:param name="addRoleToParam"
value="#{roleTreeItem.fullPath}"/>
<f:actionListener
type="org.apache.jetspeed.portlets.security.rolemgt.AddRoleCommandLinkActionListener"
/>
</h:commandLink>
</x:treeColumn>
Upon click on the commandLink, the event is
intercepted by AddRoleCommandLinkActionListener which
in processAction set the node to add an element to and
present a form to do so. In the new form, upon adding
an element to the node, a RoleActionForm is invoked
that adds the provided element to the selected node
element.
Until now, everything work well, I now resolve the
tree table with the intent of refreshing the tree
model. I have been stuck on this since.
// Resolve the tree table.
FacesContext facesContext =
FacesContext.getCurrentInstance();
VariableResolver vr =
facesContext.getApplication().getVariableResolver();
RoleTreeTable roleTree = (RoleTreeTable)
vr.resolveVariable(facesContext,
RoleTreeTable.ROLE_TREE_TABLE);
roleTree.setTreeModel(SecurityApplicationUtils.buildRoleTreeModel());
roleTree.getTreeModel().nodeStructureChanged(SecurityApplicationUtils.findTreeNode(roleTree,
getParentRole().getFullPath()));
I don't understand how any of the DefaultTreeModel
change method are supposed to work. The
nodeStructureChanged is invoked properly in this case
but starts with a check for:
if (listeners.isEmpty())
{
// nobody cares
return;
}
where listeners is always empty.
I feel like I am missing something basic here. How do
listeners get added to the DefaultTreeModel? The
DefaultTreeModel seem to have everything necessary to
trigger tree changes, if only I could figure out what
is the hook with the listeners.
I am looking forward to your input.
Regards,
David Le Strat.
__________________________________
Do you Yahoo!?
Read only the mail you want - Yahoo! Mail SpamGuard.
http://promotions.yahoo.com/new_mail
DefaultTreeModel: nodeStructureChanged + Tree Reloading
Posted by David Le Strat <dl...@yahoo.com>.
All,
I have been trying to reflect changes on the tree
after an action occurs in an action form. In my
scenario, I am adding a node to the tree.
My front uses the tree / tree table tags.
<h:form name="roleSelectManyCheckboxForm">
<x:selectManyCheckbox id="roleSelectManyCheckbox"
value="#{roleActionForm.selectedRoles}"
layout="spread" />
<x:tree id="tree"
value="#{roleTreeTable.treeModel}"
var="roleTreeItem"
styleClass="tree"
nodeClass="tree-node"
headerClass="portlet-table-header"
footerClass="portlet-table-footer"
rowClasses="portlet-table-row1,
portlet-table-row2"
columnClasses="portlet-table-col1,
portlet-table-col2"
selectedNodeClass="tree-node-selected"
expandRoot="true">
<h:column>
<f:facet name="header">
<h:outputText
value="#{roleMgtMessages['selectHeader']}" />
</f:facet>
<x:treeCheckbox for="roleSelectManyCheckbox"
itemValue="#{roleTreeItem.fullPath}" />
</h:column>
<x:treeColumn>
<f:facet name="header">
<h:outputText
value="#{roleMgtMessages['roleHierarchy']}" />
</f:facet>
<h:commandLink action="none">
<h:outputText value="#{roleTreeItem.roleName}"
/>
<f:param name="addRoleToParam"
value="#{roleTreeItem.fullPath}"/>
<f:actionListener
type="org.apache.jetspeed.portlets.security.rolemgt.AddRoleCommandLinkActionListener"
/>
</h:commandLink>
</x:treeColumn>
Upon click on the commandLink, the event is
intercepted by AddRoleCommandLinkActionListener which
in processAction set the node to add an element to and
present a form to do so. In the new form, upon adding
an element to the node, a RoleActionForm is invoked
that adds the provided element to the selected node
element.
Until now, everything work well, I now resolve the
tree table with the intent of refreshing the tree
model. I have been stuck on this since.
// Resolve the tree table.
FacesContext facesContext =
FacesContext.getCurrentInstance();
VariableResolver vr =
facesContext.getApplication().getVariableResolver();
RoleTreeTable roleTree = (RoleTreeTable)
vr.resolveVariable(facesContext,
RoleTreeTable.ROLE_TREE_TABLE);
roleTree.setTreeModel(SecurityApplicationUtils.buildRoleTreeModel());
roleTree.getTreeModel().nodeStructureChanged(SecurityApplicationUtils.findTreeNode(roleTree,
getParentRole().getFullPath()));
I don't understand how any of the DefaultTreeModel
change method are supposed to work. The
nodeStructureChanged is invoked properly in this case
but starts with a check for:
if (listeners.isEmpty())
{
// nobody cares
return;
}
where listeners is always empty.
I feel like I am missing something basic here. How do
listeners get added to the DefaultTreeModel? The
DefaultTreeModel seem to have everything necessary to
trigger tree changes, if only I could figure out what
is the hook with the listeners.
I am looking forward to your input.
Regards,
David Le Strat.
__________________________________
Do you Yahoo!?
Read only the mail you want - Yahoo! Mail SpamGuard.
http://promotions.yahoo.com/new_mail
Re: Tree Node Selection Events
Posted by Gregg Bolinger <to...@embeddedthought.com>.
Thanks a lot. That is a big help.
Gregg
Adrien FOURES wrote:
><x:tree id="tree1" .....
>
><x:treeSelectionListener type="dosmed.arbre.Tree1Action"/> // build a class
>which implement treeSelectionListener(catche event when you select a node)
>
><x:iconProvider type="dosmed.arbre.TreeIcon"/> // build a class which
>implement iconProvider (update image of a node)
>
></x:tree>
>
>
>
>public class Tree1Action implements TreeSelectionListener{
>
> public Tree1Action(){
> super();
> this.init();
> }
>
> public void init(){
> System.out.println("init.........");
>
>// build your tree
>
> }
>
>
> public void valueChanged(TreeSelectionEvent event){
>
> DefaultMutableTreeNode selectNode = (DefaultMutableTreeNode)
>event.getNewSelectionPath().getLastPathComponent(); // it's tha node which
>is selected in interface.
>
>
>}
>
>
>i can not find any documentation too , so i have download the source code,
>and i try to understand it.
>
>good luck to you.
>
>
>
>
Re: Tree Node Selection Events
Posted by Adrien FOURES <af...@sigems.fr>.
<x:tree id="tree1" .....
<x:treeSelectionListener type="dosmed.arbre.Tree1Action"/> // build a class
which implement treeSelectionListener(catche event when you select a node)
<x:iconProvider type="dosmed.arbre.TreeIcon"/> // build a class which
implement iconProvider (update image of a node)
</x:tree>
public class Tree1Action implements TreeSelectionListener{
public Tree1Action(){
super();
this.init();
}
public void init(){
System.out.println("init.........");
// build your tree
}
public void valueChanged(TreeSelectionEvent event){
DefaultMutableTreeNode selectNode = (DefaultMutableTreeNode)
event.getNewSelectionPath().getLastPathComponent(); // it's tha node which
is selected in interface.
}
i can not find any documentation too , so i have download the source code,
and i try to understand it.
good luck to you.