Tree selection event in jtree

hi
i'm using a jtree in my gui but im facing a problem
jTree1.addTreeSelectionListener(new TreeSelectionListener() {
               public void valueChanged(TreeSelectionEvent e)
                    jTree1_valueChange(e);
as you can see that whenever i click on a particular node in the tree the tree selection event occurs which calls the valuechanged method and it does as required but if i click again on the same selection as before the tree selection event does not occur and it does not call the method so say that the node i'm selecting is supposed to be dynamic and has to be refreshed if i click on it again it will not update itself through the value changed method. can somebody please tell me a way to be able to get the valuechanged method even if i click on the same selection.
im a bot new to java swing programing so please if you could be a little more explanatory it could help
thanks

You problem is talked about (and a solution proposed) in the JavaDoc.
See the code sample in the doc header from http://java.sun.com/j2se/1.4.2/docs/api/javax/swing/JTree.html

Similar Messages

  • JTree Selection Events

    Hello,
    I like to initially expand a tree and select the first data item in it. It should then execute all events as it would when the user opens the tree with mouse clicks and selects a sub-item.
    This is my code:
    In the constuctor of the container of the tree control I do:
    public OperationSplitTreeSoftDist()
    initTree();
    fillTree();
    protected final void initTree()
    // setup tree renderers etc......
    // setup events
    setupTreeEvents();
    private void setupTreeEvents()
    mTree.addTreeSelectionListener(new TreeSelectionListener()
         public void valueChanged(TreeSelectionEvent e)
    System.out.println("Tree selection event received!");
    ....... // other things done here
    private void fillTree()
    ..... // executing sql query and filling resultset in tree
    mTree.expandRow(0);
    mTree.setSelectionRow(1);
    In the last two rows above I expand the root of the tree and select the first row of the expanded tree. This works fine but the EVENTS (TreeSelectionListener) are NOT fired! My implementation of the Selection Listener executes another query on a database server and fills the results in a table. This is only called AFTER mouse clicks, the programmatically selected first row does NOT fire selection events!!
    Is there any way of firing selection events PROGRAMMATICALLY??
    Many thanks for your help.
    Thomas

    You would laugh if I say it :)
    My code was throwing an Exception becoz of the index in substring function.
    To put in simple terms, careless programming. and my mind had gone for a walk...I wasn;t able to figure out where the problem lied :)
    anyways, let me know if you have problems with yoru code. I would like to know about it, and if possible..I will try solving it as well :)
    Sangeetha

  • Tree selection by user or programmatically

    Hallow All!
    How can I know if tree selection mode by user or programmatically?
    I want to listen - tree selection and do some operation only if the selection made by user (mouse or keyboard) and do nothing if the selection made programmtically!
    I tried to use isFocusOwner methos:
    addTreeSelectionListener(new TreeSelectionListener() {
                   public void valueChanged(TreeSelectionEvent e) {
                        if(!TopologyTree.this.isFocusOwner()){
                             return;
    }but is doesn't work, if some text field in another panel has the focus then the tree gain the focus only after the tree selection event performed
    any help will be most appreciated!
    Eran.

    Create a substitution rule in which user name from the header is substituted to any of the fields in vendor line item. (assignment, text etc). After this you can use this for APP.
    Tarun

  • How to select node in JTree without firing event?

    I have got standard situation. JTree in the left panel, and several edit boxes in right panel. Certainly, I have TreeSelectionListener, which on every tree node selection shows corresponding model values in edit boxes.
    I'd like to implement next logic:
    1. Something was changed in any edit box in right panel. Model has been changed.
    2. User clicks on different node in tree.
    3. Dialog "Message was not saved. Save?" with Yes/No/Cancel buttons are shown.
    Yes/No buttons are easy to handle.
    Question is about Cancel. I'd like on Cancel button left all edit boxes in their present state (do not restore values from saved model) and select back node, which wasn't saved.
    Problem is next. If I select node by setSelectionPath or smth like that, but... JTree fires event and my listener receives onTreeItemSelected back, which checks that node wasn't saved and ......
    Who does have any idea, or have done similar tasks? How can I select node and do not allow tree fire event this time?
    Thanks in advance.

    First, as soon as the model changes (when editing any
    combo box) some flag will be set. Now the logic which
    updates the combo boxes will do it only on a change of
    the current node and (this is new) if the flag wasn't
    set. You should have some flag anyway because somehow
    you must determine when to show the dialog, shouldn't
    you?Yes, I have got this logic implemented. But it's only the half :)
    I know exactly when my model has been changed, but if it was changed, i'd like to ask user what to do next - svae/loose changes/cancel
    And on cancel i'd like to select last edited tree node and do not get event from tree at that moment.
    >
    Second way, prevent selecting a new node if that flag
    has been set. You could do this by subclassing
    DefaultTreeSelectionModel and overriding some methods
    (setSelectionPath() et al).Ok. I'll investigate this.
    >
    MichaelThanks.

  • How to set a particular node selected in a JTree from within the model

    I have an adapter class that provides communication between my JTree and data model. My adapter class implements TreeModel, TreeExpansionListener, TreeSelectionListener and a listener for changes to my data model.
    My data model keeps reference to the currently selected node. It is working quite nicely when I select a tree node with the mouse (the data model is updated accordingly with the node selected), however my problem occurs trying to go the other way (set the selected node in my data model and have it reflected in the tree).
    I know that my selection in the tree is changing correctly as when the selection changes it fires off an event to update the attributes window associated with the currently selected node. I just can't get the node to become highlighted.
    Any ideas would be most welcome.
    Thanks,
    Beck.

    Does your model really have to keep track of the selected item or can the two views (the JTree and the attributes window) not be coupled together in the user interface instead?
    Failing that, you could always consider implementing TreeSelectionModel as well and calling JTree.setSelectionModel since you're keeping track of the tree selection for it already. This is quite a bit of work though.
    If that's too much trouble then if you can work out the TreePath for the node that's been programmatically selected through your model then you could use JTree.getSelectionModel().setSelectionPath. Have a look at tree.getSelectionModel().setSelectedPath(new TreePath(selectedObject)).
    This approach is a bit warped, though, since it implies that your model knows about the view and therefore couples them together.

  • Allow right-click selection in a JTree

    Hi everybody! How are today? Fine? I hope so.
    I've got a little question about JTrees: i want to put a right-click popup menu on my JTree, which may not be the same depending on which node of the tree is selected.
    My problem is that i must do a left click selection of the node before doing the right click in order that this one may be effective and correct (i.e the correct popup menu appears).
    So, i want to allow the right click selection in my JTree to select the node and to perform the action linked to the Popup menu.
    I will be very thankfull if someone could help me :)

    Sorry to post twice, but just thought i'd post the code to show you what I mean (forgive me not making this entirely generic):
    ///// Some "global" variables:
         private JPopupMenu               stPopupMenu;
         private TreePath               stPath;
         private String                    stPathComponent;
         private int                         stCount;
         private Object                    selectedNode;
    ///// Attaching the listeners:
    symbolTreeDisplay.addTreeSelectionListener(stHandler);
    symbolTreeDisplay.addMouseListener(stHandler);
    //// The event listener class:
         private class SymbolTreeHandler extends MouseAdapter implements
                   TreeSelectionListener
              public void mouseClicked(java.awt.event.MouseEvent event)
                   try
                        if (event.getModifiers() == event.BUTTON3_MASK)
                        {//right button click on mouse
                             stPopupMenu = new JPopupMenu();
                             // add your logic here, based on selectedNode to add items to the menu
                             stPopupMenu.show(symbolTreeDisplay, event.getX(), event
                                       .getY());
                   catch (Exception e)
              public void valueChanged(TreeSelectionEvent aTreeEvent)
                   try
                        stPath = aTreeEvent.getPath();
                        stCount = stPath.getPathCount();
                        selectedNode = stPath.getPathComponent(stCount - 1);
                   catch (Exception e)
         }

  • Control Framework tree control event not trigerring

    The event handle_node_double_click is not trigerring on the tree controls . I want to display the contents of the nodes on the text editor on trigerring of this event
    *& Report  ZCONTROLS_TREE_TEDIT_SPITTER
    REPORT  zcontrols_tree_tedit_spitter.
    DATA : editor TYPE REF TO cl_gui_textedit,
           tree   TYPE REF TO cl_gui_simple_tree.
    DATA : container TYPE REF TO cl_gui_custom_container,
           splitter  TYPE REF TO cl_gui_easy_splitter_container,
           right     TYPE REF TO cl_gui_container,
           left      TYPE REF TO cl_gui_container.
    DATA : node_itab LIKE node_str OCCURS 0.
          CLASS EVENT_HANDLER DEFINITION
    CLASS event_handler DEFINITION.
      PUBLIC SECTION.
        METHODS : handle_node_double_click
                  FOR EVENT NODE_DOUBLE_CLICK OF cl_gui_simple_tree
                  IMPORTING node_key.
    ENDCLASS.                    "EVENT_HANDLER DEFINITION
          CLASS EVENT_HANDLER IMPLEMENTATION
    CLASS event_handler IMPLEMENTATION.
      METHOD handle_node_double_click.
      perform node_double_click using node_key.
      ENDMETHOD.                    "HANDLE_NODE_DOUBLE_CLICK
    ENDCLASS.                    "EVENT_HANDLER IMPLEMENTATION
    data : handler1 type ref to event_handler.
    START-OF-SELECTION.
      CALL SCREEN 9001.
    *&      Module  start  OUTPUT
          text
    MODULE start OUTPUT.
      SET PF-STATUS 'ZSTAT1'.
      IF container IS INITIAL.
        CREATE OBJECT container
          EXPORTING
             container_name              = 'CONTAINER_NAME'
          EXCEPTIONS
            cntl_error                  = 1
            cntl_system_error           = 2
            create_error                = 3
            lifetime_error              = 4
            lifetime_dynpro_dynpro_link = 5
            OTHERS                      = 6
        IF sy-subrc <> 0.
          MESSAGE ID sy-msgid TYPE sy-msgty NUMBER sy-msgno
                     WITH sy-msgv1 sy-msgv2 sy-msgv3 sy-msgv4.
        ENDIF.
        CREATE OBJECT splitter
          EXPORTING
            parent            = container
            orientation       = 1
            name              = 'Mohit'
          EXCEPTIONS
            cntl_error        = 1
            cntl_system_error = 2
            OTHERS            = 3
        IF sy-subrc <> 0.
          MESSAGE ID sy-msgid TYPE sy-msgty NUMBER sy-msgno
                     WITH sy-msgv1 sy-msgv2 sy-msgv3 sy-msgv4.
        ENDIF.
        left  = splitter->top_left_container.
        right = splitter->bottom_right_container.
        CREATE OBJECT editor
          EXPORTING
            parent                 = right
            name                   = 'MohitEditor'
          EXCEPTIONS
            error_cntl_create      = 1
            error_cntl_init        = 2
            error_cntl_link        = 3
            error_dp_create        = 4
            gui_type_not_supported = 5
            OTHERS                 = 6
        IF sy-subrc <> 0.
          MESSAGE ID sy-msgid TYPE sy-msgty NUMBER sy-msgno
                     WITH sy-msgv1 sy-msgv2 sy-msgv3 sy-msgv4.
        ENDIF.
        CREATE OBJECT tree
          EXPORTING
            parent                      = left
            node_selection_mode         = tree->node_sel_mode_single
            name                        = 'MohitTree'
          EXCEPTIONS
            lifetime_error              = 1
            cntl_system_error           = 2
            create_error                = 3
            failed                      = 4
            illegal_node_selection_mode = 5
            OTHERS                      = 6
        IF sy-subrc <> 0.
          MESSAGE ID sy-msgid TYPE sy-msgty NUMBER sy-msgno
                     WITH sy-msgv1 sy-msgv2 sy-msgv3 sy-msgv4.
        ENDIF.
        PERFORM fill_tree.
        CALL METHOD tree->add_nodes
          EXPORTING
            table_structure_name           = 'NODE_STR'
            node_table                     = node_itab
          EXCEPTIONS
            error_in_node_table            = 1
            failed                         = 2
            dp_error                       = 3
            table_structure_name_not_found = 4
            OTHERS                         = 5.
        IF sy-subrc <> 0.
          MESSAGE ID sy-msgid TYPE sy-msgty NUMBER sy-msgno
                     WITH sy-msgv1 sy-msgv2 sy-msgv3 sy-msgv4.
        ENDIF.
      create object handler1.
      set handler handler1->handle_node_double_click for tree.
      ENDIF.
    ENDMODULE.                 " start  OUTPUT
    *&      Module  USER_COMMAND_9001  INPUT
          text
    MODULE user_command_9001 INPUT.
      CALL METHOD cl_gui_cfw=>dispatch.
    ENDMODULE.                 " USER_COMMAND_9001  INPUT
    *&      Form  fill_tree
          text
    -->  p1        text
    <--  p2        text
    FORM fill_tree .
      DATA : node LIKE node_str.
      CLEAR node.
      node-node_key = 'head_mohit'.
      node-isfolder = 'X'.
      node-text = 'Mohit'.
      APPEND node TO node_itab.
      CLEAR node.
      node-node_key = 'Child1'.
      node-relatkey = 'head_mohit'.
      node-relatship = cl_gui_simple_tree=>relat_last_child.
      node-text = 'Mohit is the best '.
      APPEND node TO node_itab.
      CLEAR node.
      node-node_key = 'Child2'.
      node-relatkey = 'head_mohit'.
      node-relatship = cl_gui_simple_tree=>relat_last_child.
      node-text = 'Mohit is the bestest '.
      APPEND node TO node_itab.
      CLEAR node.
      node-node_key = 'head_JAIN'.
      node-isfolder = 'X'.
      node-text = 'jAIN'.
      APPEND node TO node_itab.
      CLEAR node.
      node-node_key = 'Child3'.
      node-relatkey = 'head_JAIN'.
      node-relatship = cl_gui_simple_tree=>relat_next_sibling.
      node-text = 'cnh INDIA '.
      APPEND node TO node_itab.
      CLEAR node.
      node-node_key = 'Child4'.
      node-relatkey = 'head_JAIN'.
      node-relatship = cl_gui_simple_tree=>relat_last_child.
      node-text = 'SAP  '.
      APPEND node TO node_itab.
    ENDFORM.                    " fill_tree
    *&      Form  node_double_click
          text
         -->P_NODE_KEY  text
    form node_double_click  using  p_node_key type TV_NODEKEY.
    DATA : node LIKE node_str.
    DATA textline(256).
    DATA text_table LIKE STANDARD TABLE OF textline.
    READ TABLE node_itab WITH KEY node_key = p_node_key
                             INTO node.
    endform.                    " node_double_click
    *&      Module  exit  INPUT
          text
    module exit input.
    CASE sy-ucomm.
        WHEN 'EXIT'.
          LEAVE PROGRAM.
    ENDCASE.
    endmodule.                 " exit  INPUT

    Hello Mohit
    Here is a sample routine (taken from BCALV_TREE_02) which you have to add and adapt for your report. It does two things:
    1. Register events that should be handled (required but not sufficient for event handling)
    2. Set event handler for registered events
    The first step is different from ALV grid controls because here all events are already registered with the control (not the control framework).
    Set the event handler (statement SET HANDLER) registers the event handling with the control framework.
    FORM register_events.
    *§4. Event registration: tell ALV Tree which events shall be passed
    *    from frontend to backend.
      DATA: lt_events TYPE cntl_simple_events,
            l_event TYPE cntl_simple_event,
            l_event_receiver TYPE REF TO lcl_tree_event_receiver.
    *§4a. Frontend registration(i):  get already registered tree events.
    * The following four tree events registers ALV Tree in the constructor
    * method itself.
    *    - cl_gui_column_tree=>eventid_expand_no_children
    * (needed to load data to frontend when a user expands a node)
    *    - cl_gui_column_tree=>eventid_header_context_men_req
    * (needed for header context menu)
    *    - cl_gui_column_tree=>eventid_header_click
    * (allows selection of columns (only when item selection activated))
    *   - cl_gui_column_tree=>eventid_item_keypress
    * (needed for F1-Help (only when item selection activated))
    * Nevertheless you have to provide their IDs again if you register
    * additional events with SET_REGISTERED_EVENTS (see below).
    * To do so, call first method  GET_REGISTERED_EVENTS (this way,
    * all already registered events remain registered, even your own):
    call method g_alv_tree->get_registered_events
          importing events = lt_events.
    * (If you do not these events will be deregistered!!!).
    * You do not have to register events of the toolbar again.
    *§4b. Frontend registration(ii): add additional event ids
      l_event-eventid = cl_gui_column_tree=>eventid_node_double_click.
      APPEND l_event TO lt_events.
    *§4c. Frontend registration(iii):provide new event table to alv tree
      CALL METHOD g_alv_tree->set_registered_events
        EXPORTING
          events = lt_events
        EXCEPTIONS
          cntl_error                = 1
          cntl_system_error         = 2
          illegal_event_combination = 3.
      IF sy-subrc <> 0.
        MESSAGE x208(00) WITH 'ERROR'.     "#EC NOTEXT
      ENDIF.
    *§4d. Register events on backend (ABAP Objects event handling)
      CREATE OBJECT l_event_receiver.
      SET HANDLER l_event_receiver->handle_node_double_click FOR g_alv_tree.
    ENDFORM.                               " register_events
    Regards
      Uwe

  • Af:tree selected item

    I want to display the selected item from a tree (and to store this into a variable). I tried with selection_listener, but I don't know exactly what to write in the bean. The disclosed_row_keys is used to expand all nodes.
    <af:tree value="#{bindings.ConfigTreeParent2.treeModel}"
    var="node"
    rowSelection="single" id="tree1"
    selectionListener="#{left_tree.selection_listener}"
    disclosedRowKeys="#{left_tree.disclosed_row_keys}">
    <f:facet name="nodeStamp">
    <af:outputText value="#{node}"/>
    </f:facet>
    </af:tree>
    Thanks,
    vio

    Hi vio,
    The method signature for selectionListener is
    public void someMethodName(SelectionEvent ev);
    The selection event contains the selected row keys (well actually it contains the delta which should be improved imho like oldSelection and newSelection, but in the case of single selection, you can simply use the added list more or less), you can then extract the data associated with each row keys. So, in your case, I suggest you inject the TreeModel in your bean. Here's an example:
    In the code:
    public class MyTreeController
        private TreeModel model;
        private MySelectionManager selectionManager;
        public TreeModel getTreeModel()
            return model;
        public void setTreeModel(TreeModel model)
            this.model = model;
        public MySelectionManager getSelectionManager()
            return selectionManager;
        public void setSelectionManager(MySelectionManager manager)
            this.selectionManager = manager;
        public void selectionPerformed(SelectionEvent ev)
            Object selected = getFirstRowKey(ev.getAddedSet());
            if (selected == null)
                Object unselected = getFirstRowKey(ev.getRemovedSet());
                if (selectionManager.isSelected(getRowData(unselected)))
                    selectionManager.setSelection(null);
            else
                selectionManager.setSelection(getRowData(selected));
        private Object getFirstRowKey(RowKeySet set)
            for (Object key : set)
                return key;
            return null;
        private Object getRowData(Object rowKey)
            TreeModel model = getTreeModel();
            Object oldRowKey = model.getRowKey();
            try
                model.setRowKey(rowKey);
                return model.getRowData();
            finally
                model.setRowKey(oldRowKey); // Always restore the state
    public class MySelectionManager
        private Object selection; // Or another more precise type
        public Object getSelection()
            return selection;
        public boolean isSelected(Object data)
            return selection != null && selection.equals(data);
        public void setSelection(Object selection)
            this.selection = selection;
    }In the faces-config.xml
    <managed-bean>
      <managed-bean-name>selectionManager</managed-bean-name>
      <managed-bean-class>MySelectionManager</managed-bean-class>
      <managed-bean-scope>pageFlow</managed-bean-scope> <!-- That one can be persistent across requests -->
    </managed-bean>
    <managed-bean>
      <managed-bean-name>treeController</managed-bean-name>
      <managed-bean-class>MyTreeController</managed-bean-class>
      <managed-bean-scope>request</managed-bean-scope>
    <!-- request scope is important here since we don't know the exact lifespan of bindings.ConfigTreeParent2.treeModel -->
      <managed-property>
        <property-name>selectionManager</property-name>
        <property-class>MySelectionManager</property-class>
        <value>#{selectionManager}</value>
      </managed-property>
      <managed-property>
        <property-name>treeModel</property-name>
        <property-class>org.apache.myfaces.trinidad.model.TreeModel</property-class>
        <value>#{bindings.ConfigTreeParent2.treeModel}</value>
      </managed-property>
    </managed-bean>In your page:
    <af:tree value="#{treeController.treeModel}"
             var="node"
             id="tree1"
             rowSelection="single"
             selectionListener="#{treeController.selectionPerformed}"
             disclosedRowKeys="#{left_tree.disclosed_row_keys}">
      <f:facet name="nodeStamp">
        <af:outputText value="#{node}"/>
      </f:facet>
    </af:tree>Note that I preferred to use the tree model from the bean rather than using directly the databindings here. I did so to improve reusability and declarativity of the page as you could now simply alter the injected tree model within the faces-config to have your page point on a completely different data source.
    Regards,
    ~ Simon

  • Setting custom color for selected node in JTree?

    Hi,
    i want to set my own color for selected node in JTree. i don't want to set for all the nodes...how to set Color for Selected node using TreeCellRender class?
    Thanks
    Mani

    I assume you are not setting a custom tree cell renderer...
    javax.swing.JTree theTree = ...;
    java.awt.Color newBGColor = ...;
    ((javax.swing.tree.DefaultTreeCellRenderer)theTree.getCellRenderer())
        .setBackgroundSelectionColor(newColor);

  • Not able to reach start of selection event in the called program

    hi,
    I have a report 1 in which i am calling report2 using below syntax,
    SUBMIT Report2  VIA JOB gv_jobname NUMBER gv_jobcount
                 WITH s_g_yr  IN s_g_yr
                 WITH s_c_rf  IN s_c_rf
    AND RETURN.
    the problem is when report 2 is called it exists after event "at selection screen output" and does not go in the event "start of selection". 
    Please advise. how can i reach the "start of selection" event where all the processing logic is specified..
    Thanks and Regards,
    Kriti

    Hi,
    In your report you have used the event AT SELECTION-SCREEN OUTPUT. So, first it will trigger this event and then it will go for START-OF-SELECTION event.
    Events will trigger in this following way.
    LOAD PROGRAM
    INITIALIZATION
    AT SELECTION-SCREEN
    AT SELECTION-SCREEN OUTPUT
    START-OF-SELECTION
    END-OF-SELECTION
    TOP-OF-PAGE
    END-OF-PAGE
    In above sequence events will trigger in report.
    Regards,
    Shankar.

  • [JS/CS4/CS5] Catching a selection event in a ScriptUI interface.

    I've got this ScriptUI interface (javascript based), and now I wonder if it would be possible to change one of its button captions depending on whether anything is selected or not, in the active document (would also have to be updated if the user selects or opens another document).
    1. Is it possible to write event listeners for this?
    2. Would it be possible to include this in the same script as the rest of the Script UI interface code (that is, I'd prefer avoiding a separate file in the startup folder).
    3. What's the best source of information regarding events, which ones there are, and how to handle them in javascript?
    Andreas

    1. Yes. The selection events work well in my experience.
    2. Yes, you don't have to add them at startup. You can do something like:
    app.addEventListener("afterSelectionChanged", selectionChangedFunction);
    before you open your window. Remove the listener in the onClose event of the window. I think you'll have to have some error trapping in the selectionChangedFunction to deal with app.selection erroring after a document close or during a revert.
    3. See this thread for an extension that lets you see events as they're happening.
    Jeff

  • Finding selected event in iCal

    I want to run a script that processes the currently selected iCal event / todo. (sync it with a Filemaker DB).
    I cant find a command that returns the selected/current/active iCal object. I can only find an object one with a given property value.
    I'm a bit new to this so any pointers would be greatly appreciated.
    OTBC

    Hi OTBC,
    I was waiting for someone to post something Apple maight have added in newer versions of iCal, but I guess they didn't add anything.
    There is no selection property in iCal, but you can create macro like statements to script applications. So, as a wrokaround in iCal, you could use keystrokes to get the name of the currently selected event.
    tell application "iCal" to activate
    tell application "System Events"
    tell process "iCal"
    keystroke return
    keystroke "c" using command down
    end tell
    end tell
    This would copy the summary of to selected event. You could tab to tab through the information for the event. This might help you pinpoint the event in the case where there are several events with the same summary. Like a macro you would have to test it out in iCal to find the right combination of keystroke and ui scripting.
    Note that it is very hard to get recurrence events.
    gl,

  • A function for generate a actual tree select

    hi,
    i tried to write a function that generate a actual tree select and i think this is very helpful
    Create Or Replace Function Generate_Tree_Fun(p_Path Varchar2,
    p_Delimiter Varchar2,
    p_Level Integer,
    p_Tbl_Name Varchar2,
    p_Parent_Field Varchar2,
    p_Child_Filed Varchar2)
    Return Varchar2 Is
    v_Txt Varchar2(5000) := '';
    v_Row_Num Number;
    v_Max_Count Number;
    v_Child Varchar2(100);
    v_Parent Varchar2(100);
    v_Level Number := p_Level;
    Begin
    If (v_Level = 1) Then
    Return '';
    End If;
    If (v_Level > 1) Then
    v_Txt := '|' || Lpad('_', 6, '_');
    End If;
    If (v_Level > 2) Then
    For i In 1 .. p_Level - 2 Loop
    v_Level := v_Level - 1;
    v_Child := Ltrim(Regexp_Replace(p_Path,
    Ltrim(Replace(p_Path,
    p_Delimiter,
    ')(' || p_Delimiter) || ')',
    '\' || v_Level),
    p_Delimiter);
    Execute Immediate 'Select t.' || p_Parent_Field || '
    From ' || p_Tbl_Name || ' t
    Where t.' || p_Child_Filed || ' = :1'
    Into v_Parent
    Using v_Child;
    Execute Immediate 'Select a, b From (Select Row_Number() Over(Order By t.' ||
    p_Child_Filed ||
    ') a,Count(1) Over(Partition By t.' ||
    p_Parent_Field || ') b,t.' || p_Child_Filed ||
    ',t.' || p_Parent_Field || ' From ' || p_Tbl_Name ||
    ' t Where t.' || p_Parent_Field ||
    ' = :1 Order By t.' || p_Child_Filed || ') Where ' ||
    p_Child_Filed || ' = :2 '
    Into v_Row_Num, v_Max_Count
    Using v_Parent, v_Child;
    If (v_Row_Num <> v_Max_Count) Then
    v_Txt := Rpad('|', 20, ' ') || v_Txt;
    Else
    v_Txt := Rpad(' ', 20, ' ') || v_Txt;
    End If;
    End Loop;
    End If;
    Return v_Txt;
    End;
    select Generate_Tree_Fun(sys_connect_by_path(e.empno,','),',',level,'emp','mgr','empno') || e.ename
    from emp e
    start with mgr is null
    connect by e.mgr=prior e.empno
    enjoy it

    Arash wrote:
    hi,
    i tried to write a function that generate a actual tree select and i think this is very helpful
    We are so proud of you!

  • Since I upgraded to Yosemite I can no longer upload photos to eBay by selecting "events"  all my photos pop up together.  Anyone know how to fix this?

    I recently updated to Yosemite 10.10.1.  Since I updated I can no longer upload photos to eBay, Shutterfly, Craigslist by selecting "events".  It is no longer an option.
    All my photos come up as one entire library.  When I view them in iPhoto they are divided into events, however once I go to upload them the entire library appears without any defining options, such as "events", recent imports, etc.   I thought at first this might be an issue with eBay, but realized it wasn't when I tried to list on Craigslist.  This is a nuisance and time consuming process.  Does anyone know if there is a fix in the future or if I am just missing some quick fix?

    I would like to add that Comcast is my internet provider. Perhaps that is part of the issue although the Connection Doctor confirms the mail box is connecting to the internet. No other function processes when Connection Doctor program is used to find the source of the issue. I have read forum posts but am unable to find a way to get my Apple mail to be delivered to my computer. It worked fine up until I chose to transfer mail to the Cloud. My mail account is a .mac account.
    Still hoping someone out there can help me.
    thanks,
    anne

  • Error in at line-selection event...

    Hello experts,
    In my report, I am hiding the values of BUKRS, ANLN1 and ANLN2 during my loop.
    I am using field symbols as my work area for my itab which is it_output. The problem
    is, when I try to do this in my at line-selection event:
    at line-selection.
    data: cursorfield(20) type c.
        get cursor field cursorfield.
        case cursorfield.
         when '<FS_OUTPUT>-ASSET_SUBNUM'.
         SET PARAMETER ID 'BUK' FIELD <FS_OUTPUT>-bukrs.
         SET PARAMETER ID 'AN1' FIELD <FS_OUTPUT>-asset.
         SET PARAMETER ID 'AN2' FIELD <FS_OUTPUT>-anln2.
        endcase.
    It says that it can't recognize the fields. What am I doing wrong? By the way, I am using
    ABAP Objects in my report. Help would be greatly appreciated. Thanks again guys and take care!

    Hi Viraylab,
    Have you assigned the fieldsymbols ?
    ASSIGN IT_OUTPUT to <FS_OUTPUT>.
    Cheers
    VJ
    Message was edited by: Vijayendra  Rao

Maybe you are looking for