Expanding an af:tree node by clicking onto its label
Dear all,
I am ussing af:tree same as in this link.
http://www.oracle.com/technology/products/jdev/tips/fnimphius/js_disclose_tree_path.html
But may af:tree still can't expend clicking on node label.
I am using jdeve11.1.1.2.0, here is my code.
<af:resource type="javascript" >
function expandNode(event){
var _tree = event.getSource();
rwKeySet = event.getAddedSet();
var firstRowKey;
for(rowKey in rwKeySet){
firstRowKey = rowKey;
// we are interested in the first hit, so break out here
break;
if (_tree.isPathExpanded(firstRowKey)){
_tree.setDisclosedRowKey(firstRowKey,false);
else{
_tree.setDisclosedRowKey(firstRowKey,true);
</af:resource>
<af:tree id="sTree" value="#{MenuGenerator.treeModel}" var="node"
expandAllEnabled="false" styleClass="stree" >
<f:facet name="nodeStamp">
<af:outputText value="#{node.name}" />
</f:facet>
<af:clientListener method="expandNode" type="selection"/>
</af:tree>
With Regards,
WP
hi Frank,
i get it too. but behaviour is different as i thought.
lets say i click on one of the node to expand it.
then i click on it again to collapse.
but i can't do it like this because my focus is still on that node.
i mean when i click on one node to expand/collapse then i click on it again to expand/collapse.
is it possible? and how to achieve this?
With Regards,
WP
Similar Messages
-
Expand tree node by clicking onto the node label
I have followed this example to expand the nodes with a clic on the tree :
[http://www.oracle.com/technetwork/developer-tools/adf/learnmore/20-expand-tree-node-from-label-169156.pdf]
My code:
JSPX:
<af:resource type="javascript" source="js/glasspane.js"/>
<af:tree value="#{bindings.OpcionesPadreView1.treeModel}" var="node"
rowSelection="single" id="t1" partialTriggers=":::cbNuevCpta"
binding="#{pageFlowScope.GestionDocumentos.t1}"
selectionListener="#{bindings.OpcionesPadreView1.treeModel.makeCurrent}">
<f:facet name="nodeStamp">
<af:commandImageLink text="#{node.Gesdopcach}" id="ot1"
action="#{bindings.LoadDir.execute}"
actionListener="#{bindings.LoadFile.execute}"
icon="/images/GestionDocumentos/folder20x20.png"
partialSubmit="true">
</af:commandImageLink>
</f:facet>
<af:clientListener method="expandTree" type="selection"/>
</af:tree>
Js:
function expandTree(evt) {
alert('In');
var tree = event.getSource();
rwKeySet = event.getAddedSet();
var firstRowKey;
for (rowKey in rwKeySet) {
firstRowKey = rowKey;
if (tree.isPathExpanded(firstRowKey)) {
tree.setDisclosedRowKey(firstRowKey, false);
}else {
tree.setDisclosedRowKey(firstRowKey, true);
When i clic on the labels the tree doesn't expand, the alert also is not shown. The problem could be the <af:resource>, but i have this tag in all my pages and all javascripts work. I also changed the commandLink with an outputText, but doesn't work.
Edited by: Miguel Angel on 21/06/2012 12:53 PMAt least the call the javascript works, but this line doesn't work, anybody know why?:
rwKeySet = evt.getAddedSet(); -
What event is called when the handle next to a tree node is clicked
Hi,
I have a JTree...and the nodes in the tree have a little handle next to them. When i click on the handle, the children of that node, are shown below (as expected). However, what event occurs before the treeExpanded event is fired?? it seems like something happens just before it.
thanksPost your code, I dont think any event except treeExpanded is fired.
-
How to find the coordinates of a mouse click in a Tree node ?
Hello
I have a JTree that have few nodes. The nodes contain an icon and a label (using custom cell renderer) and I want to receive right clicks on the icon and show a popup menu.
The problem is I can only get the right click on the whole tree node, not only the icon.
I tried two approaches:
1. register the mouse listener directly with the icon in the cell renderer. That doesnt work since the events received by the tree node do not propagate to its sub-components.
2. Register the event with the JTree itself and then try to find which part of the tree node was clicked (see if it was within the coordinates of the icon).
But I cant get the node's coordinates or width.
I tried using SwingUtilities.convertPoint or SwingUtilities.ConvertMouseEvent but it just doesnt work with DefaultMutableTreeNode.
Any ideas how to do it ?user11973359 wrote:
1. register the mouse listener directly with the icon in the cell renderer. That doesnt work since the events received by the tree node do not propagate to its sub-components.No, it doesn't work because a renderer isn't added to any component hierarchy. It isn't in any way a 'sub-component'.
Read about editor and renderer concepts in the Oracle tutorial on How to Use Tables.
user11973359 wrote:
2. Register the event with the JTree itself and then try to find which part of the tree node was clicked (see if it was within the coordinates of the icon).
But I cant get the node's coordinates or width.<tt>getPathForLocation(...) </tt>in conjunction with<tt> getPathBounds(...)</tt>.
db -
Attaching an event to a tree node
Hi there, hope to trigger a simple event when a tree node is click such as
<?xml version="1.0" encoding="utf-8"?>
<mx:Application
xmlns:mx="http://www.adobe.com/2006/mxml" layout="absolute">
<mx:XML id="treeData" xmlns="">
<root>
<node label="Section 1" >
<node label="Section 1-1" >
<node label="Section 1-1-1" click="lbl1.text='section 1-1-1';" />
<node label="Section 1-1-2" click="lbl1.text='section 1-1-2';"/>
<node label="Section 1-1-3">
<node label="Section 1-1-3-1" />
<node label="Section 1-1-3-2" />
</node>
<node label="Section 1-1-4" />
</node>
<node label="Section 1-2" >
<node label="Section 1-2-1" />
<node label="Section 1-2-2" />
</node>
</node>
<node label="Section 2" >
<node label="Section 2-1" >
<node label="Section 2-1" />
</node>
</node>
</root>
</mx:XML>
<mx:Tree width="246" left="10" top="10" id="tree" labelField="@label" dataProvider="{treeData.node}" height="540"/>
<mx:Label id="lbl1" x="395" y="155" text="Label1" width="151" />
</mx:Application>
The tree and its children were rendered properly on screen but clicking the relevant nodes didn't trigger the event. Please advise.
Regards
I FI didn't see a click handler in your code either. Try adding itemClick
though so you don't see clicks on scrollbars.
<mx:Tree width="246" left="10" top="10" id="tree" labelField="@label"
dataProvider="{treeData.node}" height="540" itemClick="trace(event)" / -
Htmlb:tree differentiate between nodeclick and tree node expander click
Hi,
how can i differentiate between nodeclick and tree node expander (to get to its children) click in my event processing in htmlb:tree element.
<u><b>What i am trying to achieve?</b></u>
Onload just load root node and its immediate children.
On node expand get the children of the current node and modify htmlb:tree table2 with additional node inofs.
on node click call some client function.
But my issue is that i am not able to differentiate between node expander click and node click in my event handling. Any help on this is appreciated.
(I am not using MVC)
Thanks in advance.
Regards
Raja
Message was edited by: Durairaj Athavan RajaAfter reading your weblog I think I understand better. I did some testing with my example. I am using the toggle = "true", so that the page returns to the server each time an expander is selected.
<htmlb:tree id = "myTree1"
height = "75%"
toggle = "true"
title = "<b><otr>EQI Reporting Tree</otr></b>"
width = "90%"
onTreeClick = "myTreeClick"
table = "<%= application->selection_model->itview %>" >
</htmlb:tree>
However I have not added any coding in my event handler to respond to the expander event. I only respond to myTreeClick (which loads some data for the given selection). The BSP tree element itself must be doing the hard work for me.
if event_id cs 'tr_myTree1'.
data: tree_event type ref to cl_htmlb_event_tree.
tree_event ?= htmlb_event.
if tree_event->server_event = 'myTreeClick'.
clear appl->message1.
appl->selection_model->get_chart_data( appl = appl
node = tree_event->node ).
endif.
endif.
I pass my entire tree defintion to the element. It appears that it only sends visible nodes to be rendered. When the expander is selected, I don't have to do anything, the tree re-renders with only the newly visible rows.
I tested and turned off the toggle (toggle = "false") and my page took forever to load because it was sending all the nodes to the frontend on the first load. -
How to trigger an ActionListener in different class on click of a tree node
Hi guyz,
There are three panels inside my main Frame
-->TopPanel,MiddlePanel and BottomPanel. I have a tree structure inside a panel. This panel along with couple more panels is in MiddlePanel. My main class is "mainClass.java". Inside that i have an actionListener for a specific button. I need to trigger that actionListener when i click one of the tree nodes in the panel i specified before. The problem is that my MiddlePanel is itself a different ".java" file which is being called in my "mainClass" when a specific button is clicked. There are different buttons in my "mainClass" file and for each one i am creating different MiddlePanels depending on the buttons clicked.
So, if i click the tree node, i need to remove the MiddlePanel and recreate the MiddlePanel(One that will be created when a different button in the mainClass file is clicked). i.e., i need to trigger the actionListener for that corresponding button. Is there a way to do it?use this code to call different panel by selecting tree node.....ok
import javax.swing.*;
import javax.swing.tree.*;
import java.awt.*;
import java.sql.SQLException;
import javax.swing.event.*;
class MainTree extends JFrame
private static final long serialVersionUID = 1L;
CardLayout cl = new CardLayout();
JPanel panel = new JPanel(cl);
public MainTree() throws Exception
JPanel blankPanel = new JPanel();
blankPanel.setBorder(BorderFactory.createTitledBorder("Blank Panel"));
panel.add(blankPanel,"0");
panel.add(blankPanel,BorderLayout.CENTER);
panel.setPreferredSize(new Dimension(800, 100));
setSize(1000, 700);
setLocationRelativeTo(null);
setDefaultCloseOperation(EXIT_ON_CLOSE);
// getContentPane().setLayout(new GridLayout(1,2));
getContentPane().setLayout(new BorderLayout());
ConfigTree test = new ConfigTree();
DefaultMutableTreeNode mainTree = (DefaultMutableTreeNode)test.buildTree();
JTree tree = new JTree(mainTree);
tree.setCellRenderer(new DefaultTreeCellRenderer(){
private static final long serialVersionUID = 1L;
public Component getTreeCellRendererComponent(JTree tree,Object value,
boolean sel,boolean expanded,boolean leaf,int row,boolean hasFocus){
JLabel lbl = (JLabel)super.getTreeCellRendererComponent(tree,value,sel,expanded,leaf,row,hasFocus);
NodeWithID node = (NodeWithID)((DefaultMutableTreeNode)value).getUserObject();
if(node.icon != null)lbl.setIcon(node.icon);
return lbl;
getContentPane().add(new JScrollPane(tree));
loadCardPanels((DefaultMutableTreeNode)((DefaultTreeModel)tree.getModel()).getRoot());
getContentPane().add(panel,BorderLayout.EAST);
getContentPane().add(blankPanel,BorderLayout.WEST);
// getContentPane().add(panel);
tree.addTreeSelectionListener(new TreeSelectionListener(){
public void valueChanged(TreeSelectionEvent tse){
NodeWithID node =(NodeWithID)((DefaultMutableTreeNode)((TreePath)tse.getPath())
.getLastPathComponent()).getUserObject();
if(node.nodePanel != null)
String cardLayoutID = node.ID;
cl.show(panel,cardLayoutID);
cl.show(panel,"0");
public void loadCardPanels(DefaultMutableTreeNode dmtn)
for(int x = 0; x < dmtn.getChildCount(); x++)
if(((DefaultMutableTreeNode)dmtn.getChildAt(x)).isLeaf() == false)
loadCardPanels((DefaultMutableTreeNode)dmtn.getChildAt(x));
NodeWithID node = (NodeWithID)((DefaultMutableTreeNode)dmtn.getChildAt(x)).getUserObject();
if(node.nodePanel != null)
String cardLayoutID = node.ID;
panel.add(cardLayoutID,node.nodePanel);
public static void main(String[] args) throws Exception{new MainTree().setVisible(true);}
class ConfigTree
public Object buildTree() throws Exception
NodeWithID n0 = new NodeWithID("HelpDesk","");
NodeWithID n1 = new NodeWithID("Administrator",n0.nodeName);
NodeWithID n2 = new NodeWithID("Report Form",n1.nodeName,new Tree().getContentPane());
NodeWithID n3 = new NodeWithID("Create User",n2.nodeName,new JPanel());
NodeWithID n4 = new NodeWithID("Unlock User",n2.nodeName,new unlockui().getContentPane());
NodeWithID n5 = new NodeWithID("List User",n2.nodeName,new JPanel());
NodeWithID n6 = new NodeWithID("Assign Role",n2.nodeName,new AssignRole());
NodeWithID n9 = new NodeWithID("Operator",n1.nodeName,new JPanel());
NodeWithID n10 = new NodeWithID("Create Ticket",n9.nodeName,new JPanel());
NodeWithID n11 = new NodeWithID("My Ticket",n9.nodeName,new JPanel());
NodeWithID n12 = new NodeWithID("All Ticket",n9.nodeName,new JPanel());
NodeWithID n13 = new NodeWithID("Event Viewer",n1.nodeName,new JPanel());
DefaultMutableTreeNode top = new DefaultMutableTreeNode(n0);
DefaultMutableTreeNode branch1 = new DefaultMutableTreeNode(n1);
top.add(branch1);
DefaultMutableTreeNode node1_b1 = new DefaultMutableTreeNode(n2);
DefaultMutableTreeNode n1_node1_b1 = new DefaultMutableTreeNode(n3);
DefaultMutableTreeNode n2_node1_b1 = new DefaultMutableTreeNode(n4);
DefaultMutableTreeNode n3_node1_b1 = new DefaultMutableTreeNode(n5);
DefaultMutableTreeNode n4_node1_b1 = new DefaultMutableTreeNode(n6);
branch1.add(node1_b1);
branch1.add(n1_node1_b1);
branch1.add(n2_node1_b1);
branch1.add(n3_node1_b1);
branch1.add(n4_node1_b1);
DefaultMutableTreeNode node4_b1 = new DefaultMutableTreeNode(n9);
DefaultMutableTreeNode n1_node4_b1 = new DefaultMutableTreeNode(n10);
DefaultMutableTreeNode n2_node4_b1 = new DefaultMutableTreeNode(n11);
DefaultMutableTreeNode n3_node4_b1 = new DefaultMutableTreeNode(n12);
node4_b1.add(n1_node4_b1);
node4_b1.add(n2_node4_b1);
node4_b1.add(n3_node4_b1);
DefaultMutableTreeNode node5_b1 = new DefaultMutableTreeNode(n13);
branch1.add(node1_b1);
branch1.add(node4_b1);
branch1.add(node5_b1);
return top;
class NodeWithID
String nodeName;
String ID;
JPanel nodePanel;
ImageIcon icon;
public NodeWithID(String nn,String parentName)
nodeName = nn;
ID = parentName+" - "+nodeName;
public NodeWithID(String nn,String parentName,Container container)
this(nn,parentName);
nodePanel = (JPanel) container;
nodePanel.setBorder(BorderFactory.createTitledBorder(ID + " Panel"));
public NodeWithID(String nn,String parentName,JPanel p, ImageIcon i)
this(nn,parentName,p);
icon = i;
public String toString(){return nodeName;}
} -
is it possible to expand tree node on rollover instead of
clicking on the triangle?yes, that worked. thanks.
private function itemRollOverHandler(event:ListEvent):void{
tree.expandItem(event.itemRenderer.data, true, true);
I think I was looking for something like getItem(index)..
something similar to Flash AS 2 components. -
WHEN-TREE-NODE-EXPANDED not fire with keyboard in FORMS 10G
I have a Hierarchical Tree. When i click in any node with mouse, works fine.
When i use the key rigth and left of the keyboard, the tree expanded, but not fire the WHEN-TREE-NODE-EXPANDED.
In FORMS 6i works fine.It's a bug 4509399. There is a oneoff patch on Metalink:
https://metalink.oracle.com/metalink/plsql/f?p=130:14:4034066994841324251::::p14_database_id,p14_docid,p14_show_header,p14_show_help,p14_black_frame,p14_font:NOT,331369.1,1,1,1,helvetica -
Context Menu on the right click of af:tree node
Hi Experts,
I am using drag and drop functionality in af:tree.In that i used one tree for drag source and another one tree for drop target,and it is working as expected.
Now I want to bring one additional option in the context menu of the target tree node that is ,when i right click on any of the target tree node in addition to the default menu options like "Collapse","Expand" i want to add one more option .For this i added "contextMenu" facet after the "nodeStamp" facet inside the tree.
*<f:facet name="contextMenu">*
*<af:popup id="p1">*
*<af:menu text="Delete" id="m1">*
*<af:commandMenuItem text="Delete" id="cmi1"*
*action="#{myWorkflow.deleteWorkflowNode}"/>*
*</af:menu>*
*</af:popup>*
*</f:facet*>
Now the problem is : before using drag and drop the context menu workes without any problem .But after using drag and drop the context menu is not popped up.
can anybody help me to resolve this?
Thanks,
Priya.Hi Frank,
1. I am using JDeveloper 11.1.1.3 version
2. Drop target tree is having the context menu.
3. Yes . In Drop event am calling a backing bean method with return type DnDAction and i return the value as DnDAction.MOVE to reflect the changes in the database table to the target tree.
Regards,
Priya. -
Is there a way to disable the double-click-to-expand-
node feature? This seems to be a default behaviour,
wish to remove it. Thanks in advance.I use forms6i patch 12. And that is what I have:
Block 'TREE'
Triggers
WHEN-MOUSE-DOUBLECLICK
begin
:global.MDC := 1;
Message ('1', Acknowledge);
Pause;
end;
Tree_Item
WHEN-TREE-NODE-EXPANDED
begin
Message ('2', Acknowledge);
Pause;
if :global.MDC = 1 then
:global.MDC := 0;
Return;
else
FillLevel; --(e.g. fill the lower nodes and
-- expand the parent node)
end if;
end;
And that is what I get at runtime after double clicking on a collapsed node:
1 (acknowledge)
2 (acknowledge)
So WHEN-MOUSE-DOUBLECLICK fires prior to WHEN-TREE-NODE-EXPANDED in my environment.
Sergey. -
Hi all
i have a problem in the tree node. i was upgrading the application from forms9i to forms10g. but after the upgrade the tree node does not work as before.
every time i try to expand the tree with the keyboard ( the arrow key - the enter key ) i need to press the (tab key) to expand the tree .
also when i try to open any form from the tree by pressing the (enter key) i need to press the (tab key).
but when i use the mouse (double click) it works well.
Thanx.It's a bug 4509399. There is a oneoff patch on Metalink:
https://metalink.oracle.com/metalink/plsql/f?p=130:14:4034066994841324251::::p14_database_id,p14_docid,p14_show_header,p14_show_help,p14_black_frame,p14_font:NOT,331369.1,1,1,1,helvetica -
Hi Experts,
Working jdev 11.1.1.3.0.
we are using tree component on the page which as 6 childs. so if i click on add button once it will add child to that node and once i click on save done will come back to tree page. so everything is working fine. but the problem is once the node is added child node is not expanding. to resolve this issue i am using tree object in session, but while using this process its taking lot of performance.
manually i can able to expand the tree but if once i add node to the parent tree and coming back to the page node is not expanding i have to manually expand it.
so can any one suggest me what could be the best approch to expand the tree.
Thanks,Hi,
Hope followings useful
http://andrejusb.blogspot.com/2010/02/how-to-traverse-adf-tree.html
http://www.oracle.com/technetwork/developer-tools/adf/learnmore/20-expand-tree-node-from-label-169156.pdf
http://www.oracle.com/technetwork/developer-tools/adf/learnmore/21-expand-tree-on-initial-render-169158.pdf -
How to get a Tree Node Value when a Tree is Expanded
My reqiurement is when i Expand a Tree i need the Expanded tree Node Value. For Example Consider Parent as a Root Node of a Tree, and Consider its two Children Child1 and Child2.
When + Parent Expanded
I will Get the Output as --Parent
- Child1
- Child2
so As when i expand the Tree i must Get the String Value Parent.duplicate
How to get a Tree Node Value when a Tree is Expanded -
Help w/ clicking on leaves of tree node
Hello,
I am fairly new to Flex and coding in general, so please bare
with me if my problems seems like a trivial one.
I am trying to create a tree list, where the contents of the
tree are actually links. For example, the top level of the tree
node would be a category (companies), and the leaves of the tree
would be the company names. In addition, I would like the user to
be taken, in a new browser window, to a URL specified in the XML
list when clicking on a company name.
I am having problems resolving the click actions in the app.
I can get the app to open and close the nodes of the tree cleanly,
but when I try to add some code to take the user to a URL when
clicking on a company name (leaf), I get errors.
I am really stuck on how to read the click event in the tree
list, run to the associated XML file to find the URL, then open up
a new browser page to that URL.
Can someone help me please? I've added a snippet of code to
review.
Thank you in advance!"hokudan" <[email protected]> wrote in
message
news:ghk08n$pdb$[email protected]..
> Hi Amy,
>
> Thank you for your reply. Here are the errors that I'm
getting in Flash:
>
> ReferenceError: Error #1069: Property source not found
on mx.controls.Tree
> and
> there is no default value.
> Two of the nodes in the tree also have a 'source' value
that I've entered-
> do
> I need to make it a separate line instead of including
it with the 'label'
> field?
Two things:
1) I'm thinking the currentTarget of the itemClick event will
be the tree
itself, not the node. So you need to look at the selectedItem
property to
get the node. See the example under Handling Tree control
events:
http://livedocs.adobe.com/flex/3/html/help.html?content=dpcontrols_8.html
2) To answer your question, you just need to reference it
properly for
however you set up the xml:
http://dispatchevent.org/roger/as3-e4x-rundown/
Maybe you are looking for
-
Output Devices for Purchasing Groups
Dear Friends/Gurus Please help me out on this issue We Configure Output Devices for Purchasing Groups in SPRO the path is SPRO-IMG-MM-Purchasing-Messages-Assign Output Devices for Purchasing Groups. I would like to know what is the Exact Usage of thi
-
hello all as we know we can using powershel on local networks but i want to use it over internet ( WAN ) is there anyway to do that do i should setup a free VPN on windows or what ?? please i need help im looking for answer since 2 months but without
-
My Macbook started freezing up this morning after restarting. I've tried restarting it, even using the install disk to run the disk utility. I think the next step is reinstalling the OS, but I'm afraid of losing my files. I have some very, very, very
-
Restore SAP 2007B DataBase In SAP 2005B
I am trying to restore a Company's Database which is created in SAP 2007B to SAP 2005B, it gives some error.Is it possible to restore a database from different version to different version? Regards Om
-
Best Approach: All IDocs in one software component or not
Hi All We are in the process of importing IDocs into PI system. We are maintaining software components based on legacy system. We have two oprions to imports idocs into software components 1. Import all idocs into common software component (In this c