Can't remove a node from a tree

I am using the custom tree dataDescriptor provided in Flex live
doc. It works for creating the tree and add notes, however when I
try to remove a node from the tree it cant work. Does anyone have
any idea?
This is the code for MyCustomeTreeDataDescriptor.as
package
import mx.collections.ArrayCollection;
import mx.collections.CursorBookmark;
import mx.collections.ICollectionView;
import mx.collections.IViewCursor;
import mx.events.CollectionEvent;
import mx.events.CollectionEventKind;
import mx.controls.treeClasses.*;
public class MyCustomTreeDataDescriptor implements
ITreeDataDescriptor
// The getChildren method requires the node to be an Object
// with a children field.
// If the field contains an ArrayCollection, it returns the
field
// Otherwise, it wraps the field in an ArrayCollection.
public function getChildren(node:Object,
model:Object=null):ICollectionView
try
if (node is Object) {
if(node.children is ArrayCollection){
return node.children;
}else{
return new ArrayCollection(node.children);
catch (e:Error) {
trace("[Descriptor] exception checking for getChildren");
return null;
// The isBranch method simply returns true if the node is an
// Object with a children field.
// It does not support empty branches, but does support null
children
// fields.
public function isBranch(node:Object,
model:Object=null):Boolean {
try {
if (node is Object) {
if (node.children != null) {
return true;
catch (e:Error) {
trace("[Descriptor] exception checking for isBranch");
return false;
// The hasChildren method Returns true if the node actually
has children.
public function hasChildren(node:Object,
model:Object=null):Boolean {
if (node == null)
return false;
var children:ICollectionView = getChildren(node, model);
try {
if (children.length > 0)
return true;
catch (e:Error) {
return false;
// The getData method simply returns the node as an Object.
public function getData(node:Object,
model:Object=null):Object {
try {
return node;
catch (e:Error) {
return null;
// The addChildAt method does the following:
// If the parent parameter is null or undefined, inserts
// the child parameter as the first child of the model
parameter.
// If the parent parameter is an Object and has a children
field,
// adds the child parameter to it at the index parameter
location.
// It does not add a child to a terminal node if it does not
have
// a children field.
public function addChildAt(parent:Object, child:Object,
index:int,
model:Object=null):Boolean {
var event:CollectionEvent = new
CollectionEvent(CollectionEvent.COLLECTION_CHANGE);
event.kind = CollectionEventKind.ADD;
event.items = [child];
event.location = index;
if (!parent) {
var iterator:IViewCursor = model.createCursor();
iterator.seek(CursorBookmark.FIRST, index);
iterator.insert(child);
else if (parent is Object) {
if (parent.children != null) {
if(parent.children is ArrayCollection) {
parent.children.addItemAt(child, index);
if (model){
model.dispatchEvent(event);
model.itemUpdated(parent);
return true;
else {
parent.children.splice(index, 0, child);
if (model)
model.dispatchEvent(event);
return true;
return false;
// The removeChildAt method does the following:
// If the parent parameter is null or undefined, removes
// the child at the specified index in the model.
// If the parent parameter is an Object and has a children
field,
// removes the child at the index parameter location in the
parent.
public function removeChildAt(parent:Object, child:Object,
index:int, model:Object=null):Boolean
var event:CollectionEvent = new
CollectionEvent(CollectionEvent.COLLECTION_CHANGE);
event.kind = CollectionEventKind.REMOVE;
event.items = [child];
event.location = index;
//handle top level where there is no parent
if (!parent)
var iterator:IViewCursor = model.createCursor();
iterator.seek(CursorBookmark.FIRST, index);
iterator.remove();
if (model)
model.dispatchEvent(event);
return true;
else if (parent is Object)
if (parent.children != undefined)
parent.children.splice(index, 1);
if (model)
model.dispatchEvent(event);
return true;
return false;
This is my tree definition:
<mx:Tree width="143" top="0" bottom="0" left="0"
height="100%"
id="publicCaseTree"
dataDescriptor="{new MyCustomTreeDataDescriptor()}"
dataProvider="{ac}"
defaultLeafIcon="@Embed('assets/caseIcon.png')"
change="publicTreeChanged(event)"
dragEnabled="true"
dragMoveEnabled="false"/>
This is how I remove the selected node from the tree. When
Delete button is clicked, the doDeleteCase function is
exectuted.
public function publicTreeChanged(event:Event):void {
selectedNode =
publicCaseTree.dataDescriptor.getData(Tree(event.target).selectedItem,
ac);
public function doDeleteCase(event:Event):void{
publicCaseTree.dataDescriptor.removeChildAt(publicCaseTree.firstVisibleItem,
selectedNode, 0, ac);
Any help would be appreciated.Thanks.

Finally I removed nodes from tree, but not sure I did in the
right way. Anybody encounter the same problem, please
discuss.

Similar Messages

  • How can I remove child node from JTree???

    Hi,
    I would like to remove all the child node of my jtree. For instance I would like to remove the c, d, and e nodes. It's possible to remove all the child node or to remove by her name ("c", "d", and "e"). If yes what is the method that it permit to do.
    A-----
    |
    b-------c
    |
    |--------d
    |
    ---------e
    I use the model : DefaultMutableTreeNode
    Thanks

    There are a couple of ways it can be done. If your tree uses DefaultTreeModel as its TreeModel, you can use removeNodeFromParent(). This will remove the node from its parent and effectively remove its children, too. All nodes removed will be garbage-collected if there are no other references to them.
    If your tree model is not the default tree model, but still uses MutableTreeNode, you can use either remove() or removeFromParent() on the node itself, depending on whether you want to remove the node itself or one of its children.
    On the other hand, your tree may use a model that simply "mirrors" another data structure, in which case you would have to remove the node from the other data structure and have it reflected in the model.

  • Remove root node from tree ...

    hi all,
    how can i delete the root node from a tree ???
    i've tried:
    tree.removeAll();
    this removes all nodes from the tree except the root.
    thanks.

    try this:
    tree.setRootVisible(false);
    Bye!

  • How to remove the focus from a tree?

    Hello,
    how can I remove the focus from a tree, so that
    none of the elements in the tree is selected?
    I have tried using the following methods:
    setTreeSelection(null);
    setLeadSelection(IWDNode.NO_SELECTION);
    None of them worked.
    Any help highly appreciated.
    Greetings,
    Tomek.

    Hello,
    it seems I have found a (dirty) workaround to this
    problem. If anyone is interested, details below:
    When the user clicks on a tree node (say A tree),
    I do the following:
    1. request focus on the tree selected by the user
       (say B tree):
      IWDTree foldersTree = 
        (IWDTree)thisView.getElement("TreeFolders");
      foldersTree.requestFocus();
    2. invalidate the A tree (which causes the tree
       to disappear)
      wdThis.wdGetContext().nodeInbox().invalidate();
    3. recreate the A tree (filling the context nodes)
    4. unselect the A tree:
    wdContext.nodeInbox().setLeadSelection(IWDNode.NO_SELECTION);
    Thanks a lot to all of you who have responded.
    Greetings,
    Tomek.

  • How to remove a node from a xml

    Hi All,
    I want to remove a node from my xml output. Can anyone suggest me how to get that? I want to implement this by using the ASSIGN activity.
    My sample output is
    <env:Envelope xmlns:env="http://schemas.xmlsoap.org/soap/envelope/" xmlns:wsa="http://www.w3.org/2005/08/addressing">
         <env:Header>
              <wsa:MessageID>urn:4EF1A350677C11E1BFA7794ED76B03EF</wsa:MessageID>
              <wsa:ReplyTo>
                   <wsa:Address>http://www.w3.org/2005/08/addressing/anonymous</wsa:Address>
              </wsa:ReplyTo>
         </env:Header>
         <env:Body>
              <SiebelOrderQueryByExample_Output xmlns="http://siebel.com/asi/">
                   <ListOfOrderInterface xmlns="http://www.siebel.com/xml/Siebel%20Order">
                        <Orders>
                             <Id>1-15IXJ</Id>
                             <AccountId>1-2EE</AccountId>
                             <OrderNumber>1012-1234</OrderNumber>
                             <ListOfLineItems>
                                  <LineItems>
                                       <Id>1-15IYN</Id>
                                       <LineNumber>303</LineNumber>
                                       <OrderNumber>1012-1234</OrderNumber>
                                       <OrderHeaderId>1-15IXJ</OrderHeaderId>
                             </LineItems>
                                  </ListOfLineItems>
                             </Orders>
    </ListOfOrderInterface>
              </SiebelOrderQueryByExample_Output>
         </env:Body>
    </env:Envelope>
    I want to delete the <ListOfLineItems>node from the xml above so that my resultant would be,
         <env:Envelope xmlns:env="http://schemas.xmlsoap.org/soap/envelope/" xmlns:wsa="http://www.w3.org/2005/08/addressing">
         <env:Header>
              <wsa:MessageID>urn:4EF1A350677C11E1BFA7794ED76B03EF</wsa:MessageID>
              <wsa:ReplyTo>
                   <wsa:Address>http://www.w3.org/2005/08/addressing/anonymous</wsa:Address>
              </wsa:ReplyTo>
         </env:Header>
         <env:Body>
              <SiebelOrderQueryByExample_Output xmlns="http://siebel.com/asi/">
                   <ListOfOrderInterface xmlns="http://www.siebel.com/xml/Siebel%20Order">
                        <Orders>
                             <Id>1-15IXJ</Id>
                             <AccountId>1-2EE</AccountId>
                             <OrderNumber>1012-1234</OrderNumber>
         </Orders>
    </ListOfOrderInterface>
              </SiebelOrderQueryByExample_Output>
         </env:Body>
    </env:Envelope>     
    Please suggest something Its urgent.
    Thanks in Advance.

    It goes something like this, taken from the above blog entry:
    Removing a node from node-list
    With the bpelx: extensions in BPEL you are able to insert and update nodes in a node list. A node-list is an XML message that contains a set of records. In this article I use the following example:
    <BookList xmlns="http://message.vijfhuizen.com">
    <Book>
    <title>The Lord Of The Rings</title>
    <author>J.R.R. Tolkien</author>
    </Book>
    <Book>
    <title>Harry Potter</title>
    <author>J.R.R. Tolkien</author>
    </Book>
    <Book>
    <title>The Hobbit</title>
    <author>J.R.R. Tolkien</author>
    </Book>
    <Book>
    <title>Storm; Chronicals of Pandarve</title>
    <author>Don Lawrence</author>
    </Book>
    </BookList>
    For creating and updating node lists the bpelx: functions are enough to handle this. But when you want to remove a particular node, you can use the bpelx:remove function. But this function can only remove a node from a particular position. For example removing the second node you code:
    <bpel:assign>
    <bpelx:remove>
    <bpelx:target variable="VarBookList" query="/Booklist/Book[2]" />
    </bpelx:append>
    </bpel:assign>
    It is hard to code the bpelx:remove to create a xpath to dynamicly remove node. You would like to remove the second node based on the xpath:
    /Booklist/Book[title="Harry Potter" and author="J.R.R. Tolkien"]
    You can add the above xpath in the bpelx:remove, but you are not able to make this dynamically.
    There is a solution. The trick is to create a stylesheet that copies the data into a new message, but removing that particular records. Create a stylesheet that does the normal copy of the XML message. Then add a <choose> element in the stylsheet to filter that particular record.
    <xsl:template match="/">
    <BookList>
    <xsl:for-each select="/BookList/Book">
    <xsl:choose>
    <xsl:when test="title='Harry Potter' and author='J.R.R. Tolkien'"/>
    <xsl:otherwise>
    <Book>
    <title>
    <xsl:value-of select="title"/>
    </title>
    <author>
    <xsl:value-of select="author"/>
    </author>
    </Book>
    </xsl:otherwise>
    </xsl:choose>
    </xsl:for-each>
    </BookList>
    Now we have a XSL stylesheet that removes a particular record, but this is not variable. This can be done via XSLT parameters.
    <xsl:param name="pTitle"/>
    <xsl:param name="pAuthor"/>
    <xsl:template match="/">
    <BookList>
    <xsl:for-each select="/BookList/Book">
    <xsl:choose>
    <xsl:when test="title=$pTitle and author=$pAuthor"/>
    <xsl:otherwise>
    <Book>
    <title>
    <xsl:value-of select="title"/>
    </title>
    <author>
    <xsl:value-of select="author"/>
    </author>
    </Book>
    </xsl:otherwise>
    </xsl:choose>
    </xsl:for-each>
    </BookList>
    </xsl:template>
    Now we are able to use this stylesheet in BPEL. In general BPEL create the following code:
    <assign name="Transform">
    <bpelx:annotation>
    <bpelx:pattern>transformation</bpelx:pattern>
    </bpelx:annotation>
    <copy>
    <from expression="ora:processXSLT('RemoveNode.xsl'
    , bpws:getVariableData('Variable_BookList','payload')" />
    <to variable="Variable_BookListTemp" part="payload"/>
    </copy>
    </assign>
    But this code does not pass parameters to the stylesheet. The ora:processXSLT() can do this it has an additional parameter in this function:
    <assign name="Transform">
    <bpelx:annotation>
    <bpelx:pattern>transformation</bpelx:pattern>
    </bpelx:annotation>
    <copy>
    <from expression="ora:processXSLT('RemoveNode.xsl'
    , bpws:getVariableData('Variable_BookList','payload')" />
    , bpws:getVariableData('BPELxslparameters'))"/>
    <to variable="Variable_BookListTemp" part="payload"/>
    </copy>
    </assign>
    Now only you have to create the BPELxslparameters variable and assign it with the correct name/value pairs. The structure of the this variable is as follows:
    <?xml version="1.0" encoding="windows-1252" ?>
    <xsd:schema xmlns:xsd="http://www.w3.org/2001/XMLSchema"
    xmlns="http://schemas.oracle.com/service/bpel/common"
    targetNamespace="http://schemas.oracle.com/service/bpel/common"
    elementFormDefault="qualified">
    <xsd:element name="parameters">
    <xsd:complexType>
    <xsd:sequence>
    <xsd:element name="item" minOccurs="1" maxOccurs="unbounded">
    <xsd:complexType>
    <xsd:sequence>
    <xsd:element name="name" type="xsd:string"/>
    <xsd:element name="value" type="xsd:string"/>
    </xsd:sequence>
    </xsd:complexType>
    </xsd:element>
    </xsd:sequence>
    </xsd:complexType>
    </xsd:element>
    </xsd:schema>
    Create in BPEL the variable BPELxslparameters and let it point to this strucure:
    <process ....
    xmlns:common="http://schemas.oracle.com/service/bpel/common"
    .../>
    <variable name="BPELparameters" element="common:parameters"/>
    Now we can in BPEL create an empty XML message, based on this strcuture and assign the values to these parameters and then call the processXSLT function.
    <bpelx:assign name="Assign_GenerateEmptyParameterSet">
    <copy>
    <from>
    <parameters xmlns="http://schemas.oracle.com/service/bpel/common">
    <item>
    <name>pTitle</name>
    <value/>
    </item>
    <item>
    <name>pAutor</name>
    <value/>
    </item>
    </parameters>
    </from>
    <to variable="BPELparameters" query="/common:parameters"/>
    </copy>
    </bpelx:assign>
    <assign name="Assign_setXSLTParameters">
    <copy>
    <from expression="'Harry Potter'"/>
    <to variable="BPELparameters" query="/common:parameters/common:item[1]/common:value"/>
    </copy>
    <copy>
    <from expression="'J.R.R. Tolkien'"/>
    <to variable="BPELparameters" query="/common:parameters/common:item[1]/common:value"/>
    </copy>
    </assign>
    Posted by Marc Kelderman SOA Blog at 1/16/2008 09:20:00 PM

  • 3750x Stack UTIL-3-TREE: Data structure error--attempt to remove an unthreaded node from a tree

    A Cisco Stack 3750X switch report the following error message:
    %UTIL-3-TREE: Data structure error--attempt to remove an unthreaded node from a tree.
    every minute +-20 sec
    Cisco IOS Software, C3750E Software (C3750E-IPBASEK9-M), Version 15.0(2)SE4, RELEASE SOFTWARE (fc1)
    analog bug: https://tools.cisco.com/bugsearch/bug/CSCsz93221

    WS-C3750G-24PS-E C3750-IPBASEK9-M version 12.2(53)SE2
    After implementing 802.1x with Avaya IP phones
    %UTIL-3-TREE: Data structure error--attempt to remove an unthreaded node from a tree
    Port then fails authentication and goes into vl-err-dis

  • Removing a node in a tree

    Im using this line of code
    var selectedNode:XML = XML(MyTree.selectedItem);
    and i want to remove the selectedNode from the tree... The
    only way that I have found to remove the node is to use these lines
    of code which seems ridiculous just to remove the node
    var parentChildren:XMLList =
    XMLList(selectedNode.parent().children());
    for (var i:int = 0; i < parentChildren.length(); i++) {
    if (parentChildren
    .@label == selectedNode.@label) {
    delete parentChildren;
    The only thing that I have found is to use the XMLNode object
    because it has removeNode method... Except I can't use that either
    because I get a warning when I try to cast the selectedItem into a
    XMLNode.
    Does anyone know how to simplify a deletion of a node.

    First, XMLNode is an object belonging to the old flash xml
    style xml stuff,
    and is not part of the new e4x XML class. Neither is
    XMLDocument. In the new
    XML, yo only have XML and XMLList to work with.
    As far as delete, it is a bit of a PITA. I am amazed that we
    have to use the
    top-level object delete, but that is the case.
    Now you should be able to just do:
    delete selectedNode;
    Try that first..However, looking back at my own code I
    didn't do this.
    Instead, I use this function:
    //deletes the currently selected node
    private function deleteSelectedNode():void
    var nodeToDelete:XML = XML(treeData.selectedItem);
    //reference to the
    node to delete
    var xlcParent:XMLListCollection = new
    XMLListCollection(nodeToDelete.parent().children());
    //collection of nodes
    containing the node to delete
    var iIndex:int = xlcParent.getItemIndex(nodeToDelete);
    //index of node to
    delete in collection
    xlcParent.removeItemAt(iIndex); //remove the node
    //treeData.invalidateList(); //refresh the tree
    }//deleteSelectedNode
    Maybe that technique will work for you.
    Tracy

  • How to remove a node from nlb at runtime?

    hello,
    i need to temporally exclude a node from an nlb.
    May happen that a server is up and working but the web application i'm balancing is out of sinch with the same application in the others nodes.
    Eg. some static variables are not the same of the same static variables of other nodes, because of a timeout, a write error and so on but the server is still working.
    in this case i need to stop the server from nlb because the information in the web application is not in sinch with other nodes.
    I need to prevent users from being serverd from this out to date server, untill it will became updated, but i need to do this programmatically
    how can i do it?

    "DuoMi" <[email protected]> wrote in message
    news:gnojbf$2sg$[email protected]..
    > How to remove a node from XMLList
    >
    > I want remove the first node from XMLList
    >
    >
    > and how to get the combobox all values string:
    >
    > <data>
    > <value>2</value>
    > </date>
    > <data>
    > <value>5</value>
    > </date>
    > <data>
    > <value>8</value>
    > </date>
    >
    > I need a string whit value "2,5,8"
    >
    > thkan you.~
    I think something like
    comboBox.dataProvider..value.toString()
    will work.

  • How to Remove a Node from JTree?

    I want to remove a node from a JTree but the node may or maynot be visible.
    My method takes a String which is the name of the node.
    The nodes im using are DefaultMutableTreeNode
    This is my code so far but it doesnt work.
    public void removePerson(String pName)
              TreePath node = tree.getNextMatch(pName,0,Position.Bias.Forward);
              tree.expandPath(node);
              tree.removeSelectionPath(node);
    }Any Suggestions or ways which i could achive this?
    Thank you,

    I don't think removeSelectionPath is what you want to use.
    These should help:
    [http://java.sun.com/j2se/1.4.2/docs/api/javax/swing/tree/DefaultTreeModel.html#removeNodeFromParent(javax.swing.tree.MutableTreeNode)|http://java.sun.com/j2se/1.4.2/docs/api/javax/swing/tree/DefaultTreeModel.html#removeNodeFromParent(javax.swing.tree.MutableTreeNode)]
    [http://www.roseindia.net/java/example/java/swing/RemoveNodes.shtml|http://www.roseindia.net/java/example/java/swing/RemoveNodes.shtml]

  • How can we remove the commas from the Formula value in SAP BW BEx query

    Hi All,
    How can we remove the commas from the Formula value in SAP BW BEx query
    We are using the formula replacing with characteristic.The characteristic value needs to be display as number with out commas.
    Regards
    Venkat.

    Do you want to remove the commas when you run the query on Bex Web or in RSRT?
    Regards

  • How can i remove a card from iTunes ?

    How can i remove a card from iTunes ?

    If you want to remove a credit/debit card from your account then on your computer's iTunes you should be able to edit your payment info by going into the Store > View Account menu option and logging into your account, and on your account's details page there should be a payment link.  If you are doing it on your iOS device then tap on your id in Settings > iTunes & App Store and tap on 'View Apple ID' on the popup and log into your account  - that should also give you a payments link on your account's page.
    Changing payment info : Change or remove your payment information from your iTunes Store account (Apple ID)
    If you don't get the 'none' option on the payment details screen : Why can’t I select None when I edit my Apple ID payment information?

  • HT202667 how can I remove credit card from apple id ?

    i don't want to use apple id with credit card anymore i purchased enough apps for my apple device so now i wanna remove it so how can i remove credit card from apple id

    On your computer's iTunes you should be able to edit your payment info by going into the Store > View Account menu option and logging into your account, and on your account's details page there should be a payment link.  If you are doing it on your iPhone then tap on your id in Settings > iTunes & App Store and tap on 'View Apple ID' on the popup and log into your account  - that should also give you a payments link on your account's page.
    Changing payment info : http://support.apple.com/en-gb/HT1918
    If you don't get the 'none' option on the payment details screen : http://support.apple.com/en-gb/TS5366

  • How can I remove credit card from itunes account?

    How can I remove credit card from itunes account?

    I'm not home right now, so don't have iTunes here. I am basing this on having to do this a few days ago, as well as pictures from Google Images, so things may have different names now...
    Store (dropdown at top of iTunes screen)>View my account>Edit Payment Information>In the list of types of credit cards, the one at the far right says "None." Click that.

  • How can I remove some themes from Keynote??

    How can I remove some themes from Keynote??

    What a co-incidence... I just deleted those same goodies. They were in /Library/Application Support/Keynote-folder on my machine. I just deleted the whole folder, cause there seemed to be nothing more but those downloaded files. And Keynote worked great afterwards. There seemed to be another folder for iWork09, which is not to be removed.

Maybe you are looking for

  • A default value in a form

    Hi All I have a form that collects info from the users and puts the info in the table. There is one field that I would like to enter a default value of 51, as this is a field that will properly cause the user some concerns. I could then not show this

  • MacBook Pro will not load start up properly

    My MacBook Pro 2012 will not load properly after I took it to the apple store and they ran test on it. When I boot it up I get the gray screen with the loading bar. I can get into disk utility. However I don't believe they messed with anything and it

  • Links do not work in IE7

    Hello. My colleagues use Dell Laptop computers with IE7 browser. The link Is sent for a video does not work. It appears to work in Chrome. Please advise. Thank you.

  • Recovery_scenerio

    Hi, Dear Gurus. Oracle :9.2.0 OS: windows XP I tried to shut down the database. The database was shutting down cleanly. But at mount state it stopped. After waiting for an hour I just rebooted the machine. I checked the status of the database. It was

  • TVKWZ : Org.Unit: Allowed Plants per Sales Organization

    Hello, At one of the implementations which is doing intercompany postings with SO-PO model has 250,000 records to be created in this table. 1. Is this okay to have such a huge number of records in this table ? 2. Is there any way BDC, LSMW method to