Sorting a recursive node

Hello,
I've created a tree in web dynpro. This tree is filled with names of employees. I want to sort it by the names.
1: I create a Comparator:
public class ElementsComparator implements java.util.Comparator{ 
       public int compare(final Object o1, final Object o2)  {   
          final IPrivateView_WDHRMSSNaviView.ITreeNodeElement ea =
               (IPrivateView_WDHRMSSNaviView.ITreeNodeElement)o1;
          final IPrivateView_WDHRMSSNaviView.ITreeNodeElement eb =
               (IPrivateView_WDHRMSSNaviView.ITreeNodeElement)o2;
             return ea.getText().compareToIgnoreCase(eb.getText());
2: I get the root node and call the sort method
IPrivateView_WDHRMSSNaviView.ITreeNodeNode node = wdContext.nodeTreeNode().nodeChildNode();
sortNodes(node);
3: in the sort method i have to iterate all child nodes and sort the elements.
public void sortNodes( IPrivateView_WDHRMSSNaviView.ITreeNodeNode element )
     java.util.Comparator c = new ElementsComparator();
     wdContext.currentContextElement().setDebugValue(wdContext.nodeTreeNode().getNodeInfo().getPathDescription() + " :: ");
     wdContext.nodeTreeNode().sortElements(c);
     Iterator it = wdContext.nodeTreeNode().iterateChildNodes();
     /*when I add this:
         *wdContext.nodeTreeNode().nodeChildNode().sortElements(c);
         *the first childNode is sorted. */
     while(it.hasNext()){
          IPrivateView_WDHRMSSNaviView.ITreeNodeNode childnode = (IPrivateView_WDHRMSSNaviView.ITreeNodeNode)it.next();
          childnode.sortElements(c);          
Why isn't this working? Can anybody tell me what's wrong?
Thanks,
Joachim

IMasterNodeElement parent = wdContext.nodeMasterNode().createAndAddMasterNodeElement();
parent.setName("Parent");
  IValueNodeElement e = parent.createAndAddValueNodeElement();
  e.setValue1("Parent Value1");
IMasterNodeElement child= parent.nodeRecursiveNode().createAndAddMasterNodeElement();
child.setName("Child");
  IValueNodeElement e = child.createAndAddValueNodeElement();
  e.setValue1("Child Value1");
Armin

Similar Messages

  • [Tree] item and node order ! (Recursive Node)

    I made a wd4a has organizatonal structure tree. but I have some problem with the org tree.
    I want to have a tree(org structure) in item(person) and node(organization) order.
    Root                                            Root
      |- Person 1                                    |- Head Dept
      |- Person 2                                    |        |-Person 3
      |-Head Dept                        ->        |        |-Person 4
      |       |- Person 3                             |-Sales
      |       |- Person 4                             |- Person 1
      |-Sales                                          |- Person 2
    ( to be displayed)                                 (current displayed)
    Whiat's the problem?
    Although the both of them have a same contents, I really want to display in person and org order .
    Plz. help.

    I solved this problem myself and it makes me very so tired.
    I guess that Recursive node tree have some bugs.
    If a node have one recursive node and one sub-node and some kinds of attributes,
    we have to make a decision on how to display and sort them(sub-node and attributes)
    There is a example below as I really want to sort them.
      C_Drive Folder
    - file 1
    - file 2
    - Folder 1
    - file3
    - Folder 1-1
    - Folder 2
    Context
        |-Folder Node
        |      |-File Node
        |      |       |-File Name attribute
        |      |-Folder Name attribute
        |      |-Folder_Content             -> Recursive Node
    When you meet this situation,you must implement the context nodes and
    the names of context node and recursive node must be in alphabet order you want to display.
    I am sorry for my crumsy writting English.

  • Sort a context node that has subnodes

    I have a context node with cardinatliy 0:1.
    It has one subnode, 3 attributes, and a recursive node.
    Now, I would like to sort the content of the node by one the three attributes.
    How can I do that?

    Hi Daniel,
    but if the subnode is mapped on the parent, it will have the same 0...1 cardinality - and it won't make sense to sort it.
    If perhaps both the parent and subnode have 0...n cardinality but you are only creating one root element - this makes more sense.
    Sorting the second/third/nnn level of a hierarchy is difficult - because it is difficult for the user to specify which level they want to sort. I would assume that you'd just make it so that ALL levels were sorted according to whichever criteria you choose.
    You could consider representing your data as a table popin's (which would then make it more obvious which level was being sorted) but if your data has n levels of hierarchy this will very quickly become a nightmare of recursive dynamic coding.
    As you are no doubt aware, the standard table sorting logic as implemented in CL_WDR_TABLE_METHOD_HNDL does not work for hierarchical tables. (7.01, goodness knows, it might in 7.02)
    So I see two options:
    I think you would either have to go down the path of creating your own table handler, unfortunately the standard table handler CL_WDR_TABLE_METHOD_HNDL is marked as final - so you couldn't just subclass that and override the sort handling (which doesn't work for hierarchical tables). Instead you'd probably have to re-implement. Then reassign the handler in the WDDOMODIFYVIEW. I remember doing similar sorts of things to implement sorting in WDJ in the early days when the standard handler didn't do all I needed it to do. (i.e. it was sorting by key rather than by text for dropdown by keys).
    Or, in the event when you open/display a node, sort the contents according to the state of toggle buttons that you implement in the root node of your hierarchy. When these toggle buttons change state - recursively sort your your entire context.
    This means you don't have to mess with the standard table handler, but does give a very non-standard sort implementation.
    Good luck, if you have any questions, please do let us know.
    Chris

  • How to manipulate recursive node with context api?

    Hi, all.
      I made a recursive node in my context.  So it is like a tree.
    When I choosed one child node in my tree, how can I get it`s current element?
    Thanks a lot.

    Hi Louis
    Check this PDF link
    http://www.sdn.sap.com/irj/servlet/prt/portal/prtroot/com.sap.km.cm.docs/library/user-interface-technology/wd%20java/wdjava%20archive/constructing%20a%20recursive%20and%20loadable%20web%20dynpro%20tree.pdf
    Also check this elearning link.It gives info of supply function
    https://www.sdn.sap.com/irj/scn/elearn?rid=/library/uuid/60086bd5-9301-2b10-6f97-a14366a5602b&overridelayout=true
    Regards
    Ruturaj

  • Dynamic context in web dynpro abap: recursion node is possible?

    Hi,
    i'm working with web dynpro ABAP and I need to create a dynamic recursion node. Is possible?
    thank you.
    Regards.
    Al

    Hello Saravanan,
    this is my code that creates a context node with recursion node, but supply_method i never called. why? could you help me?
          CALL METHOD lr_root_info->add_new_child_node
            EXPORTING
              name                         = y_name
              is_mandatory                 = abap_false
              is_multiple                  = abap_true
              is_mandatory_selection       = abap_false
              is_multiple_selection        = abap_true
              is_singleton                 = abap_true
              is_initialize_lead_selection = abap_true
              is_static                    = abap_true
              supply_method                = 'SUPPLY_NAV_LIST'
            RECEIVING
              child_node_info              = lr_node_info.
          ls_attribute-name = 'TEXT'.
          ls_attribute-type_name = 'STRING'.
          CALL METHOD lr_node_info->add_attribute
            EXPORTING
              attribute_info = ls_attribute.
          ls_attribute-name = 'ENABLED'.
          ls_attribute-type_name = 'WDY_BOOLEAN'.
          CALL METHOD lr_node_info->add_attribute
            EXPORTING
              attribute_info = ls_attribute.
          lr_node_info->add_recursive_child_node( child_name = y_name_nav child_info = lr_node_info is_static = abap_false ).
    Thank you.
    Al

  • 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 .

  • Recursive node error in ESR

    Check result for Data Type: PriceDerivationType | http://alfuttaim.com/xi/storeConnectivity:
    Data type Data Type PriceDerivationType | http://alfuttaim.com/xi/storeConnectivity points to itself
    Hi Experts ,
    I have a datatype part of sap standard content which has a recursive node ( poniting to itself).
    I have to copy it to a local name space and use it . When i try to copy it and activate it i am getting this
    error .
    "Check result for Data Type: PriceDerivationType | http://alfuttaim.com/xi/storeConnectivity:
    Data type Data Type PriceDerivationType | http://alfuttaim.com/xi/storeConnectivity points to itself"
    Please let me know how do i go abt activating this object.
    Thanks in advance and best regards,
    Anil

    Hi Anil,
      When you copy it local namespace, verify the namespace is local or the one which is poiting to itself.
      If this is pointing itself, manually you change the namespace which you want and activate it.
      Hope this helps.
    Regards
    Shankar.

  • Recursive node in xsd

    Hello PI people.
    I have a problem reguarding to a XSD file (standard DSML found here: [DSMLv2|http://www.oasis-open.org/committees/dsml/docs/DSMLv2.xsd]).
    When I Import it as external definition to PI Integration builder it all works fine but if I undfold the message "Filter" the there is problem with the defintions for "not" and after one more fold on "and" or "or" the same problem is shown. It looks like PI understands the XSD but it just not permit recursive nodes?
    Is it the XSD that dosent meet the PI standard or is it a internal thing in PI that needs to be activated to handle recursive nodes i XSD?
    (When a message is mapped with this DSML all the error prone nodes are stripped..)
    // Jesper

    Hello Jesper,
    You can refer to this document for supported XSD and WSDL:
    http://www.sdn.sap.com/irj/sdn/go/portal/prtroot/docs/library/uuid/00a9a425-1769-2a10-9196-bd8eeed72e4c
    Once you open this excel document go to row 94 for Recursive Data Structures, it says it is supported but there is a reference to row 143 which says
    Recursive data structure must be expanded in design-time manually to the desired depth
    If what you are thinking is dynamic recursion, then it is not possible. You have to use Java Mapping/XSLT for that. Now as for the nodes not displaying, right-click on the node and then select expand recursive structure.
    Hope this helps,
    Mark

  • Reading and modifying data in a recursive node

    Hi All,
    I am using a TreeByNesting column in a table UI element of my component.
    For this purpose I have created a node in the context - ('TREE') which contains a recursive node - ('RECURSIVE_TREE').
    What would be the simplest way to read the data from this node ? And how do I go about changing a single line of information
    within the node ?
    Thanks,
    Fathima

    What would be the simplest way to read the data from this node?
    Reading data from a recursive node is no different to reading any normal node. It's just that you have a very simple way of holding the same structure.
    Once you have a reference to the element of a node (a single line of data), then updating it is no different to updating a line of a table.
    More issues are associated with making and setting lead selections for an element (all parent elements also need to be lead selected and no child elements). Searching through the hierarchy, etc.
    Where I have used this functionality I have often set up search tables with the key data that I want to search in a flat table and a reference to the corresponding element - much easier to search then - without having to resort to recursive coding!
    Could you elaborate a little on what exactly you are having an issue with?
    Cheers,
    Chris

  • WD ABAP: Lead selection on a recursive node

    Hi,
    I would like to know if lead selection is permitted on a recursive node in WD ABAP.
    As of now, methods 'set_lead_selection_index' or 'set_lead_selection' do not cause lead selection to change in my view, and the lead selection rests only with the first row in my table..(I have set the rowSelectable property to YES for my table.)
    Also, method call 'set_selected' performed on my target element does not solve the problem.
    Any help much appreciated!
    Best Regards.

    Hi Adithya,
    Yes, you can have a leadSelection on a recursive node and it can be changed by the same methods that are used for non-recursive ones.
    Best regards,
    Thomas

  • WD ABAP: Recursion Nodes that Repeat Tree Nodes with Embedded Tables ???

    At Rich H's suggestion, I'm posting this here as well as in the blogs.
    Suppose you've got a tree context with a node that has a table embedded under it. (For example, the TREE_WITH_TABLE view of WDR_TEST_EVNT has this kind of context substructure.) Call this node "NODE_WITH_TABLE."
    You now define a recursion node underneath "NODE_WITH_TABLE" and specify "NODE_WITH_TABLE" as the repeated node for this recursion node. Call this recurion node "RECURSION_NODE".
    Lo and behold - the table fills properly when you're on any instance of "NODE_WITH_TABLE", but not when you're on an instance of "RECURSION_NODE".
    I'm hoping that:
    a) I'm doing something wrong;
    OR
    b) There's an easy work-around/alternative I'm not seeing
    OR
    c) SAP will give recursion nodes enough memory to carry any table(s) embedded in the nodes they're repeating.
    'Cause I sure don't want to have to define "n" levels of tree-nodes that have different copies of the same table(s) embedded in them.
    Message was edited by: Armin Reichert

    /people/david.halitsky/blog/2006/08/16/recursion-nodes-that-repeat-tree-nodes-with-embedded-tables-in-wd-abap-not
    Maybe you might want to back out your weblog as it is not really a place to ask these types of questions.  Think of it this way,  if you are allowed to do this type of weblog,  what is stopping any other weblogger.  Hence the weblogs would just be another forum, which I don't think anyone wants. 
    Regards,
    Rich Heilman

  • Recursive Node  In WebDyn Pro

    Hi........
    Like I am not Able to Create Recursive Node. it is giving Error. Type Comfortable.
    Please Tell Me solution ...

    You may have to explain lot more than this,so that we can understand and help you effective.
    What you do exactly? from where you are trying to do ? explain it in step step what you have done so for and also post the exact message.
    You must be making somewhere a mistake. This is not a kind of error i hear often.

  • Recursive node mapping

    Hi everybody,
    i would like to ask if it is posiible to map context node with recursive node from controller to view. I try to do that by the recursive subnode is disabled. When that is not possible can that any one explain why?
    Regards
    Bogdan

    Hello Bogdan,
    Recursive context nodes cannot be mapped. You may refer this <a href="http://help.sap.com/saphelp_nw2004s/helpdata/en/ea/a5384162316532e10000000a1550b0/frameset.htm">article</a>
    Best Regards,
    Bala

  • Recursive node and Non Recursive node

    Hi,
    What is the difference between Recursive node and Non Recursive node ?
    Thanks,
    Teja

    Hi Teja
    Recursive node
    If you wish to represent a recursive data structure within the context, a recursive node is the correct node to use. The simplest example of recursive data within a hierarchical structure is a file system. A dictionary can contain either files or subdirectories. This definition is then repeated for each subdirectory level down the hierarchy.
    Within the context, a recursive node is a special node that has only two properties: name and repeatedNode. As with any context node, a recursive node must itself name, but the repeatedNode property is where the recursion is defined. This property holds a reference to some parent node and indicates that, at runtime, the location of the recursive node will be occupied by a node of the type indicated in the repeatedNode property.
    You should think of a recursive node as a design time placeholder used to indicate a node will be created at this location at runtime, and will be of the type named in the repeatedNode property.
    The node name identified by repeatedNode must lie on the direct path back to the context root node.
    When a recursive node is created at runtime it always created as a non-singleton node. This is a hard-coded feature and cannot be changed.
    Non recursive node is opposite to recursive node
    Regards
    Ruturaj

  • Recursive node

    Hi All,
    What is recursive node what is the use of it .....
    waiting for your response...
    Regards,
    Shilpa

    Hi
    Recursive Node is used when depth of child nodes under a given context while not be known untill at runtime.
    Recursive Node have two properties : Name and repeated Node
    https://www.sdn.sap.com/irj/scn/wiki?path=/display/wdjava/value%252bnodes%252cmodel%252bnodes%252crecursive%252bnodes
    /people/sap.user72/blog/2005/06/05/tree-control-in-webdynpro
    /people/bharadwaj.p/blog/2006/12/20/image-recursive-tree-with-an-action
    Thanks,
    Tulasi Palnati

Maybe you are looking for