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



Reply via email to