Using contectMenu with richTree?
allforjava.allforjava.aol.in Feb 11, 2009 7:07 AMDear replier,
I'hv tried to navigate next-page (Edit, with contextMenu action=)on tree node selection. I'm unable to use the rich:componentControl, with rich:contextMenu code outside the rich:tree.
However the contextMenu code works within/inside the rich:treeNode works, partially i.e the action (to Edit page) is not invoked for the nodes 2 and/or 3 hierarchy.
Any help/clue is appreciated. Thank you in advance.
CODE:
TasksTree.xhtml
`
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<ui:composition xmlns="http://www.w3.org/1999/xhtml"
xmlns:s="http://jboss.com/products/seam/taglib"
xmlns:ui="http://java.sun.com/jsf/facelets"
xmlns:a="http://richfaces.org/a4j"
xmlns:f="http://java.sun.com/jsf/core"
xmlns:h="http://java.sun.com/jsf/html"
xmlns:rich="http://richfaces.org/rich"
template="layout/template.xhtml">
<ui:define name="body">
<a:form id="tasksSearch" styleClass="edit">
<!-- CONTEXT MENU
<rich:contextMenu attached="true" id="treeMenu" submitMode="ajax">
<rich:menuItem>
Selected Task ID:<b>{taskId}</b>
</rich:menuItem>
<rich:menuItem action="Edit">
<h:graphicImage value="/img/edit.gif" border="0"></h:graphicImage>
<h:outputText value="#{resourceBundle.labels['list.edit']}"></h:outputText>
<a:actionparam name="tasksId" value="{tasksId}"/>
</rich:menuItem>
</rich:contextMenu>
-->
<!-- TREE -->
<rich:panel>
<rich:tree id="tasksTree" switchType="client">
<rich:recursiveTreeNodesAdaptor roots="#{tasksHome.instance.tasks == null? tasksHome.instance : tasksHome.instance.tasks}" var="taskItem" nodes="#{taskItem.taskses}">
<rich:treeNode icon="/img/down.gif">
<h:outputText value="#{taskItem.id}"/>
<!-- Inner contextMenu -->
<rich:contextMenu event="oncontextmenu" attached="true" id="treeMenu" submitMode="ajax">
<rich:menuItem>
Selected Task ID:<b>#{taskItem.id}</b>
</rich:menuItem>
<rich:menuItem action="Edit" limitToList="true">
<h:graphicImage value="/img/edit.gif" border="0"></h:graphicImage>
<h:outputText value="#{resourceBundle.labels['list.edit']}"></h:outputText>
<f:param name="tasksId" value="#{taskItem.id}"/>
</rich:menuItem>
</rich:contextMenu>
<!-- Inner contextMenu -->
</rich:treeNode>
</rich:recursiveTreeNodesAdaptor>
<!-- ComponentControl within TREE
<rich:componentControl event="onSelected" attachTo="tasksTree" for="treeMenu" operation="show">
<f:param name="taskId" value="#{taskItem.id}"/>
</rich:componentControl>
-->
</rich:tree>
</rich:panel>
</a:form>
</ui:define>
</ui:composition>
`
TaskTree.page.xml
`
<?xml version="1.0" encoding="UTF-8"?>
<page xmlns="http://jboss.com/products/seam/pages"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://jboss.com/products/seam/pages http://jboss.com/products/seam/pages-2.0.xsd">
<param name="tasksId" value="#{tasksHome.tasksId}"/>
<param name="taskId"/>
<navigation from-action="Edit">
<end-conversation />
<redirect view-id="/TasksEdit.xhtml" />
</navigation>
</page>
`
I'hv tried to navigate next-page (Edit, with contextMenu action=)on tree node selection. I'm unable to use the rich:componentControl, with rich:contextMenu code outside the rich:tree.
However the contextMenu code works within/inside the rich:treeNode works, partially i.e the action (to Edit page) is not invoked for the nodes 2 and/or 3 hierarchy.
Any help/clue is appreciated. Thank you in advance.
CODE:
TasksTree.xhtml
`
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<ui:composition xmlns="http://www.w3.org/1999/xhtml"
xmlns:s="http://jboss.com/products/seam/taglib"
xmlns:ui="http://java.sun.com/jsf/facelets"
xmlns:a="http://richfaces.org/a4j"
xmlns:f="http://java.sun.com/jsf/core"
xmlns:h="http://java.sun.com/jsf/html"
xmlns:rich="http://richfaces.org/rich"
template="layout/template.xhtml">
<ui:define name="body">
<a:form id="tasksSearch" styleClass="edit">
<!-- CONTEXT MENU
<rich:contextMenu attached="true" id="treeMenu" submitMode="ajax">
<rich:menuItem>
Selected Task ID:<b>{taskId}</b>
</rich:menuItem>
<rich:menuItem action="Edit">
<h:graphicImage value="/img/edit.gif" border="0"></h:graphicImage>
<h:outputText value="#{resourceBundle.labels['list.edit']}"></h:outputText>
<a:actionparam name="tasksId" value="{tasksId}"/>
</rich:menuItem>
</rich:contextMenu>
-->
<!-- TREE -->
<rich:panel>
<rich:tree id="tasksTree" switchType="client">
<rich:recursiveTreeNodesAdaptor roots="#{tasksHome.instance.tasks == null? tasksHome.instance : tasksHome.instance.tasks}" var="taskItem" nodes="#{taskItem.taskses}">
<rich:treeNode icon="/img/down.gif">
<h:outputText value="#{taskItem.id}"/>
<!-- Inner contextMenu -->
<rich:contextMenu event="oncontextmenu" attached="true" id="treeMenu" submitMode="ajax">
<rich:menuItem>
Selected Task ID:<b>#{taskItem.id}</b>
</rich:menuItem>
<rich:menuItem action="Edit" limitToList="true">
<h:graphicImage value="/img/edit.gif" border="0"></h:graphicImage>
<h:outputText value="#{resourceBundle.labels['list.edit']}"></h:outputText>
<f:param name="tasksId" value="#{taskItem.id}"/>
</rich:menuItem>
</rich:contextMenu>
<!-- Inner contextMenu -->
</rich:treeNode>
</rich:recursiveTreeNodesAdaptor>
<!-- ComponentControl within TREE
<rich:componentControl event="onSelected" attachTo="tasksTree" for="treeMenu" operation="show">
<f:param name="taskId" value="#{taskItem.id}"/>
</rich:componentControl>
-->
</rich:tree>
</rich:panel>
</a:form>
</ui:define>
</ui:composition>
`
TaskTree.page.xml
`
<?xml version="1.0" encoding="UTF-8"?>
<page xmlns="http://jboss.com/products/seam/pages"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://jboss.com/products/seam/pages http://jboss.com/products/seam/pages-2.0.xsd">
<param name="tasksId" value="#{tasksHome.tasksId}"/>
<param name="taskId"/>
<navigation from-action="Edit">
<end-conversation />
<redirect view-id="/TasksEdit.xhtml" />
</navigation>
</page>
`