How to delete a dynamically created context node ?

Hi
  I have created a context node dynamically and have added the check boxes to the node.
  But when i am refreshing the page it is giving me the following excepiton:
com.sap.tc.webdynpro.progmodel.context.ContextException: DataNodeInfo(DwdReportView.Person): duplicate name for attribute attr1
I am writing the following code in wdDoExit() method so that the node is invalidated  and all dynamically added nodes and attributes are destroyed from the metadata.
The code  is :
     wdContext.getContext().reset(false);
or
     wdContext.getContext().reset();
or
                     wdContext.nodeName().invalidate();
I have tried all the above mentioned code  snippets but it is still giving me the same exception.
Please help me  resolve this issue.
Thanks in advance.
Regards
Shaily

Shally,
A better forum to place your question is the forum.
To your question: the wdDoExit() method is only called once i.e. when the view is destroyed from memory. Just like the wdDoInit() mehtod is called only once at initialisation of the view.
Try refactoring your code, so that upon initialising of your context, the old version of it is removed.
Hope this helps.
Regards,
Alain

Similar Messages

  • How to access the structure of a dynamically created context node/element

    Hi All,
    in method wddoinit I have added a context node and some attributes
    lo_node = wd_context->get_child_node( name = wd_this->wdctx_instructors ).
      lo_node_info = lo_node->get_node_info( ).
      lo_node_info = lo_node_info->add_new_child_node( name                  = 'OCCUPANCY'
                                                       is_mandatory          = abap_true
                                                       is_multiple           = abap_false
                                                       is_multiple_selection = abap_false ).
          lo_node_info->add_attribute( ls_attr ).
    So far, I have node INSTRUCTORS (0...n) with a subnode OCCUPANCY (1...1)
    In the supply_method of INSTRUCTORS I would like to fill the instructors node and the OCCUPANCY subnode.
    The thing is I do not know the structure of the dynamicaly created subnode OCCUPANCY there. How can I get a description of this node (that, what in non-dynamic programming would be wd_this->element_occupancy...)??
    THANKS,
    Johannes

    ...I got this one solved by myself...
    I simply added this coding:
    lo_node_info = lo_node->get_node_info( ).
      lt_attributes = lo_node_info->get_attribute_names( ).
    This appers to be enough information to be good to gogo
    Thanks anyway.

  • Creating context node with dynamic type

    When we are creating context node thru wizard,  Dictionary type must be filled. I'm trying to create Context node manually.Did any one tried created Context node class with Dynamic type.

    Hi Prasad,
    I have a similar requirement.
    Can you please share with me how did you create context node with dynamic table data?
    Thanks
    Vicky

  • Dynamic reverse context node mapping at runtime

    Hi!
    I have an application which uses another embedded component containing a ALV table which shows the data of a transparent table.
    Everything works fine if i'm working with a static table with static attributes and map the context node of the application to the node in the embedded component. The context node in the embedded component is reversed mapped and gets its data from the application's context node.
    Now i want to do it dynamically. Inside the application the user should choose the name of a table and I'm using RTTI functions to get it's technical informations. At runtime i'm adding dynamically attributes (i.e. fieldname, type, length) to a static context node called 'DATA'.
    The ALV component of the embedded component is mapped to an interface context node named 'DATA' which uses reverse mapping to receive data from the applications context node 'DATA'.
    What I need to know is how to create the mapping between application context node and interface context node of the embedded component at runtime after i have created the attributes of the node dynamically. Is that basically possible?
    I've already tried to map the both nodes statically to see if the dynamically created attributes are mapped automatically then. The mapping seems to be fine at node level, but doesn't work for the later dynamically added attributes.
    Could someone point me to informations if dynamic mapping context nodes is basically possible and how to do it?
    Regards
    Ralf-J.

    Hi Lars!
    Thanks for the link! The problem isn't to fill the context node dynamically. That's already working using RTTI etc.
    It seems to me that the interface context node of the ALV in the embedded component doesn't recognize the dynamically added attributes. As i wrote the binding on node level (DATA->DATA), which i'm doing at design time, is working as expected, but the added attributes are only shown in the context node of the using component but not in the embedded.
    I'm still thinking there must be a way to do a binding at runtime. On the other hand the comment of Glenn in the thread you've pointed me to, seems to suggest that the ALV itself might have problems with dynamically appended attributes.
    Regards
    Ralf-J.

  • Accessing Dynamically created Context

    Hi,
    I want to actually read the context which is dynamically created. I have a basic doubt that, will that context contain all the records or just metadata in context? How to read certain records from the context. I dont want to populate them to view via some textbox etc, actually using that data I want to create some xml. so I need to read all the records which are available in that context.
    Please let me know your inputs asap.
    Best REgards,
    Ritesh

    Hi Mehta,
    You can create both nodes as well as attributes in context dynamically. If you are creating a context attribute it will have only a single value.If you are creating context nodes it will have multiple values
    IWDNode node = wdContext.getChildNode("<node name>",IWDNode.LEAD_SELECTION);
    IWDTextview text = (IWDTextview)view,createElement(IWDTextview.class,null)
    text.bindText(node.getElementAt(<give index>).getAttribute())
    Hope this helps you
    Try to create context attributes and nodes statically
    Hope this helps you
    Regards
    Rohit

  • How to search data from a context node.

    Hi Friends,
    Thanks for ur help for previous problem . I am facing some other problem i.e how to
    search data from a context node.
    i have a context node :-
    Car(main node) which consist of details, owners, engine and Brand  as its sub node.
    the value attibutes of difft nodes are:-
    Car-  category
    Details-  Mileage, Price, registration_no, miles_used
    owner -  name, phnno,addrs
    Brand -  main_brand, co_brand
    Engine- Bhp,Rpm
    Now i have to apply a search criteria on the basis of price, miles_used .
    pls help to implement that .
    Thanks & regards
    Pravin jha

    Hi PRAVIN,
                       What I can understand from your problem is that, you have a list with various properties and you want to display them and search them in your WD App. If I am correct, use the following approach:
    Instead of using "details, owners, engine and Brand" Nodes, use the attributes inside the parent node. i.e in the node Car, add all the attributes viz. Mileage, Price, registration_no, miles_used, name, phnno,addr etc.
    Now you can create a table of this node "Car" and can easily search on the basis of any criteria.
    I hope this solves your issue. If you are looking for something else, please revert, I'll be happy to help you.
    Cheers!!!
    Umang

  • Is it possible to dynamically create xml nodes?

    Hi,
    Is it possible to dynamically create child nodes of an xml
    file with flash??
    Im what i want to do is save a users name etc in an xml file
    without having to manually add nodes in.
    So when a user clicks a button to save their details a new
    node is created.
    Thnx

    Yes.
    Look
    at XML.appendChild as a starting point.

  • How to access a dynamic created attribute in a context node?

    <i>Hello,</i>
    <i>who could help? I can't set a value for a dynamically created attribute which is bind to a table.</i>
    <i>My context of the view looks as follow (is defined in NetWeaver):</i>
      - Context
         - Availability (Node)
             - vctxService (Attribute)
             - vctxServiceDesc (Attribute)
             - ... (further predefined attributes)
             - ... (some have to be set dynamically as follows)
    <i>Then I have added attributes dynamically in the wdDoModifyView(...) - method, as follows:</i>
    for (int i = 0; i < max; i++) {
       // some code to dynamically create table columns
       // adding attributes dynamically
       IWDAttributeInfo attrInfo =       wdContext.nodeAvailability().getNodeInfo().      addAttribute("vctxAvailability_" + i, "ddic:com.sap.dictionary.string");
       tv.bindText(attrInfo); // bind to TextView in table
    <i>In the method onPlugFrom... I tried to set the values for the attributes "vctxAvailability_ + i" as follows:</i>
    for (int i = 0; i < max; i++) {
       IAvailabilityElement newAvailNodeElement =     wdContext.createAvailabilityElement();
       // some values will be set for the
       // predefined attributes of AvailabilityNode
       // newAvailNodeElement.set...( value );
       // newAvailNodeElement.setVctxService( xy.getServ() );
       // now the values of dynamically created and added
       // attributes in AvailabilityNode will be added
       // THIS DOESN'T WORK
       newAvailNodeElement.setAttributeValue    ("vctxAvailability_" + i, "value" + i);
    <i>It would be great if someone could help me.
    Thanks in advance.
    Kind regards,
    Carsten</i>

    Carsten,
    Here is a sample code that creates context attributes dynamically and also sets values:
    //Creates a node
    IWDNodeInfo nodeInfo = wdContext.wdGetAPI().getRootNodeInfo().addChild("TestNode", null, true, true, false, true, false, true, null, null, null);
    //If you want to bind the node to a model node then the
    //second argument to the above method should be the
    //model class.
    //Creates an attribute under the node just created.
    IWDAttributeInfo testAttrib = wdContext.wdGetAPI().getRootNodeInfo().getChild("TestNode").addAttribute("testAttrib", "ddic:com.sap.dictionary.string");
    IWDNodeElement testNode = wdContext.getChildNode("TestNode", IWDNode.LEAD_SELECTION).getCurrentElement();
    IWDNode testNode2 = wdContext.getChildNode("TestNode", IWDNode.LEAD_SELECTION);
    //Now you can bind testNode with the Model Node
    //You can also set a value to the newly created attribute
    testNode.setAttributeValue("testAttrib", new String("Value"));
    Hope this helps.
    Shakeel

  • Creating context node dynamically in web dynpro for java

    Hi
    I am having requirement where user can ask for 3 tables . I have created tables dynamically. But now  i want that context node should also be created dynamically.
    Thanks and Regards,
    Saurabh

    Hello Saurabh,
    Refer the below link:
    http://wiki.sdn.sap.com/wiki/display/WDJava/DynamicUIGeneration.
    There is a section Dynamically Building the Context. Please refer to that.
    There are lots of things available in SDN for the same.
    Regards
    Nizamudeen SM

  • How to get a dynamically created symbol to delete itself on click?

    Here's the setup...
    I want to have a dynamically created symbol appear upon click of a hotspot. In this case, you click on a pulsating hotspot and a popup box appears.
    Here's the code I'm using for that.
    //Create an instance element of a symbol as a child of the given parent element
    var mySymbolObject = sym.createChildSymbol("gardern_toxins_popup","stage");
    So we have the symbol "garden_toxins_popup" from my library placed dynamically on the page. I would like to assign an action to the pop-up itself that allows you to remove the symbol from the stage upon click.
    I feel silly for not being able to figure this out. I tried iterations of this bit of code...
    //Get the stage from the composition level, get the symbol
    sym.getComposition().getStage().getSymbol("garden_toxins_popup").delete();
    ...but it doesn't work.
    So I tried thinking like I was back in Flash and tried the following...
    this.parent.removeChild(this);
    But no joy on that as well. Is there something I haven't addressed in this logic or am I going about it in the wrong way? Thanks!

    Hi, chirpieguy-
    You'll want to use the deleteSymbol() API.
    http://www.adobe.com/devnet-docs/edgeanimate/api/current/index.html
    BTW, you should use the capitalized "Stage" to add it to the Stage - the lower case stage has a special meaning with Animate and might not give you what you want..
    sym.createChildSymbol("gardentoxins", "Stage");
    In the symbol itself, create a click event on a container div, then:
    sym.deleteSymbol();
    That being said, you don't need to dynamically create and delete an object.  What you can do is to use hide() and show() on an element and use the coordinates of your click to change the CSS value of top/left of this object so that you don't have to do the object management I highlighted above.
    Hope that points you in the right direction.
    -Elaine

  • How to bind UI Element with Context Node Attribute Element

    Hi,
    I'm building my view dynamically in the wdDoModifyView method.
    Is it possible to bind a "TextView" element to a specific element of an attribute node?
    Scenario:
    Node_Employees
    |
    +- Attribute_Code
    |
    +- Attribute_Name
    Node Contents:
    Employees
    |
    +- Code: 1, Name: Employee 1
    |
    +- Code: 2, Name: Employee 2
    |
    +- Code: 3, Name: Employee 3
    I need to do something like binding a TextView UI element to the "Name" attribute of the element #2, what would result to show "Employee 2" on my view.
    How can I do this?
    Thanks in advance,
    Geraldo.

    Hi Saravanan,
    First I populate the context node and it won't change during view's lifecycle.  After that, I build my view and bind the TextView UI elements to the node context attributes elements.
    If the node has 10 elements, I will build 10 TextView UI elements and bind them to each attribute element.
    Regards,
    Geraldo Brígido.

  • How to modify the data of Context Node of type table in BSPCOMP WB

    Hi,
    I have context node which is of table type. Now, beofre displaying the table, I have to delete few entries from this context node.
    Could you please help me out, how exactly I can handle this?
    Component: BP_DATA (Enhanced)
    View: MarketingAttributesEOVP
    Context Node: ATTRIBUTES 
    Thanks,
    Sandeep

    Make use of ON_NEW_FOCUS method of the context node to achieve the same. Get the collection first and then iterate it remove the entities which are not needed and then set the rest of the collection. You can also check standard code for reference.
    Rg,
    Harshit Kumar

  • Dynamically create context menu

    I'm trying to create a context menu based on a certain af:commandImageLink.
    I have an af:popup with an af:menu in my page. I bound the af:menu to my bean so I can change the content. I didn't put any children in the menu to start because I want to add the children based on the image that's click.
    I added an af:showPopupBehavior to show my popup on click. The idea was that I wanted to use the actionListener of the af:commandImageLink to dynamically create the menu that I need. But it seems that the actionListener fires after the showPopupBehavior most times. On the first click, it looks like the actionListener fires first then the showPopupBehavior. After that, it seems the actionListener always fires after.
    So it looks like this is not really supposed to work.
    Does anyone have any suggestions on how this should be made to work?

    Thanks a lot Timo,
    This does allow me to control when the popup shows up.
    I modified the code you gave slightly to include code to align the popup:
        public static void showPopup(String popupId, String alignId) {
            FacesContext context = FacesContext.getCurrentInstance();
            StringBuilder script = new StringBuilder();
            script.append("var popup = AdfPage.PAGE.findComponent('").append(popupId).append("'); ").append("if (!popup.isPopupVisible()) { ")
                .append("var hints = {}; ").append("hints[AdfRichPopup.HINT_ALIGN_ID] = '").append(alignId).append("'; ")
                .append("hints[AdfRichPopup.HINT_ALIGN] = AdfRichPopup.ALIGN_AFTER_END; ").append("popup.show(hints);}");
            ExtendedRenderKitService erks = Service.getService(context.getRenderKit(), ExtendedRenderKitService.class);
            erks.addScript(context, script.toString());
        }I still have some problems though. I need to give some more context on this.
    So I have an af:iterator that shows a list of images. I'm trying to popup a context menu when they click the image. The menu needs to be aligned relative to the image that was clicked.
    However, when I tried to get the ID from the ActionEvent, I get the design time ID which should not be the same as the run time ID because the iterator would have created multiple instances of the image, each with a unique ID. I'm assuming that's why the alignment is not working.
    Am I missing something here?
    Also, I seem to be having problems with modifying the menu. Here's my bean code:
        private RichMenu baseMenu;
        public void imageActionListener(ActionEvent actionEvent) {
            Object o = actionEvent.getComponent();
            RichCommandImageLink image = (RichCommandImageLink)o;
            DCIteratorBinding iteLoc = ADFUtils.findIterator("OpItemLocationsVO2Iterator");
            for(Row row : iteLoc.getAllRowsInRange()) {
                OpItemLocationsVORowImpl r = (OpItemLocationsVORowImpl)row;
                RichCommandMenuItem a = new RichCommandMenuItem();
                Number n = r.getItelocId().getSequenceNumber();
                a.setId("i" + r.getItelocId().getSequenceNumber().toString());
                a.setText(r.getItelocId().getSequenceNumber().toString());
                baseMenu.getChildren().add(a);
            AdfFacesContext.getCurrentInstance().addPartialTarget(baseMenu);
            showPopup("vmenu", image.getId());
        }So in my popup, I added a menu and I bound that menu to this bean. The idea was that whenever an image was clicked, I would remove all the children from the menu, then add the new ones. There would be a master-detail relationship between the image's iterator and the menu that's supposed to show up.
    The other problems that I'm getting with this is that the menu is not changing when I click on a different image. When I debug, I'll see the correct values being added, but nothing changes on the screen. It's always showing the first popup that was ever created. Also, I don't know how to remove the previous children. There doesn't seem to be an API to remove the children.
    Thoughts?

  • How to use attributes from different context nodes in one view?

    I am VERY new to the concept of CRM and currently working on creating an alternate version of the BP_HEAD_SEARCH. With help from SAPPRESSs book 'SAP CRM Web Client' i was ble to create my own simple Z-component.
    However after going back and forth the book and the forum (including this [article|https://wiki.sdn.sap.com/wiki/display/CRM/Howtoaddanexistingfieldtoasearchpageofadifferent+component]) i was not able to find a solution to my problem. My current search uses BuilHeaderAdvancedSearch as context node for searching. But the search should also be able to use attributes from BuilActivity, which is directly related to BuilHeader. I can't seem to find a way to get attributes from BuilActivity into the search window of my component without having to change SAP-Standard.
    Is this really the only way? Please advise on possible code and insertion point.

    Any suggestions?

  • How to delete the automatically created receipt in the expense report

    Hi experts,
    I am getting an error "no expense type for estimated costs has been defined. cannot save" while creating a travel request for an employee.
    Base on the reply from Raynard which posted on Re: FM for  trip exp
    It's because "The estimated cost in plan and request are now included into fund management. So if you have active funds management, the entered estimated cost are used to make availability check and commitment. Therefore you must create an expense type in view V_T706B1. Under 'amounts are' you have to choose 'estimated cost, no reimbursement to employee'."
    How ever, because the linkage with funds management, I faced the problem and also ckecked out the reason from SAP Help that "After the trip takes place, the user needs to manually delete the automatically created receipt in the expense report."
    Anybody can provide the solution how to automatically delete this receipt before user create the expense report??
    Thanks
    Daniel

    Hi Francis,
    Check the BADI "TRIP_WEB_CHECK" method "USER_CHECK_GENERAL_DATA".
    Here based on the schema you can modify the "estimated cost" field.
    Hope it helps.
    Regards,
    Jyothi

Maybe you are looking for