Deleting Tree Node
Hello All
I am Creating a Tree and It is going to Populate only when the Node is Expanded.
I.E. the Child records are created only when the Node is Expanded.
What we Did is that when we are creating a Parent Node, we are populating a dummy child node to the Parent Node, so that the + sign will be shown.
Now when I am Expanding the + sign, it has to delete the Dummy child node and then create the Child nodes under the Dummy one.
For this One I am unable to Find a solution.
PLEASE HELP ME REGARDING THIS ONE.
THIS PROBLEM IS RELATING TO FORMS
In the when-tree-node-expanded trigger.
Store the system.trigger_node. This is the parent.
Search, starting with the parent, for a child which has the value/label that you gave the dummy node. Did you find one? If yes then delete it.
If you didn't find one then you stop as you've already expanded this node I guess.
After you delete the child you must then add the new children. So loop through the code that produces the list of new children you want, and add them under the parent that you started with.
Hope this helps.
Similar Messages
-
I have created a tree table
create table subforums (
id NUMBER(5) primary key,
parent_id references subforums,
name varchar2(100)
And now i dont know how to delete a tree with a specified id and all of his children.
I tried to find out but i couldntHi,
When you delete a node and all of its children, what do you want to do with the grandchildren? If you want to set their parent_id to NULL, do that in a separate UPDATE statement first, then DELETE the original node and all its remaining descendants, as show below.
If, when you say "children", you mean "descendants" (including
children,
children of children,
children of children of children,
and so on, to any level,
) then do a CONNECT BY query to find their primary keys, and DELETE everything in that list, like this:
DELETE subforms
WHERE id IN
SELECT id
FROM subforms
START WITH id = :specified_id
CONNECT BY PRIOR id = parent_id
); -
Add/Edit/Delete Tree Nodes using CL_GUI_ALV_TREE
Hi All,
I am looking for an example of program with CL_GUI_ALV_TREE that have a functionality of add a tree node, edit a tree node, and delete a tree node.
I have already looked the BCALV_TREE* demo program but could not able to find a program to add/edit/delete node tree elements.
Any info on this.
Thanks
aRsHello aRs
Here is a sample report showing how to delete nodes in an ALV tree. The report was copied from BCALV_TREE_01. Search for added code:
*$ADDED: begin
*$ADDED: end[/code]
When you display the tree expand the first folder completely. When entering 'DELETE' into the command field directly the first flight date node will be deleted.
REPORT ZUS_SDN_BCALV_TREE_01_DELNODE.
based on: REPORT bcalv_tree_01.
Purpose:
~~~~~~~~
This report shows the essential steps to build up a hierarchy
using an ALV Tree Control (class CL_GUI_ALV_TREE).
Note that it is not possible to build up this hierarchy
using a simple ALV Tree Control (class CL_GUI_ALV_TREE_SIMPLE).
To check program behavior
~~~~~~~~~~~~~~~~~~~~~~~~~
Start this report. The hierarchy tree consists of nodes for each
month on top level (this level can not be build by a simple ALV Tree
because there is no field for months in our output table SFLIGHT.
Thus, you can not define this hierarchy by sorting).
Nor initial calculations neither a special layout has been applied
(the lines on the right do not show anything).
Note also that this example does not build up and change the
fieldcatalog of the output table. For this reason, all fields
of the output table are shown in the columns although the fields
CARRID and FLDATE are already placed in the tree on the left.
(Of course, this is not a good style. See BCALV_TREE_02 on how to
hide columns).
Essential steps (Search for '§')
~~~~~~~~~~~~~~~
1.Usual steps when using control technology.
1a. Define reference variables.
1b. Create ALV Tree Control and corresponding container.
2.Create Hierarchy-header
3.Create empty Tree Control
4.Create hierarchy (nodes and leaves)
4a. Select data
4b. Sort output table according to your conceived hierarchy
4c. Add data to tree
5.Send data to frontend.
6.Call dispatch to process toolbar functions
*$ADDED: begin
DATA:
gd_del_nkey TYPE lvc_nkey.
*$ADDED: end
§1a. Define reference variables
DATA: g_alv_tree TYPE REF TO cl_gui_alv_tree,
g_custom_container TYPE REF TO cl_gui_custom_container.
DATA: gt_sflight TYPE sflight OCCURS 0, "Output-Table
ok_code LIKE sy-ucomm,
save_ok LIKE sy-ucomm, "OK-Code
g_max TYPE i VALUE 255.
END-OF-SELECTION.
CALL SCREEN 100.
*& Module PBO OUTPUT
process before output
MODULE pbo OUTPUT.
SET PF-STATUS 'MAIN100'.
SET TITLEBAR 'MAINTITLE'.
IF g_alv_tree IS INITIAL.
PERFORM init_tree.
CALL METHOD cl_gui_cfw=>flush
EXCEPTIONS
cntl_system_error = 1
cntl_error = 2.
IF sy-subrc NE 0.
CALL FUNCTION 'POPUP_TO_INFORM'
EXPORTING
titel = 'Automation Queue failure'(801)
txt1 = 'Internal error:'(802)
txt2 = 'A method in the automation queue'(803)
txt3 = 'caused a failure.'(804).
ENDIF.
ENDIF.
ENDMODULE. " PBO OUTPUT
*& Module PAI INPUT
process after input
MODULE pai INPUT.
save_ok = ok_code.
CLEAR ok_code.
CASE save_ok.
WHEN 'EXIT' OR 'BACK' OR 'CANC'.
PERFORM exit_program.
*$ADDED: begin
WHEN 'DELETE'.
CALL METHOD g_alv_tree->delete_subtree
EXPORTING
i_node_key = gd_del_nkey
I_UPDATE_PARENTS_EXPANDER = SPACE
i_update_parents_folder = 'X'
EXCEPTIONS
node_key_not_in_model = 1
OTHERS = 2.
IF sy-subrc <> 0.
MESSAGE ID SY-MSGID TYPE SY-MSGTY NUMBER SY-MSGNO
WITH SY-MSGV1 SY-MSGV2 SY-MSGV3 SY-MSGV4.
ENDIF.
CALL METHOD g_alv_tree->frontend_update.
*$ADDED: end
WHEN OTHERS.
§6. Call dispatch to process toolbar functions
CALL METHOD cl_gui_cfw=>dispatch.
ENDCASE.
CALL METHOD cl_gui_cfw=>flush.
ENDMODULE. " PAI INPUT
*& Form init_tree
text
--> p1 text
<-- p2 text
FORM init_tree.
§1b. Create ALV Tree Control and corresponding Container.
create container for alv-tree
DATA: l_tree_container_name(30) TYPE c.
l_tree_container_name = 'CCONTAINER1'.
CREATE OBJECT g_custom_container
EXPORTING
container_name = l_tree_container_name
EXCEPTIONS
cntl_error = 1
cntl_system_error = 2
create_error = 3
lifetime_error = 4
lifetime_dynpro_dynpro_link = 5.
IF sy-subrc <> 0.
MESSAGE x208(00) WITH 'ERROR'(100).
ENDIF.
create tree control
CREATE OBJECT g_alv_tree
EXPORTING
parent = g_custom_container
node_selection_mode = cl_gui_column_tree=>node_sel_mode_single
item_selection = 'X'
no_html_header = 'X'
no_toolbar = ''
EXCEPTIONS
cntl_error = 1
cntl_system_error = 2
create_error = 3
lifetime_error = 4
illegal_node_selection_mode = 5
failed = 6
illegal_column_name = 7.
IF sy-subrc <> 0.
MESSAGE x208(00) WITH 'ERROR'. "#EC NOTEXT
ENDIF.
§2. Create Hierarchy-header
The simple ALV Tree uses the text of the fields which were used
for sorting to define this header. When you use
the 'normal' ALV Tree the hierarchy is build up freely
by the programmer this is not possible, so he has to define it
himself.
DATA l_hierarchy_header TYPE treev_hhdr.
PERFORM build_hierarchy_header CHANGING l_hierarchy_header.
§3. Create empty Tree Control
IMPORTANT: Table 'gt_sflight' must be empty. Do not change this table
(even after this method call). You can change data of your table
by calling methods of CL_GUI_ALV_TREE.
Furthermore, the output table 'gt_outtab' must be global and can
only be used for one ALV Tree Control.
CALL METHOD g_alv_tree->set_table_for_first_display
EXPORTING
i_structure_name = 'SFLIGHT'
is_hierarchy_header = l_hierarchy_header
CHANGING
it_outtab = gt_sflight. "table must be empty !
§4. Create hierarchy (nodes and leaves)
PERFORM create_hierarchy.
§5. Send data to frontend.
CALL METHOD g_alv_tree->frontend_update.
wait for automatic flush at end of pbo
ENDFORM. " init_tree
*& Form build_hierarchy_header
build hierarchy-header-information
-->P_L_HIERARCHY_HEADER strucxture for hierarchy-header
FORM build_hierarchy_header CHANGING
p_hierarchy_header TYPE treev_hhdr.
p_hierarchy_header-heading = 'Month/Carrier/Date'(300).
p_hierarchy_header-tooltip = 'Flights in a month'(400).
p_hierarchy_header-width = 30.
p_hierarchy_header-width_pix = ' '.
ENDFORM. " build_hierarchy_header
*& Form exit_program
free object and leave program
FORM exit_program.
CALL METHOD g_custom_container->free.
LEAVE PROGRAM.
ENDFORM. " exit_program
*& Form create_hierarchy
text
--> p1 text
<-- p2 text
FORM create_hierarchy.
DATA: ls_sflight TYPE sflight,
lt_sflight TYPE sflight OCCURS 0,
l_yyyymm(6) TYPE c, "year and month of sflight-fldate
l_yyyymm_last(6) TYPE c,
l_carrid LIKE sflight-carrid,
l_carrid_last LIKE sflight-carrid.
DATA: l_month_key TYPE lvc_nkey,
l_carrid_key TYPE lvc_nkey,
l_last_key TYPE lvc_nkey.
§4a. Select data
SELECT * FROM sflight INTO TABLE lt_sflight UP TO g_max ROWS.
§4b. Sort output table according to your conceived hierarchy
We sort in this order:
year and month (top level nodes, yyyymm of DATS)
carrier id (next level)
day of month (leaves, dd of DATS)
SORT lt_sflight BY fldate0(6) carrid fldate6(2).
Note: The top level nodes do not correspond to a field of the
output table. Instead we use data of the table to invent another
hierarchy level above the levels that can be build by sorting.
§4c. Add data to tree
LOOP AT lt_sflight INTO ls_sflight.
Prerequesite: The table is sorted.
You add a node everytime the values of a sorted field changes.
Finally, the complete line is added as a leaf below the last
node.
l_yyyymm = ls_sflight-fldate+0(6).
l_carrid = ls_sflight-carrid.
Top level nodes:
IF l_yyyymm <> l_yyyymm_last. "on change of l_yyyymm
l_yyyymm_last = l_yyyymm.
*Providing no key means that the node is added on top level:
PERFORM add_month USING l_yyyymm
CHANGING l_month_key.
The month changed, thus, there is no predecessor carrier
CLEAR l_carrid_last.
ENDIF.
Carrier nodes:
(always inserted as child of the last month
which is identified by 'l_month_key')
IF l_carrid <> l_carrid_last. "on change of l_carrid
l_carrid_last = l_carrid.
PERFORM add_carrid_line USING ls_sflight
l_month_key
CHANGING l_carrid_key.
ENDIF.
Leaf:
(always inserted as child of the last carrier
which is identified by 'l_carrid_key')
PERFORM add_complete_line USING ls_sflight
l_carrid_key
CHANGING l_last_key.
ENDLOOP.
ENDFORM. " create_hierarchy
*& Form add_month
FORM add_month USING p_yyyymm TYPE c
p_relat_key TYPE lvc_nkey
CHANGING p_node_key TYPE lvc_nkey.
DATA: l_node_text TYPE lvc_value,
ls_sflight TYPE sflight,
l_month(15) TYPE c. "output string for month
get month name for node text
PERFORM get_month USING p_yyyymm
CHANGING l_month.
l_node_text = l_month.
add node:
ALV Tree firstly inserts this node as a leaf if you do not provide
IS_NODE_LAYOUT with field ISFOLDER set. In form 'add_carrid_line'
the leaf gets a child and thus ALV converts it to a folder
automatically.
CALL METHOD g_alv_tree->add_node
EXPORTING
i_relat_node_key = p_relat_key
i_relationship = cl_gui_column_tree=>relat_last_child
i_node_text = l_node_text
is_outtab_line = ls_sflight
IMPORTING
e_new_node_key = p_node_key.
ENDFORM. " add_month
FORM add_carrid_line USING ps_sflight TYPE sflight
p_relat_key TYPE lvc_nkey
CHANGING p_node_key TYPE lvc_nkey.
DATA: l_node_text TYPE lvc_value,
ls_sflight TYPE sflight.
add node
ALV Tree firstly inserts this node as a leaf if you do not provide
IS_NODE_LAYOUT with field ISFOLDER set. In form 'add_carrid_line'
the leaf gets a child and thus ALV converts it to a folder
automatically.
l_node_text = ps_sflight-carrid.
CALL METHOD g_alv_tree->add_node
EXPORTING
i_relat_node_key = p_relat_key
i_relationship = cl_gui_column_tree=>relat_last_child
i_node_text = l_node_text
is_outtab_line = ls_sflight
IMPORTING
e_new_node_key = p_node_key.
ENDFORM. " add_carrid_line
*& Form add_complete_line
FORM add_complete_line USING ps_sflight TYPE sflight
p_relat_key TYPE lvc_nkey
CHANGING p_node_key TYPE lvc_nkey.
DATA: l_node_text TYPE lvc_value.
WRITE ps_sflight-fldate TO l_node_text MM/DD/YYYY.
add leaf:
ALV Tree firstly inserts this node as a leaf if you do not provide
IS_NODE_LAYOUT with field ISFOLDER set.
Since these nodes will never get children they stay leaves
(as intended).
CALL METHOD g_alv_tree->add_node
EXPORTING
i_relat_node_key = p_relat_key
i_relationship = cl_gui_column_tree=>relat_last_child
is_outtab_line = ps_sflight
i_node_text = l_node_text
IMPORTING
e_new_node_key = p_node_key.
*$ADDED: begin
IF ( ps_sflight-fldate = '20040522' ). " first flight date
IF ( gd_del_nkey IS INITIAL ). " collect only first date
gd_del_nkey = p_node_key.
ENDIF.
ENDIF.
*$ADDED: end
ENDFORM. " add_complete_line
*& Form GET_MONTH
text
-->P_P_YYYYMM text
<--P_L_MONTH text
FORM get_month USING p_yyyymm
CHANGING p_month.
Returns the name of month according to the digits in p_yyyymm
DATA: l_monthdigits(2) TYPE c.
l_monthdigits = p_yyyymm+4(2).
CASE l_monthdigits.
WHEN '01'.
p_month = 'January'(701).
WHEN '02'.
p_month = 'February'(702).
WHEN '03'.
p_month = 'March'(703).
WHEN '04'.
p_month = 'April'(704).
WHEN '05'.
p_month = 'May'(705).
WHEN '06'.
p_month = 'June'(706).
WHEN '07'.
p_month = 'July'(707).
WHEN '08'.
p_month = 'August'(708).
WHEN '09'.
p_month = 'September'(709).
WHEN '10'.
p_month = 'October'(710).
WHEN '11'.
p_month = 'November'(711).
WHEN '12'.
p_month = 'December'(712).
ENDCASE.
CONCATENATE p_yyyymm+0(4) '->' p_month INTO p_month.
ENDFORM. " GET_MONTH
/code
Regards
Uwe -
Finding a deleted tree node yields something other than 0...
I FIND_TREE_NODE a deleted node, it keeps giving me
1232280 (I didn't make it up) instead of 0 as the node
identifier... Can anyone shed some light on this?I FIND_TREE_NODE a deleted node, it keeps giving me
1232280 (I didn't make it up) instead of 0 as the node
identifier... Can anyone shed some light on this? -
Tree and Tree Node Components - Threadinar7
Hi All,
This is the seventh in the "Threadinar" series , please see Threadinar6 at
http://forum.sun.com/jive/thread.jspa?threadID=100601 for details
In this Threadinar we will focus on the
"Tree" and "Tree Node" Components
Let us begin our discussion with the Tree Component.
Tree Component
You can drag the Tree component from the Palette's Basic category to the Visual Designer to create a hierarchical tree structure with nodes that can be expanded and collapsed, like the nodes in the Outline window. When the user clicks a node, the row will be highlighted. A tree is often used as a navigation mechanism.
A tree contains Tree Node components, which act like hyperlinks. You can use a Tree Node to navigate to another page by setting its url property. You can also use a Tree Node to submit the current page. If the the Tree Node's action property is bound to an action event handler, selecting the node automatically submits the page. If the Tree Node's actionListener property is bound to an action listener, opening or closing the node automatically submits the page. You set Tree Node properties in the Tree Node Component Properties window.
* If you use this component to navigate between pages of a portlet, do not use the url property to link to a page. Instead, use the Navigation editor to set up your links to pages.
* Events related to tree node selection do not work correctly in portlets because the component uses cookies to pass the selected node id back and forth, and cookies are not correctly handled by the portlet container. You cannot handle tree node selection events in portlet projects.
Initially when you drop a tree on a page, it has one root node labeled Tree and one subnode labeled Tree Node 1. You can add more nodes by dragging them to the tree and dropping them either on the root node to create top level nodes or on existing nodes to create subnodes of those nodes. You can also right-click the Tree or any Tree Node and choose Add Tree Node to add a subnode to the node.
Additionally, you can work with the component in the Outline window, where the component and its child components are available as nodes. You can move a node from level to level easily in the Outline window, so you might want to work there if you are rearranging nodes. You can also add and delete tree nodes in the Outline window, just as in the Visual Designer.
The Tree component has properties that, among other things, enable you change the root node's displayed text, change the appearance of the text, specify if expanding or collapsing a node requires a trip to the server, and specify whether node selection should automatically open or close the tree. To set the Tree's properties, select the Tree component in your page and use the Tree Component Properties window.
The following Tutorial ("Using Tree Component") is very useful to learn using Tree components
http://developers.sun.com/prodtech/javatools/jscreator/learning/tutorials/2/sitemaptree.html
See Also the Technical Article - "Working with the Tree Component and Tree Node Actions"
http://developers.sun.com/prodtech/javatools/jscreator/reference/techart/2/tree_component.html
Tree Node Component
You can drag the Tree Node component from the Palette's Basic category to a Tree component or another tree node in the Visual Designer to create a node in a hierarchical tree structure, similar to the tree you see in the Outline window.
The tree node is created as a subnode of the node on which you drop it. If you drop the node on the tree component itself, a new node is created as a child of the root node. You can see the hierarchical structure clearly in the Outline window, where you can also easily move nodes around and reparent them.
You can also add a tree node either to a Tree component or to a Tree Node component by right-clicking the component and choosing Add Tree Node.
A Tree Node component by default is a container for an image and can be used to navigate to another page, submit the current page, or simply open or close the node if the node has child nodes.
* If you select the Tree Node component's node Tree Node icon in the Outline window, you can edit its properties in the Tree Node Properties window. You can set things like whether or not the Tree Node is expanded by default, the tooltip for the Tree Node, the label for the tree node, and the Tree Node's identifier in your web application.
* You can use a Tree Node to navigate to another page by setting its url property. You can also use a Tree Node to submit the current page. If the the Tree Node's action property is bound to an action event handler, selecting the node automatically submits the page. If the Tree Node's actionListener property is bound to an action listener, opening or closing the node automatically submits the page.
- Note: If you use this component to navigate between pages of a portlet, do not use the url property to link to a page. Instead, use the Navigation editor to set up your links to pages. In addition, events related to tree node selection do not work correctly in portlets because the component uses cookies to pass the selected node id back and forth, and cookies are not correctly handled by the portlet container. You cannot handle tree node selection events in portlet projects.
* If you select the image in the Tree Node, you can see that its icon property is set to TREE_DOCUMENT. If you right-click the image on the page and choose Set Image, you can either change the icon to another one or choose your own image in the Image Customizer dialog box. For more information on working with an image in a tree node, see Image component.
- Note: The image used in a tree node works best if it is 16x16 or smaller. Larger images can work, but might appear overlapped in the Visual Designer. You can right-click the component and choose Preview in Browser feature to check the appearance of the images.
Please share your comments, experiences, additional information, questions, feedback, etc. on these components.
------------------------------------------------------------------------------- --------------------One challenge I had experience was to make the tree
always expanded on all pages (I placed my tree menu
in a page fragment so I can just import it in my
pages).Did you solve this problem. It would be interesting to know what you did.
To expand a node you call setExpanded on the node. Here is some code from a tutorial that a coworker of mine is working on.
In the prerender method:
Integer expandedPersonId = getRequestBean1().getPersonId();
// If expandedPersonId is null, then we are not coming back
// from the Trip page. In that case we do not want any trip
// nodes to be pre-selected (highlighted) due to browser cookies.
if (expandedPersonId==null) {
try {
HttpServletRequest req =(HttpServletRequest)
getExternalContext().getRequest();
Cookie[] cookies = req.getCookies();
//Check if cookies are set
if (cookies != null) {
for (int loop =0; loop < cookies.length; loop++) {
if (cookies[loop].getName().equals
("form1:displayTree-hi")) {
cookies[loop].setMaxAge(0);
HttpServletResponse response =(HttpServletResponse)
getExternalContext().getResponse();
response.addCookie(cookies[loop]);
} catch (Exception e) {
error("Failure trying to clear highlighting of selected node:" +
e.getMessage());
} ... (in a loop for tree nodes)...
personNode.setExpanded(newPersonId.equals
(expandedPersonId));In the action method for the nodes:
// Get the client id of the currently selected tree node
String clientId = displayTree.getCookieSelectedTreeNode();
// Extract component id from the client id
String nodeId = clientId.substring(clientId.lastIndexOf(":")+1);
// Find the tree node component with the given id
TreeNode selectedNode =
(TreeNode) this.getForm1().findComponentById(nodeId);
try {
// Node's id property is composed of "trip" plus the trip id
// Extract the trip id and save it for the next page
Integer tripId = Integer.valueOf(selectedNode.getId().substring(4));
getRequestBean1().setTripId(tripId);
} catch (Exception e) {
error("Can't convert node id to Integer: " +
selectedNode.getId().substring(4));
return null;
It would also be great if I can set the tree
readonly where the user cannot toggle the expand
property of the tree (hope this can be added to the
tree functionality). -
I want to delete all tree node at a time
hi all
i built my tree manualy using ftree.add_tree_node (not by record group and populate the RG) and i want to delete all tree nodes at a time in one statment
please urgenthi
try something like this.
DECLARE
htree ITEM;
num_selected NUMBER;
BEGin
-- Find the tree itself.
htree := Find_Item('tree_block.htree3');
-- Find the number of nodes marked as selected.
num_selected := Ftree.Get_tree_Property(htree, Ftree.SELECTION_COUNT);
-- Loop through nodes and delete them. Since nodes are internally
-- re-numbered when one is deleted, be sure to loop in reverse
-- order from last to first.
FOR j in num_selected..1 LOOP
Ftree.delete_tree_node(htree, Ftree.Get_tree_Selection(htree, j));
END LOOP;
END;If its Correct/helpful please mark it thanks.
Sarah -
Deleting a RichTree component tree node
Hi,
I would like to delete a node in a tree and have that reflected in my tree model. Can anyone help with some sample code on how to do this? I'm using the RichTree component in JDev 11g.
Thanks
ColinColin,
Here are two good blog entries that demonstrates how-to programmatically manipulate the tree component and its underlying CollectionModel. In 11 the APIs on the CollectionModel remain unchanged other than being repackaged into an Apache Trinidad package. Neither entry shows you how to delete a node but this is as simple as removing an item from the CollectionModel and refreshing the tree. See if that helps.
http://technology.amis.nl/blog/?p=1313
http://thepeninsulasedge.com/blog/2006/10/10/adf-faces-working-with-the-aftree/
--Ric -
I have to delete all selected node in JTree. any idea.
..if root is also selected with child and only child should get deleted..For each delete-candidate node x you could check if there is a delete-candidate node y
(other than x) that has node x in its PathToRoot-array ( DefaultTreeModel#getPathToRoot(y) ).
If yes, simply set the path of x to null, so you can skip the nulls later on.
Message was edited by:
Andre_Uhres
Message was edited by:
Andre_Uhres -
I have to read the contents form an ldif file and display it with in a tree, in that the first dn, should be displayed as root dn, and next as child nodes with all the properties of dn.
I displayed all the dn's but am not understanding how to take root dn and child nodes. please help me if any one know.
Thanks,
RagaHi,
When you delete a node and all of its children, what do you want to do with the grandchildren? If you want to set their parent_id to NULL, do that in a separate UPDATE statement first, then DELETE the original node and all its remaining descendants, as show below.
If, when you say "children", you mean "descendants" (including
children,
children of children,
children of children of children,
and so on, to any level,
) then do a CONNECT BY query to find their primary keys, and DELETE everything in that list, like this:
DELETE subforms
WHERE id IN
SELECT id
FROM subforms
START WITH id = :specified_id
CONNECT BY PRIOR id = parent_id
); -
Selecting a RichTree component tree node
Hi,
How do I get the selected tree node in a RichTree component?. I would like to select the node with the mouse and possibly use the popup menu to initiate an action (e.g. delete). How do I add an item to the popup menu to do this? I'm using the RichTree component in JDev 11g. Any sample code would be helpful.
Thanks
ColinColin,
To perform some operation on node selection within af:tree component you simply need to create a selectionlistener and decorate the tree component with the listener you implemented. For the context-menu you describe the af:tree has an attribute named contextMenuId. Set the value of this attribute to equal the id of an af:popup that contains an af:menu that represents the menu that you want displayed on a right-click. Below is a link to the tag doc for the af:tree component
http://www.oracle.com/technology/products/adf/adffaces/11/doc/multiproject/adf-richclient-api/tagdoc/af_tree.html
--Ric -
Hi All,
Can anyone help me to implement Tree node in F4 Search help?
Thanks
E KarthikeyanSAP has provided a lot of sample programs for developing tree structures. Just go to SE38, type BCALVTREE and hit F4. You'll get different sample programs with a range of operations on trees
Go through the link,
http://www.sapdevelopment.co.uk/reporting/alv/alvtree.htm
Slowly check this code..you will get idea of how to develop tree structure.
REPORT y_hierarchies_in_tables
NO STANDARD PAGE HEADING.
PARAMETER: g_group TYPE grpname. " DEFAULT 'Z_GLAB0000'.
DATA:
g_setid TYPE setid,
g_class TYPE setclass.
DATA: lt_hier TYPE STANDARD TABLE OF sethier,
lt_val TYPE STANDARD TABLE OF setvalues.
DATA: hier LIKE sethier OCCURS 0 WITH HEADER LINE,
val LIKE setvalues OCCURS 0 WITH HEADER LINE,
setinfo LIKE setinfo OCCURS 0 WITH HEADER LINE.
DATA: zaccbas(20) TYPE c OCCURS 0 WITH HEADER LINE.
DATA: miss_val LIKE setvalues-from OCCURS 0 WITH HEADER LINE.
DATA: table_name TYPE tabname,
field_name TYPE setfld.
DATA: ambiguity_flag TYPE c.
Ambiguity check
PERFORM ambiguity_check.
Display Records
PERFORM display_records.
*& Form AMBIGUITY_CHECK
Ambiguity check
FORM ambiguity_check .
DATA: it_abaplist LIKE abaplist OCCURS 0 WITH HEADER LINE.
DATA: BEGIN OF it_ascilist OCCURS 0,
zeile(256) TYPE c,
END OF it_ascilist.
DATA: flag.
SUBMIT rgsovl00 "VIA SELECTION-SCREEN
WITH p_shrtn = g_group
WITH path = 'X'
EXPORTING LIST TO MEMORY
AND RETURN.
CALL FUNCTION 'LIST_FROM_MEMORY'
TABLES
listobject = it_abaplist
EXCEPTIONS
not_found = 1
OTHERS = 2.
CALL FUNCTION 'LIST_TO_ASCI'
TABLES
listasci = it_ascilist
listobject = it_abaplist
EXCEPTIONS
empty_list = 1
list_index_invalid = 2
OTHERS = 3 .
LOOP AT it_ascilist.
IF it_ascilist-zeile = text-001.
flag = 'X'.
ENDIF.
IF flag = 'X' AND
it_ascilist-zeile = text-002.
ambiguity_flag = 'X'.
CLEAR flag.
ENDIF.
ENDLOOP.
FREE MEMORY.
ENDFORM. " AMBIGUITY_CHECK
*& Form DISPLAY_RECORDS
Display the Records
FORM display_records .
PERFORM get_records.
PERFORM header_data.
PERFORM item_data.
ENDFORM. " DISPLAY_RECORDS
*& Form GET_RECORDS
Get all the Node values
FORM get_records .
Get the ID name for the Hierarchy
CALL FUNCTION 'G_SET_GET_ID_FROM_NAME'
EXPORTING
shortname = g_group
setclass = g_class
old_setid = g_setid
IMPORTING
new_setid = g_setid.
Get the Table and Field name for the Top Node
CALL FUNCTION 'G_SET_GET_INFO'
EXPORTING
setname = g_setid
no_set_title = 'X'
use_table_buffer = 'X'
IMPORTING
info = setinfo.
table_name = setinfo-tabname.
field_name = setinfo-fld.
Get all the Nodes for the Hierarchy
CALL FUNCTION 'G_SET_TREE_IMPORT'
EXPORTING
no_descriptions = ' '
no_rw_info = 'X'
setid = g_setid
TABLES
set_hierarchy = lt_hier
set_values = lt_val.
hier[] = lt_hier.
val[] = lt_val.
SELECT (field_name) FROM (table_name) INTO TABLE zaccbas.
LOOP AT zaccbas.
READ TABLE val WITH KEY FROM = zaccbas.
IF sy-subrc = 0.
DELETE zaccbas.
CLEAR zaccbas.
DELETE val INDEX sy-tabix.
CLEAR val.
ENDIF.
ENDLOOP.
ENDFORM. " GET_RECORDS
*& Form HEADER_DATA
Header Data
FORM header_data .
DATA: desc TYPE settext.
READ TABLE hier WITH KEY fieldname = field_name
shortname = g_group.
IF sy-subrc = 0.
desc = hier-descript.
ENDIF.
SKIP.
WRITE: 'Node :',g_group.
WRITE:75 'User name :', sy-uname.
WRITE:/ 'Description :', desc.
WRITE:75 'Date:', sy-datum.
WRITE:/ 'Table Name :' , table_name.
WRITE:75 'Time:', sy-timlo.
WRITE:/ 'Field Name :', field_name.
write:75 'Client:', SY-MANDT.
skip.
IF ambiguity_flag = 'X'.
WRITE:/ 'Ambiguity Check :'. WRITE: 'Success' COLOR 5.
ELSE.
WRITE:/ 'Ambiguity Check :'. WRITE: 'Failed' COLOR 6 .
ENDIF.
WRITE:/ sy-uline.
WRITE:/37 'Validation for Hierarchy'.
WRITE:/ sy-uline.
ENDFORM. " HEADER_DATA
*& Form ITEM_DATA
Output Report for Nodes
FORM item_data .
IF NOT zaccbas[] IS INITIAL.
WRITE:/ 'Missing Records from Hierarchy' COLOR 3.
LOOP AT zaccbas.
WRITE:/ zaccbas.
ENDLOOP.
ENDIF.
IF NOT val[] IS INITIAL.
SKIP 1.
WRITE:/ 'Additional Records in Hierarchy' COLOR 3.
LOOP AT val.
WRITE:/ val-from. ", 28 val-DESCRIPT.
ENDLOOP.
ELSEIF ZACCBAS[] IS INITIAL.
WRITE:/ 'No Missing Records Found' COLOR 3.
ENDIF.
ENDFORM. " ITEM_DATA
Thanks,
Sakthi C
*Rewards if useful* -
Commandtoolbarbutton enabling/disabling based on tree node selection
i am using the tree tag to generate a set of nodes and every node is a command link.... i have a set of commandtoolbarbuttons on top of the tree... the functionality i am trying to obtain is on press of the tree node( i.e, command link ) the commantoolbarbuttons are enabled or disabled.. on press of link i am able to get the tree node selected in the backing bean, and also i am setting some variables for the "disabled" attribute of commandtoolbarbutton. The problem i am facing here is i have a partialtrigger attribute in the commandtoolbarbutton pointing to the commandlink id. But the partial trigger is unable to identify the command link id outside the tree. And i cannot put the commandtoolbar buttons inside the tree...
Can anyone please let me know how can i resolve this?? or is there anyother approach??
The source code is as mentioned below...
<af:panelGroupLayout layout="horizontal" halign="right">
<f:facet name="separator">
<af:spacer width="5px"/>
</f:facet>
<af:toolbox id="mainTab_box" >
<af:toolbar id="mainTab_bar">
<af:spacer width="80"/>
<af:commandToolbarButton icon="/resources/images/new_ena.png" partialSubmit="true"
shortDesc="New" id="ctb1_mainTab" disabled="#{nodeSelectionHandler.createToolbar}" partialTriggers="cl1"/>
<af:commandToolbarButton icon="/resources/images/update_ena.png" partialSubmit="true"
shortDesc="Update" id="ctb2_mainTab" disabled="#{nodeSelectionHandler.editToolbar}" partialTriggers="cl1"/>
<af:commandToolbarButton icon="/resources/images/delete_ena.png" partialSubmit="true"
shortDesc="Delete" id="ctb3_mainTab" disabled="#{nodeSelectionHandler.cancelToolbar}" partialTriggers="cl1"/>
<af:commandToolbarButton icon="/resources/images/importIcon.png" partialSubmit="true"
shortDesc="Import" id="ctb4_mainTab" disabled="#{nodeSelectionHandler.exportToolbar}" partialTriggers="cl1"/>
<af:commandToolbarButton icon="/resources/images/exportIcon.png" partialSubmit="true"
shortDesc="Export" id="ctb5_mainTab" disabled="#{nodeSelectionHandler.importToolbar}" partialTriggers="cl1"/>
</af:toolbar>
</af:toolbox>
</af:panelGroupLayout>
<af:panelGroupLayout layout="scroll">
<af:tree var="node"
value="#{browserTreeModel}"
id="browsertree" inlineStyle="min-width:200px;min-height:400px;width:100%;height:100%"
rowSelection="single" clientComponent="true" contentDelivery="immediate"
>
<f:facet name="nodeStamp">
<af:panelGroupLayout id="pgl10">
<af:image id="nodeIcon"
inlineStyle="margin-right:3px; vertical-align:middle; height:16px; width:16px;"
shortDesc="directory icon" rendered="#{node.destination != null}"
source="#{node.destination}"/>
<af:commandLink text="#{node.text}"
id="cl1"
disabled="false" partialSubmit="true"
actionListener="#{nodeSelectionHandler.selectionPerformed}" >
<f:attribute name="nodeId" value="#{node.id}"/>
<f:attribute name="operation" value="#{node.associatedOperation}"/>
</af:commandLink>
</af:panelGroupLayout>
</f:facet>
</af:tree>
</af:panelGroupLayout>With apologies, you're not aware of ELUtils class devised by Steve Muench:
package view;
import javax.faces.context.FacesContext;
import javax.faces.el.MethodBinding;
import javax.faces.el.ValueBinding;
public class ELUtils {
public static boolean test(String booleanExpr) {
return Boolean.TRUE.equals(get(booleanExpr));
public static String getAsStringWithDefault(String expr, String defaultExpr) {
return (String)getWithDefault(expr, defaultExpr);
public static String getAsString(String expr) {
return (String)get(expr);
public static Integer getAsInteger(String expr) {
return (Integer)get(expr);
public static Object get(String expr) {
FacesContext fc = FacesContext.getCurrentInstance();
ValueBinding vb = fc.getApplication().createValueBinding(expr);
return vb.getValue(fc);
public static Object getWithDefault(String expr, String defaultExpr) {
Object exprVal = get(expr);
return exprVal != null ? exprVal : get(defaultExpr);
public static void set(String expr, String value) {
Object valToSet = value;
if (isELExpr(value)) {
valToSet = get(value);
set(expr, valToSet);
public static void set(String expr, Object value) {
FacesContext fc = FacesContext.getCurrentInstance();
ValueBinding vb = fc.getApplication().createValueBinding(expr);
vb.setValue(fc, value);
private static boolean isELExpr(Object o) {
if (o instanceof String) {
String str = (String)o;
str.trim();
return str.startsWith("#{") && str.endsWith("}");
return false;
public static Object invokeMethod(String expr, Class[] paramTypes, Object[] params) {
FacesContext fc = FacesContext.getCurrentInstance();
MethodBinding mb = fc.getApplication().createMethodBinding(expr, paramTypes);
return mb.invoke(fc, params);
public static Object invokeMethod(String expr, Class paramType, Object param) {
return invokeMethod(expr, new Class[] { paramType }, new Object[] { param });
}Try that.
CM. -
How to store tree nodes in data base
i am creating a tree with create node and delete node dynamically
how can i store the tree nodes in the data base and how can i retrive them from data base to tree and tree tableThank s for replay
I am tring to the tree nodes and Dynamically creating and removing the nodes from the tree that tree structure have to store in the data base and after wards retrive the tree structure from the database and display as the tree -
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. -
How to delete a node from a node network
How do I delete a node from a node network?
<P>
<OL>
<LI>Follow the instructions on page 30 of the Calendar Server (CS) 3.x Admin Guide,
and page 62 of the CS 4.0 Admin Guide "Deleting (excluding) a Node from the
Network".
<LI>Shut down the Directory Server.
<LI>Backup the LDAP directory to an LDIF file.
<LI>Edit this LDIF file and delete references to the
6 calendar reserved users for the node to be deleted.
<LI>Restore the LDAP directory with this changed LDIF file.
<LI>Run unidbfix -export -n all
<LI>Edit the resulting remotenodes.ini
files and delete all
references to the node to be deleted.
<LI>Run unidbfix -import -n all
<LI>Start the Directory Server.
<LI>Start the Calendar Server.
<P>
Note: This next step is for Calendar Server 3.x * ONLY *
<P>
<LI>Run unireqdump -delete
to delete all requests to the node
to be deleted.
</OL>Divya wrote:
Hi,
I'm using forms6i.
I want to delete unselected nodes from a tree
How can it be done??
ThanksIf you mean empty branches as unselected nodes,
set Allow Empty Branches property to 'No' in the Trees property.
Maybe you are looking for
-
Hello, I am from Russia. Recently i upgraded my OS to Leopard and my sustain pedal in Logic 8 stopped working. Can anyone please help me with advice? What can i do about it?! Thank you.
-
How do I install software (specifically Office for Mac) on a MacBook Air?
How do I install software (specifically Office for Mac) on my MacBook Air? Thanks.
-
Only one DVI works on the dock
I just purchased two new Dell U2412M displays (1920x1200) for use with my W530 and dock. I had planned to plug them both into the DVI ports on the dock, but it seems like this is problematic. When I do so, I only get an image out of the display on po
-
Whatever messages I'm sending in message, it's not being received.... Help?
-
How do you install "Twixtor" excellent Slow Motion plug in for FCP
Hi, I have the Twixtor FxPlug Pro v5.0.1 but can't get to install it properly. I have seen some posts in the web but for me there is no clue how to install it. The installer installs it in the root of HD folder, but later they say you have to "move"