11gR1: expanding the current node in a tree programmatically

Does anybody know how to programmatically expand the currently selected node in an af:tree in 11gR1? In all honesty I've searched a million OTN posts and tried a lot of examples but haven't got it working yet.
At it's most simple I have a tree:
<af:tree id="dirTree" value="#{bindings.NodesViewTree.treeModel}" var="node"
             selectionListener="#{tbindings.NodesViewTree.treeModel.makeCurrent}" rowSelection="single"
             binding="#{treeBean.dirTree}" >
  <f:facet name="nodeStamp">
      <af:outputText value="#{node.Name}" id="ot2"/>
  </f:facet>
</af:tree>...of which the user can select a node, and the selectionListener updates the treeModel's current selected row.
I want a button whose actionListener programatically takes the current selected row and expands (aka discloses it). I've a bean like follows:
public class TreeBean {
  private RichTree dirTree;
  public void setDirTree(RichTree dirTree) { this.dirTree = dirTree; }
  public RichTree getDirTree() { return dirTree;  }
  public void doSomething(ActionEvent actionEvent) {
    RowKeySet selectedTreeNodes = dirTree.getSelectedRowKeys();
    RowKeySet disclosedTreeNodes = dirTree.getDisclosedTreeNodes();
   AdfFacesContext.getCurrentInstance().addPartialTarget(dirTree);
}But I can't figure out what to do from here?
Further to this say if we did manage to expand the current selected node, and I happened to know the oracle.jbo.Key of one of the expanded node's child nodes, how can I programatically select it.
As mentioned I know a search of the forums yields a few hits for this topic, but none have yet solved my issue, so I'm hoping somebody can address my problem afresh please.
Thanks for your assistance,
CM.

After a lot of playing it appears the JS approach is a dead-end. Ultimately what I'm attempting to achieve is to allow the user to right click a node in a tree, create a new node, and select the new node for the user. This can't be achieved in JS as the main work of creating the node must be done from the bindings/binding classes only accessible in a backing bean.
So I've finally come up with a backing bean code solution where the user selects a node in a tree, and via a secondary action of selecting a context menu commandMenuItem the following code is executed. When I say "code solution", unfortunately I mean something that compiles & runs without throwing errors (hurrah!), but (sigh) doesn't work. I'm hoping somebody on the forum can give me a kick in the right direction please.
The code:
  RichTree dirTree;
  public void anotherExperimentalCreate(ActionEvent actionEvent)  {
    String parentNodeType = getSelectedNodeType();
    if (parentNodeType.equals(DATABASE)) {
      // create user - todo
    } else if (parentNodeType.equals(FOLDER)) {
      // Fetch data from parent row required for new row
      oracle.jbo.domain.Number parentNodeId = getSelectedNodeId();
      oracle.jbo.domain.Number parentNodeTypeId = getSelectedNodeTypeId();
      DCIteratorBinding treeIterator = AdfUtils.findDCIteratorBinding(NODES_VIEW_TREE_ITERATOR);
      RowSetIterator treeRsi = treeIterator.getRowSetIterator();
      // Create new row
      // Why rsi.createAndInitRow? See - http://radio.weblogs.com/0118231/stories/2003/01/17/whyDoIGetTheInvalidownerexception.html
      Row newRow = treeRsi.createAndInitRow(new NameValuePairs(new String[]{"ParentNodeId"}, new Object[]{parentNodeId}));           
      oracle.jbo.domain.Number newNodeId = (oracle.jbo.domain.Number)newRow.getAttribute("NodeId");
      newRow.setAttribute("ParentNodeId", parentNodeId);
      newRow.setAttribute("NodeTypeId", parentNodeTypeId);
      newRow.setAttribute("Name", "New Folder" + newNodeId.toString());
      treeRsi.insertRow(newRow);
      // Commit changes and refresh iterator so it places new child row at correct location in tree
      FacesCtrlActionBinding commitBinding = AdfUtils.findFacesCtrlActionBinding("Commit");
      commitBinding.execute();     
      treeIterator.executeQuery();
      // Rebuild tree's current selected row by grabbing the current selected rows list (from which this action was invoked)
      // and add the additional new row to the end, with the goal of making the new row selected.
      // For "single" selection tree, and fact this routine can only be invoked via selecting a node, we only need
      // first element from iterator
      // Technique for casting to list derived from following OTN post:
      //    ADF Faces  - type of key element!
      List<Key> currentSelectedRowKeys = (List<Key>)dirTree.getSelectedRowKeys().iterator().next();
      ArrayList<Key> newSelectedRowKeys = new ArrayList<Key>();
      // Copy existing selected row keys to our new selected row key list
      for (Key currentSelectRowKey : currentSelectedRowKeys) {
        newSelectedRowKeys.add(currentSelectRowKey);
      // Add our new row's key to the end of the list
      newSelectedRowKeys.add(newRow.getKey());
      RowKeySetTreeImpl newSelectedRowKeySetTree = new RowKeySetTreeImpl();
      newSelectedRowKeySetTree.add(newSelectedRowKeys);
      // **** doesn't work ****
      dirTree.setSelectedRowKeys(newSelectedRowKeySetTree);
      AdfFacesContext.getCurrentInstance().addPartialTarget(dirTree);
  }As per the "doesn't work" annotation above, the problem is when the tree is refreshed via the PPR event, the tree hasn't selected the new row as passed to setSelectedRowKeys. Instead the state of the tree (expand/collapse) is the same as before the code is fired, though the new row is present as a child.
Has anybody any clues at all on what I can attempt to try next please?
Regards,
CM.

Similar Messages

  • How to get the current node element by its value?

    e.g,:
    wdContext.current<b>Deal</b>Element().setAttributeValue("<i>deal_id</i>","<i>aaaaaaa</i>");
    above code can get the result i wanna.
    but now i wanna in terms of its node'name to  set attribute vaue of itself. in other words,i have no idea about how to get the current node element by its name"<b>Deal</b>".

    Hi Wing,
    The answer is there in your question itself.
    wdContext.currentDealElement()
    will give you the current node element by its name"Deal" or you could use
    wdContext.nodeDeal().getCurrentElement()
    or you could use
    wdContext.nodeDeal().getElementAt(wdContext.nodeDeal().getLeadSelection())
    Regards,
    Sudeep

  • How to get the parent node of the current node?

    Hi all,
    i want to get the parent node of the current node and the not the parent of the parent node.
    thank you very much

    Hi,
    the parent node of <subnode1-2>29.99</subnode1-2> is (node1), how can do to get <node1> throw <subnode1-2>29.99</subnode1-2> the sub node of <node1>.
    As per my understanding the parent node of <subnode1-2>29.99</subnode1-2> is book not the node1.
    If you want node 1 as a parent of subnode1-2 than your xml will look like this.
    <?xml version="1.0" encoding="ISO-8859-1"?>
    <bookstore>
    <book>
    <fathernode>Harry Potter</fathernode>
    <node1>
           <subnode1>29.99</subnode1>
           <subnode2>29.99</subnode2>
    </node1>
    <node2>
           <subnode1>19.99</subnode1>
           <subnode2>19.99</subnode2>
    </node2>
    </book>
    </bookstore>
    and also if you want tom retrive float data than refer following XPATH.
    "//book[[price='1000']]/price/text()"
    Regards,
    Manoj Bilthare

  • How to get the root node of a tree?

    I wanna get all the leaf node of a tree.But JTree have no method about how to get the root TreeNode of a tree.Then how should I do?

    try this:
    http://javaalmanac.com/egs/javax.swing.tree/GetNodes.html?l=rel

  • Select the multiple nodes in a tree

    Hi Experts,
    We need to select the multiple nodes in a tree.Whatever we are selecting,that has to be added in the table as a tree structure itself.
    For ex:
    A
    |--A1
        |--B1
    If We select the A then A,A1 and B1 has to be added in a table.Please help me out for this.
    Regards
    Nutan
    Edited by: Armin Reichert on Jan 29, 2008 2:33 PM

    Hi,
    You have to create a recursive node and use the tree by nesting UI component
    Following tutorial will be of use
    https://www.sdn.sap.com/irj/servlet/prt/portal/prtroot/com.sap.km.cm.docs/library/user-interface-technology/webdynpro/wd%20java/wdjava%20tutorials%20and%20articles%20archive/constructing%20a%20recursive%20and%20loadable%20web%20dynpro%20tree.pdf
    Recursive Node
    http://help.sap.com/saphelp_nw70/helpdata/en/5d/97384162316532e10000000a1550b0/frameset.htm
    TreeByNesting
    http://help.sap.com/saphelp_nw70/helpdata/en/92/12a74046033913e10000000a155106/content.htm
    https://www.sdn.sap.com/irj/sdn/go/portal/prtroot/docs/webcontent/uuid/28113de9-0601-0010-71a3-c87806865f26?rid=/library/uuid/49f2ea90-0201-0010-ce8e-de18b94aee2d#31 [original link is broken]
    Regards
    Ayyapparaj

  • Setting background color to just the root node in a tree

    How can I set a background color to just the root node in a tree? I got the node in the followig way in the renderer method.
    IconNodeClass parentIconNode = (IconNodeClass)((IconNodeClass)value).getRoot();
    Then how can I set the background for just the root node? Thanks.

    You need to write ur own treeCellRenderer for that to be done

  • Fragment menu -how to pass the current nod to a function

    How can I pass the current node to a function I tried this but it
    didn't work.please advice
    <script language="javascript">
    nvh_mainnavigation_display(g_navNode_Path, Node ,
    "<!--$HttpRelativeFragmentsRoot-->AlfarisMainNavigation", false);
    </script>
    Note:
    I'm trying to create a menu that shows the subnodes of the current
    section or node that im standing on.

    <BLOCKQUOTE><font size="1" face="Verdana, Arial">quote:</font><HR>Originally posted by Juan Oropeza ([email protected]):
    http://technet.oracle.com:89/ubb/Forum2/HTML/006279.html <HR></BLOCKQUOTE>
    null

  • How we know the selected node in a Tree object in a form?

    In a TREE object in forms, how can we know the current selected node by clicking a push button.
    lets say , there are 10 nodes in my tree, and 5th one i selected. But i want to store the selected node in a variable, when i click a button.
    please help
    thanks

    Hello
    I've just notice what might be a bug in Oracle forms because when I have the when-tree-node-selected trigger present for the tree (It does not matter if it executes null or some code), the code in option 1 works fine on a when-button-pressed trigger on a button item. This is what I had done to give you a reply.
    My second option will work because you're populating a parameter with when-tree-node-selected trigger which is then readable form anywhere else in the form. All you add is a check on when-button-pressed. Also for bug handling you need to consider setting the value to null when deselecting. I have this option working currently in one of my applications.
    DECLARE
         num_selected NUMBER;
         htree ITEM;
    curren_node FTREE.NODE;
    BEGIN
    htree := find_item('tree.form_list');
    num_selected := ftree.get_tree_property(htree,ftree.selection_count);
    for j in 1..num_selected
    LOOP
    curren_node := ftree.get_tree_selection(htree,j);
    message('hello :'||ftree.Get_Tree_Node_Property(htree,curren_node,ftree.node_value),acknowledge);
    end loop;
    END;     
    cheers
    Q

  • How to get UIComponent of the selected node in af:tree with drag and drop

    Hi
    Are there examples showing how one could get a UIComponent using DropEvent to be used with a Popup showing as a custom "context menu" at the target node ?
    Right now, with dropEvent.getDropComponent, we could only get the tree.
    We like to get its selected node so that the popup shows at the node level, not at the tree level.
    Thanks

    Hi Frank
    Thanks for responding.
    We like to show on our custom "context menu" using PopupHints (not using facet name contextmenu) with 3 commandMenuItems.
    Since component id is needed by PopupHints to place this custom "context menu", we tried
    RichTree dropTree = (RichTree)dropEvent.getDropComponent();
    alignId = dropTree.getClientId(context);
    // alignId = pt1:pt_region1:1:pt1:pc1:navTree
    getClientId returns us the tree id and hence the context menu is placed next to tree.
    We like to place the context menu next to a target node of the tree when dragging and dropping.
    But we couldn't figure out how to get that node id.
    In your suggestion,
    List dropRowKey = (List) dropEvent.getDropSite();
    RichTree dropComponent = (RichTree) dropEvent.getDropComponent();
    dropCompoent.setRowKey(dropRowKey);
    how do we then get the id of this node then ? What's the method ?
    Thanks Frank

  • Current node tree with tooltip_text

    Hello,
    How can i display a tooltip_text for the current node from a tree ?
    I tried with
    :Ctrl.Node_Selected     := Ftree.Get_Tree_Node_Property('BL_TREE.MENU',
    :SYSTEM.TRIGGER_NODE,
    Ftree.NODE_VALUE);
    set_item_property('BL_TREE.MENU',
    tooltip_text,
    :Ctrl.Node_Selected);
    I didn't find something with the build_in set_Tree_Node_Property
    There is a possibility to display an icon for each node ? I build the tree with a record group. How can I do it ?
    Thanks
    Bye

    hi,
    you can set the tooltip-text of the whole treebean according to the currently selected "active" node.
    Try to use the code you already used in a WHEN-TREE-NODE-SELECTED-Trigger.
    It's not possible to have a tooltip-text for each node separately.
    Yes, you can assign an icon to each node. Whn you use a recordgroup to fill the tree, one of the columns of the recordgroup has to be the name of the icon
    If i remember correctly the columns are
    NODE_STATE
    NODE_DEPTH
    NODE_LABEL
    NODE_ICON
    NODE_VALUE

  • Display the icon when current node selected in af:tree

    Hi !! Gud Mrg !!
    I am using jdeveloper 11.1.1.5
    I had created an af:tree., I need to display the icon when my user clicks the current node!!
    Could any one pls provide me solution to fix this !!

    Sorry jhon and Frank !!
    I will explain what i had did and my scenario!!
    What i had did
    I had dragged and dropped my ApplBusFun as a af:tree
    Such that it doesnot have parent and child My tree would look like this
    Request for quotation
    Supplier Documents
    Suppliers
    Purcahse Order
    My Scenario
    My scenario is when my user clicks the current row ., Consider if my user clicks Request for quotaiton an arrow symbol must be appeared before Request for Quotation such that my output must looks like this
    ==>Request for quotation
    Supplier Documents
    Suppliers
    Purcahse Order==> This is the icon which appeared before Request For Quotation and this icon must appear whenever user clicks any node Suppose if my user going to click Supplier Document means
    My output must look like this
    Request for quotation
    ==>Supplier Documents
    Suppliers
    Purcahse OrderHope i had explained my scenario clearly!! Appologise if i didnt explained properly!!

  • How can i change the expand level of nodes in treeView1 according to numericupdown value change ?

    I have this method:
    void ExpandToLevel(TreeNodeCollection nodes, int level)
    if (level > 0)
    foreach (TreeNode node in nodes)
    node.Expand();
    ExpandToLevel(node.Nodes, level - 1);
    I added now a new method:
    void CollapseToLevel(TreeNodeCollection nodes, int level)
    if (level > 0)
    foreach (TreeNode node in nodes)
    node.Collapse();
    CollapseToLevel(node.Nodes, level - 1);
    Then in the numericupdown changed value event i did:
    decimal oldValue;
    private void numericUpDown1_ValueChanged(object sender, EventArgs e)
    if (numericUpDown1.Value > oldValue)
    ExpandToLevel(treeView1.Nodes, (int)numericUpDown1.Value);
    else
    CollapseToLevel(treeView1.Nodes, (int)numericUpDown1.Value);
    oldValue = numericUpDown1.Value;
    When i expand change the numericupdown value up it's expand it fine level by level. But when i collapse it back when changing the numericupdown value back down if i was at value 4 and now changed to value 3 all the nodes collapsed back to root.
    I want it to collapse only by one level from 4 to 3 to 2 to 1 when the vlaue is 0 then collapse back to root.
    The collapse is not working good.

    Hi,
    You don't need to loop from the start to collapse it.
    Just issue the collapse on the current node; if its not collapsible then nothing will happen.
    treeView1.SelectedNode.Collapse();
    Happy coding.
    Please remember to mark the replies as answers if they help and unmark them if they provide no help.

  • Accessing the parent element of  a tree node !

    Hi All,
    I’m building a tree application, in which the user has the option for creating a new node at any level he wants. But my problem is, If the user wants to create a node at the same level of the selected node, how do I retrieve the parent element? Can someone help me in this regard? I’ve done the following
    1)     Created a node “TreeNode” with the required attributes & the recursive node.
    2)     When the user clicks on any node, I am able to retrieve the selected element through recursive traversal (i.e. the instance of TreeNodeElement, say elmt)
    3)     I was able to retrieve the parent element through the function elmt.node().getParentElement(). But it returns an instance of IWDNodeElement, which does not have the recursive node. Ofcourse, I cannot typecast IWDNodeElement to “TreeNodeElement”.
    Then How do I retrieve the “TreeNodeElement” instance of the parent element? Someone please help…..!
    Thanks in Advance,
    Best Regards,
    Nibu.

    Hi Nibu,
    you should type as follows
    IPrivateRecursiveTree.ITreeNodeElement ele=(IPrivateRecursiveTree.ITreeNodeElement)selectedElement.node().getParentElement();
    this way you will get the Parent element of the current node.
    Rgds,
    Vilish
    P.S. If prob solved, consider reward points

  • How do I calculate/retrieve the depth of a current node in XSLT?

    I mean the number of parent nodes a particular node has, hard coded something like:
    <root>
    <child depth="1">
    <another_child depth="2">
    I do not want to hard code these levels, so i am searching for a way to do it in XSLT. I could not find a function/element for this purpose.
    Who knows the solution????
    tnx

    You count the nodes in the ancestor axis: something like count(ancestor:*). Adjust by +/-1 if you need to include/exclude the root or the current node.

  • How to get current node element for recursive node.

    Hello Xperts,
    I have a requirement where I need to find the current node element of the recursive node.
    I was trying following code for the same
    Data:
    selected_elem type ref to if_wd_context_element.
    selected_elem  = WDEVENT->GET_CONTEXT_ELEMENT( NAME = 'CONTEXT_ELEMENT' ).
    selected_elem  ->get_static_attributes(
        IMPORTING
          static_attributes = sel_attri ).
    But it does not work for me and I always get 1st node value.
    Please help me in this issue.
    -Ashutosh

    Hello ,
             If you implementing a simple tree ( not table tree )  and you want the selected element for
    OnLoadChildren event  .
    Then create an importing parameter CONTEXT_ELEMENT  of type IF_WD_CONTEXT_ELEMENT
    in the event handler of onLoadChildren .
    Webdynpro framework automatically filled up the context element with the current node in the tree .
    I tried it , It really worked for me .
    If you have a table tree then you need to create an importing parameter PATH  of type String in tha event handler .
    Webdynpro frame automatically fills the PATH .
    the use can use the following method to get the element from the PATH .
    wd_context->path_get_element( path ).
    I tried it , It also  worked for me .
    Regards
    Vivek
    PS : please provide the points if answer is helpful .

Maybe you are looking for

  • Function Module for Campaigns

    Hi Experts, I have an query, I am executing a Campaigns based on this campaign creating a Leads as transaction. I need some function module or BAPI , using which i can download the Lead Numbers , Business Partner Details like name , address, marketin

  • Issue with electronic bank statement upload

    Hi All,           Presently I face an inssue in posting electronic bank statement upload (Tcode - ff_5). The scenario goes like this.          First we do payment to vendor using 'f110' transaction.Here the document currency is different from local c

  • Why is my battery showing it's fully charged at 95%?

    Why is my battery showing it's fully charged at 95%?

  • Music player turning on automatically

    At random, when I swipe up to access Control Center, it says my music player is on and playing a random song. Even though I havent opened my music app. Anyone else know whats going on??

  • Doubt if Xperia Z3 is shockproof

     Hello, guys, I just wanted to know if Xperia Z3 is shockproof. Mine one is the Dual version. I was wondering if just the glass screen protector is enough or I would have to use those phones cases. Thanks in advance.