You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@myfaces.apache.org by ChrisAndCatharineMiller <cm...@happywombat.com> on 2005/04/06 12:16:35 UTC
tree nodes and actions
I have created a tree using the <x:tree> tag (no problem) and a listener using the <x:treeSelectionListener> tag (again no problem - I get events whenever I select a tree node.
The thing that I am struggling with is how to fire an Action when a user selects a tree node (the treeSelectionListener returns null so cannot return a String like an Action and the tree itself has no action attribute). I basically want to update the page when the user selects something in the tree - In my case the tree nodes represent product categories and when a node is selected I want to display the appropriate product data.
I'm sure that I'm missing something really obvious - I'm sure the tree tag wasn't just created to look pretty !
Any help would be appreciated.
Thanks,
Chris
Re: tree nodes and actions
Posted by Sean Schofield <se...@gmail.com>.
I believe this can be done in tree. Oliver is probably a better
person to help you out with that one. It can definitely be done in
tree2. See the simple tree2 example for details on how.
sean
On Apr 6, 2005 6:16 AM, ChrisAndCatharineMiller <cm...@happywombat.com> wrote:
>
>
>
> I have created a tree using the <x:tree> tag (no problem) and a listener
> using the <x:treeSelectionListener> tag (again no problem – I get events
> whenever I select a tree node.
>
>
>
> The thing that I am struggling with is how to fire an Action when a user
> selects a tree node (the treeSelectionListener returns null so cannot return
> a String like an Action and the tree itself has no action attribute). I
> basically want to update the page when the user selects something in the
> tree – In my case the tree nodes represent product categories and when a
> node is selected I want to display the appropriate product data.
>
>
>
> I'm sure that I'm missing something really obvious – I'm sure the tree tag
> wasn't just created to look pretty !
>
>
>
> Any help would be appreciated.
>
>
>
> Thanks,
>
>
>
> Chris
Re: tree nodes and actions (again)
Posted by Rob Decker <ro...@objectsource.org>.
It's not really an error to set an xml attribute equal to a string. I think action="string" is valid too.
----- Original Message -----
From: ChrisAndCatharineMiller
To: MyFaces Discussion
Sent: Friday, April 08, 2005 9:45 PM
Subject: Re: tree nodes and actions (again)
Apologies - a dumberror (it did not show up well on my monitor).
What I am a bit surprised about is that I did not get any error. Is there somewhere that I should be looking apart from the tomcat logs ?
Thanks,
Chris
----- Original Message -----
From: Rob Decker
To: MyFaces Discussion ; ChrisAndCatharineMiller
Sent: Friday, April 08, 2005 10:14 PM
Subject: Re: tree nodes and actions (again)
Maybe because you have a ) closing the expression instead of }.
----- Original Message -----
From: ChrisAndCatharineMiller
To: myfaces-user@incubator.apache.org
Sent: Thursday, April 07, 2005 10:59 PM
Subject: tree nodes and actions (again)
Following the previous response I am now using a tree2 rather than a tree.
Following the example I am using a command link to try to do something when an item is selected - the tree displays fine, but it just doesn't work when the command link is selected.
I have tried adding in a command button using exactly the same action and that works fine (which implies all my configuration is OK), but the command link itself doesn't even call the action. The JSP I am using is below, any help would be appreciated - its driving me nuts !
%@ taglib prefix="f" uri="http://java.sun.com/jsf/core" %>
<%@ taglib prefix="h" uri="http://java.sun.com/jsf/html" %>
<%@ taglib prefix="x" uri="http://myfaces.apache.org/extensions" %>
<!-- Form just to get command button to work-->
<h:form id="selectCategoryForm" >
<h:panelGroup id="body">
<!-- use clientSideToggle to use javascript for toggling-->
<x:tree2 value="#{categoryList.categories}" id="tree" var="node" varNodeToggler="t" clientSideToggle="true">
<f:facet name="category-folder">
<h:panelGroup>
<h:commandLink immediate="true" styleClass="boxText" action="#{productSearch.getProductsByCategoryAction)">
<h:outputText value="#{node.description}"/>
<f:param name="categoryId" value="#{node.identifier}"/>
</h:commandLink>
<!-- add in a command button as well, why does this work and not the link ? -->
<h:commandButton value="Go" action="#{productSearch.getProductsByCategoryAction}" type="submit"/>
<h:inputText id="categoryId" value="#{node.identifier}"/>
</h:panelGroup>
</f:facet>
</x:tree2>
</h:panelGroup>
</h:form>
Re: tree nodes and actions (again)
Posted by ChrisAndCatharineMiller <cm...@happywombat.com>.
Apologies - a dumberror (it did not show up well on my monitor).
What I am a bit surprised about is that I did not get any error. Is there somewhere that I should be looking apart from the tomcat logs ?
Thanks,
Chris
----- Original Message -----
From: Rob Decker
To: MyFaces Discussion ; ChrisAndCatharineMiller
Sent: Friday, April 08, 2005 10:14 PM
Subject: Re: tree nodes and actions (again)
Maybe because you have a ) closing the expression instead of }.
----- Original Message -----
From: ChrisAndCatharineMiller
To: myfaces-user@incubator.apache.org
Sent: Thursday, April 07, 2005 10:59 PM
Subject: tree nodes and actions (again)
Following the previous response I am now using a tree2 rather than a tree.
Following the example I am using a command link to try to do something when an item is selected - the tree displays fine, but it just doesn't work when the command link is selected.
I have tried adding in a command button using exactly the same action and that works fine (which implies all my configuration is OK), but the command link itself doesn't even call the action. The JSP I am using is below, any help would be appreciated - its driving me nuts !
%@ taglib prefix="f" uri="http://java.sun.com/jsf/core" %>
<%@ taglib prefix="h" uri="http://java.sun.com/jsf/html" %>
<%@ taglib prefix="x" uri="http://myfaces.apache.org/extensions" %>
<!-- Form just to get command button to work-->
<h:form id="selectCategoryForm" >
<h:panelGroup id="body">
<!-- use clientSideToggle to use javascript for toggling-->
<x:tree2 value="#{categoryList.categories}" id="tree" var="node" varNodeToggler="t" clientSideToggle="true">
<f:facet name="category-folder">
<h:panelGroup>
<h:commandLink immediate="true" styleClass="boxText" action="#{productSearch.getProductsByCategoryAction)">
<h:outputText value="#{node.description}"/>
<f:param name="categoryId" value="#{node.identifier}"/>
</h:commandLink>
<!-- add in a command button as well, why does this work and not the link ? -->
<h:commandButton value="Go" action="#{productSearch.getProductsByCategoryAction}" type="submit"/>
<h:inputText id="categoryId" value="#{node.identifier}"/>
</h:panelGroup>
</f:facet>
</x:tree2>
</h:panelGroup>
</h:form>
Re: tree nodes and actions (again)
Posted by Rob Decker <ro...@objectsource.org>.
Maybe because you have a ) closing the expression instead of }.
----- Original Message -----
From: ChrisAndCatharineMiller
To: myfaces-user@incubator.apache.org
Sent: Thursday, April 07, 2005 10:59 PM
Subject: tree nodes and actions (again)
Following the previous response I am now using a tree2 rather than a tree.
Following the example I am using a command link to try to do something when an item is selected - the tree displays fine, but it just doesn't work when the command link is selected.
I have tried adding in a command button using exactly the same action and that works fine (which implies all my configuration is OK), but the command link itself doesn't even call the action. The JSP I am using is below, any help would be appreciated - its driving me nuts !
%@ taglib prefix="f" uri="http://java.sun.com/jsf/core" %>
<%@ taglib prefix="h" uri="http://java.sun.com/jsf/html" %>
<%@ taglib prefix="x" uri="http://myfaces.apache.org/extensions" %>
<!-- Form just to get command button to work-->
<h:form id="selectCategoryForm" >
<h:panelGroup id="body">
<!-- use clientSideToggle to use javascript for toggling-->
<x:tree2 value="#{categoryList.categories}" id="tree" var="node" varNodeToggler="t" clientSideToggle="true">
<f:facet name="category-folder">
<h:panelGroup>
<h:commandLink immediate="true" styleClass="boxText" action="#{productSearch.getProductsByCategoryAction)">
<h:outputText value="#{node.description}"/>
<f:param name="categoryId" value="#{node.identifier}"/>
</h:commandLink>
<!-- add in a command button as well, why does this work and not the link ? -->
<h:commandButton value="Go" action="#{productSearch.getProductsByCategoryAction}" type="submit"/>
<h:inputText id="categoryId" value="#{node.identifier}"/>
</h:panelGroup>
</f:facet>
</x:tree2>
</h:panelGroup>
</h:form>
tree nodes and actions (again)
Posted by ChrisAndCatharineMiller <cm...@happywombat.com>.
Following the previous response I am now using a tree2 rather than a tree.
Following the example I am using a command link to try to do something when an item is selected - the tree displays fine, but it just doesn't work when the command link is selected.
I have tried adding in a command button using exactly the same action and that works fine (which implies all my configuration is OK), but the command link itself doesn't even call the action. The JSP I am using is below, any help would be appreciated - its driving me nuts !
%@ taglib prefix="f" uri="http://java.sun.com/jsf/core" %>
<%@ taglib prefix="h" uri="http://java.sun.com/jsf/html" %>
<%@ taglib prefix="x" uri="http://myfaces.apache.org/extensions" %>
<!-- Form just to get command button to work-->
<h:form id="selectCategoryForm" >
<h:panelGroup id="body">
<!-- use clientSideToggle to use javascript for toggling-->
<x:tree2 value="#{categoryList.categories}" id="tree" var="node" varNodeToggler="t" clientSideToggle="true">
<f:facet name="category-folder">
<h:panelGroup>
<h:commandLink immediate="true" styleClass="boxText" action="#{productSearch.getProductsByCategoryAction)">
<h:outputText value="#{node.description}"/>
<f:param name="categoryId" value="#{node.identifier}"/>
</h:commandLink>
<!-- add in a command button as well, why does this work and not the link ? -->
<h:commandButton value="Go" action="#{productSearch.getProductsByCategoryAction}" type="submit"/>
<h:inputText id="categoryId" value="#{node.identifier}"/>
</h:panelGroup>
</f:facet>
</x:tree2>
</h:panelGroup>
</h:form>