Sean,
 
Could you clarify which Listener I should use for tree2. I want to get the description of the Document node/leaf of the Tree(2).
 
I have in my JSP;
 
<h:commandLink immediate="true" styleClass="document" actionListener="#{loanSelectionTreeActionListener.processEvent}" >
 
 
and backing class;
 
public class LoanSelectionTreeActionListener implements ActionListener {
 
    public LoanSelectionTreeActionListener() {
       
    }
   
    public void processAction(ActionEvent event) throws AbortProcessingException {
        System.out.println(">>>>> selectedLoan");
 
        //UIComponent comp = actionEvent.getComponent();
        //HtmlTree tree = (HtmlTree) comp.getParent().getParent();
        //System.out.println(">>>>> tree = " + tree);
        //TreeNodeBase node = tree.getNode();
    }
}
 
 
However this throws an exception;
 
17:28:53,221 INFO  [STDOUT] >>>>> LoanServiceBean getHierarchy
17:28:53,251 ERROR [MethodBindingImpl] Exception while invoking _expression_ #{loa
nSelectionTreeActionListener.processEvent}
java.lang.NoSuchMethodException: com.fortytwoobjects.mangroup.jsf.LoanSelectionT
reeActionListener.processEvent(javax.faces.event.ActionEvent)
        at java.lang.Class.getMethod(Class.java:986)
        at org.apache.myfaces.el.MethodBindingImpl.invoke(MethodBindingImpl.java
:127)
        at javax.faces.component.UICommand.broadcast(UICommand.java:86)
        at org.apache.myfaces.custom.tree2.UITreeData.broadcast(UITreeData.java:
116)
        at javax.faces.component.UIViewRoot._broadcastForPhase(UIViewRoot.java:1
10)
        at javax.faces.component.UIViewRoot.processDecodes(UIViewRoot.java:152)
        at org.apache.myfaces.lifecycle.LifecycleImpl.applyRequestValues(Lifecyc
leImpl.java:177)
        at org.apache.myfaces.lifecycle.LifecycleImpl.execute(LifecycleImpl.java
:87)
        at javax.faces.webapp.FacesServlet.service(FacesServlet.java:109)
        at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(Appl
icationFilterChain.java:237)
        at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationF
ilterChain.java:157)
 
Internet communications are not secure and therefore NOTiFY
does not accept legal responsibility for the contents of this message.
Although NOTiFY operates anti-virus programmes, it does not
accept responsibility for any damage whatsoever that is caused by
viruses being passed.  Any views or opinions presented are solely those
of the author and do not necessarily represent those of NOTiFY. 
Replies to this email may be monitored by NOTiFY for operational or
business reasons.
 
 
----- Original Message -----
From: "Sean Schofield" <[EMAIL PROTECTED]>
To: "MyFaces Discussion" <[email protected]>
Sent: Thursday, March 24, 2005 3:10 PM
Subject: Re: selectionlistener for tree2

Jon,

Here is a portion of a previous email I sent on the subject.  Let me
know if there is still any confusion.

sean

[snip]

I've added a isNodeSelected() method to the tree so that it can be
accessed via a
value binding _expression_.

All that is required (if you want to use this functionality) is to set
the action listener of the commandLink as in this JSP.

   <f:facet name="document">
     <h:panelGroup>
       <h:commandLink immediate="true" styleClass="document"
actionListener="#{t.setNodeSelected}" rendered="#{!t.nodeSelected}">
         <h:graphicImage value="/images/document.png" border="0"/>
         <h:outputText value="#{node.description}"/>
         <f:param name="docNum" value="#{node.identifier}"/>
       </h:commandLink>
       <h:commandLink immediate="true" styleClass="documentSelected"
actionListener="#{t.setNodeSelected}" rendered="#{t.nodeSelected}">
         <h:graphicImage value="/images/document.png" border="0"/>
         <h:outputText value="#{node.description}"/>
         <f:param name="docNum" value="#{node.identifier}"/>
       </h:commandLink>
     </h:panelGroup>
   </f:facet>

In fact the new tree is now even more powerful than the current tree
in this regard because you can control what constitutes node
selection.  So if you didn't want the selection of a branch node to be
counted as a node selection you now have that option.  Of course you
can always configure it to behave exactly the same as the current tree
if that is your wish (or ignore node selection entirely.)


[snip]

On Wed, 23 Mar 2005 16:47:43 -0800, Jon Travis <
[EMAIL PROTECTED]> wrote:
> I know there was some discussion on the -dev list about
> tree2 selection differences between tree1.
>
> One of the things that I'm liking about Tree1 is the
> ability to easily show which nodes are selected (they
> are bolded, hilighted, etc.)
>
> Does this feature exist in tree2?  I basically need
> the ability to set the selected tree nodes from the
> model & have them visually cued.
>
> -- Jon
>
>
> On Mar 18, 2005, at 10:34 AM, Borja Mart�n wrote:
>
> > Yes, I could get the selected node without problem. I paste the code
> > snippet in case it could help anyone else:
> > <x:tree2 id="secciones"
> >    value="#{sections.data}"
> >    var="section"
> >    varNodeToggler="t">
> >                          <f:facet name="section">
> >        <h:panelGroup>
> >            <f:facet name="expand">
> >                <h:graphicImage value="images/yellow-folder-open.png"
> > rendered="#{t.nodeExpanded}" border="0"/>
> >            </f:facet>
> >            <f:facet name="collapse">
> >                <h:graphicImage value="images/yellow-folder-closed.png"
> > rendered="#{!t.nodeExpanded}" border="0"/>
> >            </f:facet>
> >                      <h:commandLink
> > actionListener="#{sections.select}">
> >                <h:outputText value="#{section.description}" />
> >            </h:commandLink>
> >        </h:panelGroup>
> >    </f:facet>
> > </x:tree2>
> >
> > public void select(ActionEvent ae)
> > {
> >    UIComponent comp = ae.getComponent();
> >    HtmlTree tree = (HtmlTree) comp.getParent().getParent();
> >    TreeNodeBase node = tree.getNode();
> > }
> >
> > bye!
> >
> > Sean Schofield wrote:
> >
> >> x:treeselectionlistener is for tree.  Tree2 does not use that (as you
> >> have probably figured out already.)  Tree2 can use an action listener
> >> to indicate which node was selected (similar to what you were trying.)
> >>
> >> Do you have it working now?  It sounded like from your last message
> >> that you are ok with tree2 and node selection now.
> >>
> >> sean
> >>
> >> On Fri, 18 Mar 2005 19:13:47 +0100, Borja Mart�n <
[EMAIL PROTECTED]>
> >> wrote:
> >>
> >>> sorry, but the problem was that I had some html without the
> >>> f:verbatim
> >>> tags and that's why the actions weren't called
> >>>
> >>> Borja Mart�n wrote:
> >>>
> >>>
> >>>> hi,
> >>>> I was trying to get the tree2 working and have found that the
> >>>> TreeSelectionListener tag (x:treeselectionlistener) doesnt work, it
> >>>> says the component isnt a component tree. I tried to insert an
> >>>> actionListener like this #{sections.select} and created the method
> >>>> public void select(ActionEvent ae){..} in the sections bean, but it
> >>>> isnt called
> >>>> which should be the way to get the selected node using the tree2
> >>>> component?
> >>>>
> >>>> thanks in
> >
> >
> >
>
>

Reply via email to