You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@myfaces.apache.org by "Roger Lee, NOTiFY" <ro...@notify.co.uk> on 2005/03/29 00:07:43 UTC
Getting Description from tree Node
I have an ActionListener on a x:commandLink on a Document in a tree2. In the
backing class I have;
public void selectLoan(ActionEvent actionEvent) throws
AbortProcessingException {
UIComponent component = actionEvent.getComponent();
HtmlTree tree = (HtmlTree) component.getParent().getParent;
}
But I get a ClassCastException.
What is the correct way to get the description from the Tree2 node.
Thanks,
Roger Lee
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.
navigating from tree2
Posted by "Roger Lee, NOTiFY" <ro...@notify.co.uk>.
My ActionListener in a tree2 component calls a backing class and gets the
Description from the Tree Node.
LoanSelectionTree.jsp
<x:commandLink immediate="true" styleClass="document"
actionListener="#{loanSelectionTreeActionListener.selectLoan}" >
I then call a method in this Backing Class which returns "success".
public void selectLoan(ActionEvent actionEvent) throws
AbortProcessingException {
//System.out.println("********** LoanSelectionTreeActionListener
selectLoan");
UIComponent component = actionEvent.getComponent();
UIComponent parent = component.getParent().getParent();
HtmlTree tree = (HtmlTree) parent;
TreeNode node = tree.getNode();
nodeDescription = node.getDescription();
System.out.println(">>>>> LoanSelectionTreeActionListener selectLoan
node.getDescription = " + node.getDescription());
// To force return of "Success"
isTreeNodeSelected();
}
public String getNodeDescription() {
return (nodeDescription);
}
public String isTreeNodeSelected() {
if (nodeDescription != null) {
System.out.println(">>>>> LoanSelectionTreeActionListener
isTreeNodeSelected = " + FortyTwoObjectsConstants.SUCCESS_OUTCOME);
return FortyTwoObjectsConstants.SUCCESS_OUTCOME;
}
else {
System.out.println(">>>>> LoanSelectionTreeActionListener
isTreeNodeSelected = " + FortyTwoObjectsConstants.ERROR_OUTCOME);
return FortyTwoObjectsConstants.ERROR_OUTCOME;
}
}
in my Faces-Config I have;
<navigation-rule>
<from-view-id>/LoanSelectionTree.jsp</from-view-id>
<navigation-case>
<from-action>#{loanSelectionTreeActionListener.selectLoan}</from-action>
<from-outcome>success</from-outcome>
<to-view-id>/LoanEnquirySummary.jsp</to-view-id>
</navigation-case>
</navigation-rule>
I have also tried it with;
<from-action>#{loanSelectionTreeActionListener.isTreeNodeSelected}</from-action>
Either way it does not navigate to my "LoanEnquirySummary.jsp"
No errors thrown. Any suggestions?
Many thanks.
Roger Lee
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.
Re: Getting Description from tree Node
Posted by Rob Decker <ro...@objectsource.org>.
Actually it should be
UIComponent parent = component.getParent();
while (!(parent instanceof HtmlTree))
parent = parent.getParent();
----- Original Message -----
From: "Rob Decker" <ro...@objectsource.org>
To: "MyFaces Discussion" <my...@incubator.apache.org>; "Roger Lee,
NOTiFY" <ro...@notify.co.uk>
Sent: Monday, March 28, 2005 6:38 PM
Subject: Re: Getting Description from tree Node
> UIComponent parent = null;
> while (!(parent instanceof HTMLTree))
> parent = component.getParent();
>
> HtmlTree tree = (HtmlTree)parent;
>
>
> ----- Original Message -----
> From: "Roger Lee, NOTiFY" <ro...@notify.co.uk>
> To: "MyFaces Discussion" <my...@incubator.apache.org>
> Sent: Monday, March 28, 2005 5:07 PM
> Subject: Getting Description from tree Node
>
>
> >
> > I have an ActionListener on a x:commandLink on a Document in a tree2. In
> the
> > backing class I have;
> >
> > public void selectLoan(ActionEvent actionEvent) throws
> > AbortProcessingException {
> > UIComponent component = actionEvent.getComponent();
> >
> > HtmlTree tree = (HtmlTree) component.getParent().getParent;
> > }
> >
> > But I get a ClassCastException.
> >
> > What is the correct way to get the description from the Tree2 node.
> >
> > Thanks,
> >
> > Roger Lee
> >
> >
> > 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.
> >
> >
>
Re: Getting Description from tree Node
Posted by "Roger Lee, NOTiFY" <ro...@notify.co.uk>.
Rob,
I now realise that my ClassCastException was due to using;
import org.apache.myfaces.custom.tree.HtmlTree;
not
import org.apache.myfaces.custom.tree2.HtmlTree;
You did mean HtmlTree (not HTMLTree).
When I run you example I just get a continuous loop, as it appears not to be
finding an instance of HtmlTree.
Have I misunderstood something?
Thanks,
Roger Lee
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: "Rob Decker" <ro...@objectsource.org>
To: "MyFaces Discussion" <my...@incubator.apache.org>; "Roger Lee,
NOTiFY" <ro...@notify.co.uk>
Sent: Tuesday, March 29, 2005 12:38 AM
Subject: Re: Getting Description from tree Node
> UIComponent parent = null;
> while (!(parent instanceof HTMLTree))
> parent = component.getParent();
>
> HtmlTree tree = (HtmlTree)parent;
>
>
> ----- Original Message -----
> From: "Roger Lee, NOTiFY" <ro...@notify.co.uk>
> To: "MyFaces Discussion" <my...@incubator.apache.org>
> Sent: Monday, March 28, 2005 5:07 PM
> Subject: Getting Description from tree Node
>
>
>>
>> I have an ActionListener on a x:commandLink on a Document in a tree2. In
> the
>> backing class I have;
>>
>> public void selectLoan(ActionEvent actionEvent) throws
>> AbortProcessingException {
>> UIComponent component = actionEvent.getComponent();
>>
>> HtmlTree tree = (HtmlTree) component.getParent().getParent;
>> }
>>
>> But I get a ClassCastException.
>>
>> What is the correct way to get the description from the Tree2 node.
>>
>> Thanks,
>>
>> Roger Lee
>>
>>
>> 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.
>>
>>
>
>
Re: Getting Description from tree Node - Code Snippet
Posted by "Roger Lee, NOTiFY" <ro...@notify.co.uk>.
Just in case anyone is interested;
import javax.faces.component.UIComponent;
import javax.faces.event.AbortProcessingException;
import javax.faces.event.ActionEvent;
public class LoanSelectionTreeActionListener {
public LoanSelectionTreeActionListener() {
}
public void selectLoan(ActionEvent actionEvent) throws
AbortProcessingException {
System.out.println("********** LoanSelectionTreeActionListener
selectLoan");
UIComponent component = actionEvent.getComponent();
UIComponent parent = component.getParent().getParent();
HtmlTree tree = (HtmlTree) parent;
TreeNode node = tree.getNode();
System.out.println("********** LoanSelectionTreeActionListener
selectLoan node = " + node.getDescription());
}
}
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: "Rob Decker" <ro...@objectsource.org>
To: "MyFaces Discussion" <my...@incubator.apache.org>; "Roger Lee,
NOTiFY" <ro...@notify.co.uk>
Sent: Tuesday, March 29, 2005 12:38 AM
Subject: Re: Getting Description from tree Node
> UIComponent parent = null;
> while (!(parent instanceof HTMLTree))
> parent = component.getParent();
>
> HtmlTree tree = (HtmlTree)parent;
>
>
> ----- Original Message -----
> From: "Roger Lee, NOTiFY" <ro...@notify.co.uk>
> To: "MyFaces Discussion" <my...@incubator.apache.org>
> Sent: Monday, March 28, 2005 5:07 PM
> Subject: Getting Description from tree Node
>
>
>>
>> I have an ActionListener on a x:commandLink on a Document in a tree2. In
> the
>> backing class I have;
>>
>> public void selectLoan(ActionEvent actionEvent) throws
>> AbortProcessingException {
>> UIComponent component = actionEvent.getComponent();
>>
>> HtmlTree tree = (HtmlTree) component.getParent().getParent;
>> }
>>
>> But I get a ClassCastException.
>>
>> What is the correct way to get the description from the Tree2 node.
>>
>> Thanks,
>>
>> Roger Lee
>>
>>
>> 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.
>>
>>
>
>
Re: Getting Description from tree Node
Posted by Rob Decker <ro...@objectsource.org>.
UIComponent parent = null;
while (!(parent instanceof HTMLTree))
parent = component.getParent();
HtmlTree tree = (HtmlTree)parent;
----- Original Message -----
From: "Roger Lee, NOTiFY" <ro...@notify.co.uk>
To: "MyFaces Discussion" <my...@incubator.apache.org>
Sent: Monday, March 28, 2005 5:07 PM
Subject: Getting Description from tree Node
>
> I have an ActionListener on a x:commandLink on a Document in a tree2. In
the
> backing class I have;
>
> public void selectLoan(ActionEvent actionEvent) throws
> AbortProcessingException {
> UIComponent component = actionEvent.getComponent();
>
> HtmlTree tree = (HtmlTree) component.getParent().getParent;
> }
>
> But I get a ClassCastException.
>
> What is the correct way to get the description from the Tree2 node.
>
> Thanks,
>
> Roger Lee
>
>
> 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.
>
>