Delete node elements

I have created 5 elements of a node . I want to delete nodes. But it is giving error .
Context
          sample (node )    [ cardinality 0...n , selection 0..1 ]
                      name (attr)
                      number(attr)
code :
public void onActioncreate(com.sap.tc.webdynpro.progmodel.api.IWDCustomEvent wdEvent )
    //@@begin onActioncreate(ServerEvent)
    for(int i=0;i<5;i++){
         IPrivateClearnodeElements.ISampleNode node =wdContext.nodeSample();
         IPrivateClearnodeElements.ISampleElement ele = node.createSampleElement();
         ele.setName("Name "+i +" : " );
         ele.setNumber(i+"");
         node.addElement(ele);
    //@@end
  public void onActionclear(com.sap.tc.webdynpro.progmodel.api.IWDCustomEvent wdEvent )
    //@@begin onActionclear(ServerEvent)
    wdComponentAPI.getMessageManager().reportSuccess(wdContext.nodeSample().size()+"");
    for(int i=0;i<5;i++)
          try{
          wdContext.nodeSample().removeElement(wdContext.nodeSample().getSampleElementAt(i));
          wdComponentAPI.getMessageManager().reportSuccess("Deleted : "+ i+"");
          catch(Exception e)
               wdComponentAPI.getMessageManager().reportSuccess(e.getMessage()" : " i+"");
    //@@end
output :
5
Deleted : 0
Deleted : 1
Deleted : 2
Index: 3, Size: 2 : 3
Index: 4, Size: 2 : 4
Why it is not able to delete the last two node elements ????????????????//
Also any other way is there to  delete  elements of the node?
Srini

Hi srinivasa,
You have used the code to delete the element
for(int i=0;i<5;i++)
try{
wdContext.nodeSample().removeElement(wdContext.nodeSample().getSampleElementAt(i));
wdComponentAPI.getMessageManager().reportSuccess("Deleted : "+ i+"");
catch(Exception e)
wdComponentAPI.getMessageManager().reportSuccess(e.getMessage()" : " i+"");
Now.. See getSampleElementAt(i) method returns the element of i th element. On that case you have to use
getSampleElementAt(0). In that case it wiil return 0ih element end 0th element will be deleted. After deletion the 0th element 1st element will move to the 0th position.
So. in that way you can delete all the elements.

Similar Messages

  • Delete an Element in the Tree

    Hi,
    I would like to delete an element in the tree.
    but I was able to delete only the rootNode
    Could you help me. thanks
    IPrivateTreeView.ITreeNodeNode rootNode =
         wdContext.nodeTreeNode();
    IPrivateTreeView.ITreeNodeElement level2Delete = null;
    level2Delete = rootNode.currentTreeNodeElement( );
    // I would like to do somethink like that
    level2Delete.REMOVE_ELEMENT

    Hi Philippe,
    it's sooooo easy This is a snipped from the IWDNode API
       * Removes an element from the node collection. If an ICMIObservableList is
       * bound to the node, this list is modified!
       * @param element The element to be removed
       * @return <code>true</code> if the element was in.
      boolean removeElement(IWDNodeElement element);
    so you simply have to call
    wdContext.nodeTreeNode().removeElement(level2Delete);
    Hope that helps.
    Regards
    Stefan

  • Delete selected elements??

    Hi all,
    How do I delete selected elements in a node? Let say I want to delete element index 2. How do I do it? Thanks.

    Hi.,
    Get the selected Element or selected Index.,
    now read the internal table in node using get_static_attributes_table method.,
    loop the internal table
    count = count + 1.
    if count = selected index.
    esle.
    append internal table to final internal table (itab-fin).
    endif.
    endloop.
    now bind_table( itab_fin ).     " now the selected element will not appear in the node.
    you can also use  remove_element method to remove selected elements
    hope this helps u..
    Thanks & Regards,
    Kiran

  • How to pass all values from one node element to created node element?

    Hi
    I have model node element under which there are 7 values, and I've created value node element and trying to pass the values from the model node Element to this value node element. But instead of passing all the values its listing only one value.
    How do we rectify this problem!!!
    Thanks in Advance
    Srikant

    Hi Anil
    I've created the node named: TableNode
    and the name of the node from which i want to get the data is : Li_Required_Node
    the Node Structure is
    Context
      |_ Zs_Quantity_Input
         |_Output
           |_Node_Required_Node
              |_Schddt
      |_TableNode
        |_CmpDate
    The Schddt has some 7 values
    The code Snippet is as follows:
    IPublicPricesComp.ITableNodeElement nodeElement;
    IPublicPricesComp.ILi_Required_NodeElement scheduleElement;
    int counter3Max = wdContext.ILi_Required_Node().size();
    for( int counter3= 0 ; counter3 < counter3Max ;counter3++ )
    nodeElement = wdContext.createTableNodeElement();
                             scheduleElement = wdContext.nodeZs_Quantity_Input().nodeOutput_Contract_Qty().nodeLi_Required_Node().getLi_Required_NodeElementAt(counter3);
    nodeElement.setCmpDate(scheduleElement.getSchddt());
    wdContext.nodeTableNode().addElement(nodeElement);               
    On writing the above code and then binding the node to a table column only one value getting displayed
    Where can be the error?
    Thanks in Advance
    Srikant

  • HOW TO DELETE DUPLICATE ELEMENT IN A VECTOR

    Hi everybody!
    If I've a vector like this vectA={apple,orange,grape,apple,apple,banana}
    and I want final result be vectB={apple,orange,grape,banana}.
    How should I compare each element in vectA and delete duplicate element. Like here duplicated element is apple. Only one apple remain in the vectB.
    Any help,
    Thanks.

    Hello all. Good question and good answers, but I would like to elaborate.
    To begin with, you specifically asked to map the following:
    {apple,orange,grape,apple,apple,banana} ==> {apple,orange,grape,banana}
    Both of cotton.m's solutions do NOT do this, unfortunately. They are both useful in particular cases though, so think about what you're trying to do:
    cotton.m's first solution is best if order does not matter. In fact, as flounder first stated, whenever order doesn't matter, your most efficient bet is to use a Set instead of a List (or Vector) anyways.
    Set vectB = new HashSet(vectA);This code maps to {banana, orange, grape, apple}, because HashSets are "randomly" ordered.
    cotton.m's second solution is good if you want to impose NEW ordering on the List.
    Set vectB = new TreeSet(vectA);This code maps to {apple, banana, grape, orange}, because TreeSet uses alphabetical-order on Strings by default.
    java_2006, your solution is the most correct, but it's a little verbose for my taste :)
    more importantly, the runtime-efficiency is pretty bad (n-squared). calling Vector.contains performs (at worst) n comparisons; you're going to call it n times! Set.contains usually performs 2 comparisons (constant, much better), so I suggest you USE a Set to do the filtering, while still sticking with your good idea to use a List. When the ordering is "arbitrary" (so can't use TreeSet) but still relevant (so can't use HashSet), you're basically talking about a List.
    I think saving A LOT of time is worth using A LITTLE extra space, so here, let's save ourself some runtime, and some carpal-tunnel.
    import java.util.*;
    class Foo {
         public static void main(String[] args) {
              String[] fruits = {"apple","orange","grape","apple","apple","banana"};
              List     l = Arrays.asList(fruits),
                   m = filterDups(l);
              System.out.println(m);
         // remember, both of the following methods use O(n) space, but only O(n) time
         static List filterDups(List l) {
              List retVal = new ArrayList();
              Set s = new HashSet();
              for (Object o : l)
                   if (s.add(o))
                        retVal.add(o);     // Set.add returns true iff the item was NOT already present
              return retVal;
         static void killDups(List l) {
              Set s = new HashSet();
              for (Iterator i = l.iterator(); i.hasNext(); )
                   if (! s.add(i.next()))     
                        i.remove();
         // honestly, please don't use Vectors ever again... thanks!
         // if you're going to be a jerk about it, and claim you NEED a Vector result
         // then here's your code, whiner
         public static void mainx(String[] args) {
              String[] fruits = {"apple","orange","grape","apple","apple","banana"};
              List l = Arrays.asList(fruits);
              Vector v = new Vector(l);
              killDups(v);
              System.out.println(v);
    }

  • Store XML node value into an array with node element name

    Hi,
    I have the following code that displays the node element with the
    corresponding node value. I want to store the values in an array in
    reference to the node name.
    i.e.
    XML (my xml is much bigger than this, 300 elements):
    <stock>
    <symbol>SUNW</symbol>
    <price>17.1</price>
    </stock>-----
    would store the following:
    *data[symbol] = SUNW;*
    *data[price] = 17.1;*
    Thanks in advance,
    Tony
    test.jsp
    Here's my source code:
    <html>
    <head>
    <title>dom parser</title>
    <%@ page import="javax.xml.parsers.*" %>
    <%@ page import="org.w3c.dom.*" %>
    <%@ page import="dombean.*" %>
    </head>
    <body bgcolor="#ffffcc">
    <center>
    <h3>Pathways Info</h3>
    <table border="2" width="50%">
    <jsp:useBean id="domparser" class="dombean.MyDomParserBean" />
    <%
    Document doc = domparser.getDocument("c:/stocks/stocks.xml");
    traverseTree(doc, out);
    %>
    <%! private void traverseTree(Node node,JspWriter out) throws Exception {
    if(node == null) {
    return;
    int type = node.getNodeType();
    switch (type) {
    // handle document nodes
    case Node.DOCUMENT_NODE: {
    out.println("<tr>");
    traverseTree
    (((Document)node).getDocumentElement(),
    out);
    break;
    // handle element nodes
    case Node.ELEMENT_NODE: {
    String elementName = node.getNodeName();
    //if(elementName.equals("MOTHER-OCC-YRS-PREVIOUS")) {
    //out.println("</tr>");
    out.println("<tr><td>"+elementName+"</td>");
    NodeList childNodes =
    node.getChildNodes();     
    if(childNodes != null) {
    int length = childNodes.getLength();
    for (int loopIndex = 0; loopIndex <
    length ; loopIndex++)
    traverseTree
    (childNodes.item(loopIndex),out);
    break;
    // handle text nodes
    case Node.TEXT_NODE: {
    String data = node.getNodeValue().trim();
    //if((data.indexOf("\n")  <0) &#38;&#38; (data.length() > 0)) {
    out.println("<td>"+data+"</td></tr>");
    %>
    </table>
    </body>
    </html>
    {code}
    *MyDomParserBean.java*
    Code: package dombean;
    {code:java}
    import javax.xml.parsers.*;
    import org.w3c.dom.*;
    import java.io.*;
    public class MyDomParserBean
    implements java.io.Serializable {
    public MyDomParserBean() {
    public static Document
    getDocument(String file) throws Exception {
    // Step 1: create a DocumentBuilderFactory
    DocumentBuilderFactory dbf =
    DocumentBuilderFactory.newInstance();
    // Step 2: create a DocumentBuilder
    DocumentBuilder db = dbf.newDocumentBuilder();
    // Step 3: parse the input file to get a Document object
    Document doc = db.parse(new File(file));
    return doc;
    {code}
    Edited by: ynotlim333 on Sep 24, 2007 8:41 PM
    Edited by: ynotlim333 on Sep 24, 2007 8:44 PM
    Edited by: ynotlim333 on Sep 24, 2007 8:45 PM                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                       

    I still need to store it in an array because its 300 elements in the XML stocks.
    I've done the following but its not working, i'm getting error codes. I think its an easy fix. I'd also like to pass a String instead of a .xml document b/c my xml is stored inside a DB. Any suggestions on that?
    <html>
    <head>
    <title>dom parser</title>
    <%@ page import="javax.xml.parsers.*" %>
    <%@ page import="org.w3c.dom.*" %>
    <%@ page import="org.*" %>
    </head>
    <body bgcolor="#ffffcc">
    <center>
    <h3>Pathways Info</h3>
    <table border="2" width="50%">
    <jsp:useBean id="domparser" class="org.MyDomParserBean" />
    <%
    Document doc = domparser.getDocument("c:/stocks/stocks.xml");
    traverseTree(doc, out);
    %>
    <%!
            public String element_store = null;
            public String[] stock_data = new String[400];
            private void traverseTree(Node node,JspWriter out) throws Exception {
            if(node == null) {
               return;
            int type = node.getNodeType();
            switch (type) {
               // handle document nodes
               case Node.DOCUMENT_NODE: {
                 out.println("<tr>");
                 traverseTree
                 (((Document)node).getDocumentElement(),
                 out);
                 break;
              // handle element nodes
              case Node.ELEMENT_NODE: {
                String elementName = node.getNodeName();
                element_store = elementName;
                 //if(elementName.equals("MOTHER-OCC-YRS-PREVIOUS")) {
                   //out.println("</tr>");
                 NodeList childNodes =
                 node.getChildNodes();     
                 if(childNodes != null) {
                    int length = childNodes.getLength();
                    for (int loopIndex = 0; loopIndex <
                    length ; loopIndex++)
                       traverseTree
                       (childNodes.item(loopIndex),out);
                  break;
               // handle text nodes
               case Node.TEXT_NODE: {
                  String data = node.getNodeValue().trim();
                  if((data.indexOf("\n")  <0) && (data.length() > 0)) {
                  out.println("<tr><td>"+element_store+"</td>");
                  out.println("<td>"+data+"</td></tr>");
                  stock_data[element_store]=data;
    %>
    </table>
    </body>
    </html>

  • Regarding creation of node element

    Hi
    i hav a doubt regarding creation of node element. u can create new node element using method create(cn)Element available either directly from wdContext or from wdContext.node(cn) where cn is any context node.
    can any one plz explain me what's the difference between two.
    does it has any thing to with node being singelton or non-singelton?
    also can anyone explain me the difference between add and bind method.
    thanks.

    hi
    good
    Data Binding Methods
    If a property can, or must be bound to the context, the respective bind and bound methods are available.
    &#9679;     The bind methods bind the value of a property to the context element specified by the path.
    The name of the method is created according to the following pattern:
    BIND_<runtime name of the property>.
    Example: table, property: design, method: BIND_DESIGN.
    &#9679;     The bound methods return the path of the context element to which a property is bound and return NULL if no binding exists.
    The name of the method is created according to the following pattern:
    BOUND_<runtime name of the property>.
    Example: table, property: design, method: BOUND_DESIGN.
    ADD METHOD->
    Two add methods that add an element.
    &#9675;     If only the element is transferred as parameter, then the element is added at the and of a list
    &#9675;     If an index is transferred as well, then this element is transferred at the specified index position.
    http://help.sap.com/saphelp_erp2005/helpdata/en/66/18b44145143831e10000000a155106/content.htm
    thanks
    mrutyun^

  • Help needed in deleting nodes from RAC database

    Our DB is 10g RAC database and the servers are Window 2003 server. Initially the database was configured to have 4 nodes. For some reason we stopped the instances in the first two nodes and the current database is running on node3 and node4. I queried the v$thread view and it shows 3 records. Thread 2 is closed and disabled. Thread 3 is open and public and thread 4 is open and private. Now we need to disconnect nodes 1 and 2 from RAC db and cluster ware (We use Oracle cluster ware) and plan to use those two servers for other purposes. Although I read through the Oracle doc regarding deleting node from RAC “11 Adding and Deleting Nodes and Instances on Windows-Based Systems” and wrote down the steps we need to take but I am still not comfortable in doing it since it is production env and we don’t have any dev env to practice those steps. So I would like to borrow your experiences and your lessons learned while you were doing those. Please share your thoughts and insights with us.
    Thank you so much for your help,
    Shirley

    what's your full version? I can warn about specific issues in 10.1.0.3 and 10.2.0.1 - for example, in some cases (depending on how the listener was configured), it will be impossible to delete the listener for the deleted node. Known bug.
    To avoid many many known bugs, you may want to upgrade to at least 10.2.0.2 before removing a node (from my experience, this is the first stable RAC version).
    In any case, deleting a node is a rather delicate process. I really really recommend practicing. Take any pc/laptop, install VMWARE, define two virtual machines, install RAC and remove one node. It will take you an extra day or two, and could save your production.

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

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

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

  • To delete Cost Element that already has posting.

    Hi,
    I need to delete Cost element that already has posting. I used KO04 error msg. KS133 Deletion is not possible (depend records exist in table COEP). Cummulative balance already zerorise.
    Thank you.
    Moderator: Please, search SDN

    Hi, it's better not to use in productive.
    See here IMG-Controlling-General Controlling-Production Start-Up Preparation-Delete Test Data-Delete Transaction Data  and then Delete Cost Elements

  • Delete of Element in Form for COPA line item report

    Hello
    I would like to change a form used for a COPA line item report - delete an element, which has been included for years. Unfortunately I got message, that 'You cannot delete, because element xxx is dependent'.
    If I insert a new element if have no problems to delete it afterwards.
    Can anybody help me?
    Thanks in advance.
    Best regards
    Søren Kirch
    LOGSTOR A/S

    Hi,
    To my knowledge, you cannot delete the element until you assign the new one in the form if only single element is assigned.
    In case anymore element is there, there can be possibility this element is taken into consideration for making formula.
    Regards,
    Harish

  • I deleted nodes with the web developer and the deletion has become permanent. How to undo?

    I was trying to remove all the "Recommended Pages" etc. garbage on the right-hand side of Facebook and got a little click happy with 'delete nodes' using the Web Dev tools - as cathartic as it was! :)
    Now it seems as though I have broken FB on Firefox (seems to work fine on IE, surprisingly) as pics seem to be missing and the left-hand menu as well - but, of course the stuff I was trying to rid myself of comes back just fine ... sigh.
    I've read that all changes are supposed to be temporary until you restart the browser but this hasn't helped at all and I did try unchecking the 'Use hardware acceleration when available' that I read somewhere else, to no avail.
    Any assistance that can be rendered would be very much appreciated.
    For the record, I've learned my lesson and won't futz around with this anymore! :)

    For a node deletion in the Inspector tool,revert that by reloading the page. If that isn't working for you, you could try Command+Shift+r to reload the page bypassing the cache.
    You can check for problems with the sessionstore.js and sessionstore.bak files in the Firefox Profile Folder that store session data.
    Delete the sessionstore.js file and possible sessionstore-##.js files with a number and sessionstore.bak in the Firefox Profile Folder.
    HT > Profile Directory: Open Containing Folder
    http://kb.mozillazine.org/Profile_folder_-_Firefox
    Deleting sessionstore.js will cause App Tabs and Tab Groups and open and closed (undo) tabs to get lost, so you will have to create them again (make a note or bookmark them).
    http://kb.mozillazine.org/Multiple_profile_files_created

  • Tree View Node Element Resize

    Hello,
    Is there any way to resize Tree View Node Element programatically.
    In .fr file the height of the tree view node element is set to 90.
    On a button click I want to resize the element height to 18.
    I have tried using IControlView->SetFrame(TmpRect); but with no luck.
    Thanks,
    Prakash.

    Take a look at ITreeViewWidgetMgr, you can implement GetNodeWidgetHeight(...)
    and you may need to call ITreeViewMgr->NodeChanged(...) to get the TreeView to re-paint your Node.

  • Delete xml element not used in document

    Hi,
    If you have a number of texts tagged with an xml element and then delete the text, the element still exist in the structure.
    You can see the element still connected to a text, by the blue diamond on the element symbol.
    But i want do delete the elements that have no connection to texts, but cant find the right property to look for.
    In Java script CS4.
    Anyone knows?
    /Mikael

    If the (text) element is unplaced, its parentStory will be an XmlStory rather than a Story.
    So try:
    var elements = app.activeDocument.xmlElements[0].xmlElements.everyItem().getElements();
    for (var i = elements.length - 1;i >= 0;i--){
        if(elements[i].parentStory.constructor.name === "XmlStory"){
            elements[i].remove();
    This is untested. If you have tagged graphics frames it will need to be modified to not error on those.
    Jeff

  • How to delete an element in arraylist??

    here i have an array list which contain details of an address book
    I want to delete one element in the list
    but its not deleting
    Could anyone please take a look and help me
    tank u in advance!!
    else if (X.compareTo(F)==0)
       {System.out.println("Pour supprimer une fiche : saisir le NUM INDEX.");
        Integer c1 = new Integer(0);
        Z = clavier.readLine();
        c1=Integer.valueOf(Z);
        System.out.println("Vous allez supprimer la fiche "+c1);
        for( Iterator it= l.iterator(); it.hasNext();) {
          Object p =it.next();
          relations R=(relations)p;
            if (R.getnumero()==c1)
           l.remove(l.indexOf(p));}
          for( Iterator it1= l.iterator(); it1.hasNext();) {
             Object o =it1.next();
             if (o.getClass().getName()=="carnetadresses.contact")
               ((relations) (o)).affiche();
               }break;
      }

    It's a good thing you use code tags for posting here. Could you now consider using code conventions?
    - Why is the second loop nested in the first one? (this second loop looks weird anyway...)
    - The Iterator has a remove method. You should use it in such case.
    - Looks like you have a malpositioned/misused break statement (which is probably the reason why nothing happen, as it terminates the for loop after the first iteration.)

Maybe you are looking for

  • Satellite M30-951 graphic card or video BIOS does not work properly

    On the BIOS and boot pages strange characters occur (screenshot www.audioberlin.com/M30-951_SCREEN.jpg). XP boots up but the elements displayed freeze and the display becomes black for a second. The system becomes slow and does not react any longer.

  • How to determine the jspx page name in the EntityImpl Java Class

    Hello, I'm new jdev programmer. I've come across a scenario that I haven't been able to figure out. I have a small application with only two pages, but uses the same Entity class. I have two views (One view per page). In the protected void doDML() me

  • Windows 7 Ult 64 memory mgmt errors ntoskrnl.exe nt+75BC0

    Using WhoCrashed I get this error once in a while.  Where should I post this question? On Mon 4/14/2014 3:41:15 PM GMT your computer crashed crash dump file: C:\Windows\Minidump\041414-5584-01.dmp This was probably caused by the following module: nto

  • HELP!! My 8830 won't place calls.

     I activated my 8830 World Edition yesterday. I can use the interent, email, and text messaging, but i cannot place or receive phone calls. Everytime i try to place a call i get the error: Sorry, Only emergency calls can be placed. has anyone had thi

  • How to Put Serial Number in "UUT Information" Screen

    Hi guys! I'm reading the Serial Number using a Cemera and a 2D code on Units, and I would like to put the serial number in the corresponding box of "UUT Information". At this time I'm puting the serial number on Report using "RunState.Caller.Locals.U