Dynamic creation of context nodes and ui elements

Hi,
I have created context nodes dynamically. And i also want to create UI elements dynamically wherein i want to bind the attribute from the context node to it. For example i want to create a drop down by index and bind one of the attributes in the context nodes that i have earlier created dynamically to it.  I do not know how to get the path to the attribute as i get IF_WD_CONTEXTNODE_INFO when i say get_child_node(). And the IF_WD_CONTEXTNODE_INFO does not have any method where in i can get IF_WD_CONTEXT_NODE from where i can get the path by get_meta_path( )
Here is the code. The problem is to get the path which is the i/p to cl_wd_dropdown_by_idx=>new_dropdown_by_idx( ) method.
DATA:
        lo_root_ui_elmnt              TYPE REF TO cl_wd_uielement_container,
        lo_drpdwn_by_idx              TYPE REF TO cl_wd_dropdown_by_idx,
        lo_txt_vw                     TYPE REF TO cl_wd_text_view,
        lo_qstn_node                  TYPE REF TO if_wd_context_node,
        lo_optn_node_info             TYPE REF TO if_wd_context_node_info,
        lv_optn_data_source_name      TYPE string,
        lt_child_nodes                TYPE wdr_context_child_map,
        lo_qstn_el                    TYPE REF TO if_wd_context_element,
        lo_optn_el                    TYPE REF TO if_wd_context_element,
        lv_text                       TYPE string,
        lo_qstn_node_info             TYPE REF TO if_wd_context_node_info.
  FIELD-SYMBOLS:
*                 <ls_qstn>    LIKE LINE OF wd_this->mt_questions.
                <ls_child_node>         LIKE LINE OF lt_child_nodes.
  lo_root_ui_elmnt ?= io_view->get_root_element( ).
  lt_child_nodes = wd_context->get_child_nodes( ).
LOOP AT lt_child_nodes ASSIGNING <ls_child_node>.
   lo_qstn_node = <ls_child_node>-node.
    lo_qstn_el = lo_qstn_node->get_element( index = 1 ).
    lo_qstn_el->get_attribute(
          EXPORTING
            name = 'QUESTION_TEXT'
           IMPORTING
             value = lv_text ).
    lo_txt_vw =   cl_wd_text_view=>new_text_view( view = io_view ).
    lo_txt_vw->set_text( value = lv_text  ).
    lo_qstn_node_info = lo_qstn_node->get_node_info( ).
    lo_optn_node_info = lo_qstn_node_info->get_child_node( 'OPTIONS' ).
*    lv_optn_data_source_name = lo_optn_node_info->get_meta_path( withoutcontroller = abap_true ).
*    CONCATENATE lv_optn_data_source_name '.' 'OPTION_TEXT' INTO lv_optn_data_source_name.
    lo_drpdwn_by_idx = cl_wd_dropdown_by_idx=>new_dropdown_by_idx(
                          bind_texts = lv_optn_data_source_name
                          view       = io_view ).
    lo_root_ui_elmnt->add_child( lo_txt_vw ).
    lo_root_ui_elmnt->add_child( lo_drpdwn_by_idx ).
  ENDLOOP.
Regards,
Madhura Lobo
Edited by: Suhas Saha on Aug 2, 2011 11:04 AM

Hi Madhura,
Please check this thread and find Baskaran answer...
create new child-node in supply-function
Re: Creating Dynamic Node and Table
Cheers,
Kris.

Similar Messages

  • Dynamic Creation of Context Nodes

    Hi everybody,
    I'm struggling with the following code.
    public void wdDoInit()
        //@@begin wdDoInit()
              IPrivateTestView.IPersonNode personNode = wdContext.nodePerson();
              IPrivateTestView.IPersonElement personElement = personNode.createPersonElement();
              personElement.setText("John");
              personNode.getNodeInfo().addAttribute("selected_0", "ddic:com.sap.dictionary.boolean");
              personElement.setAttributeValue("selected_0", new Boolean(true));
              personNode.addElement(personElement);
              personNode = wdContext.nodePerson();
              personElement = personNode.createPersonElement();
              personElement.setText("Walter");
              personNode.getNodeInfo().addAttribute("selected_1", "ddic:com.sap.dictionary.boolean");
              personElement.setAttributeValue("selected_1", new Boolean(true));
              personNode.addElement(personElement);
        //@@end
    public static void wdDoModifyView(IPrivateTestView wdThis, IPrivateTestView.IContextNode wdContext, com.sap.tc.webdynpro.progmodel.api.IWDView view, boolean firstTime)
        //@@begin wdDoModifyView
              IWDTransparentContainer tc = (IWDTransparentContainer) view.getElement("container");
              IWDCheckBox cb0 = (IWDCheckBox) view.createElement(IWDCheckBox.class, "cb_0");
              IWDCheckBox cb1 = (IWDCheckBox) view.createElement(IWDCheckBox.class, "cb_1");
              IPrivateTestView.IPersonElement personElement = (IPrivateTestView.IPersonElement) wdContext.nodePerson().getElementAt(0);
              cb0.bindChecked(personElement.getAttributePointer("selected_0").getAttributeInfo());
              tc.addChild(cb0);
              personElement = (IPrivateTestView.IPersonElement) wdContext.nodePerson().getElementAt(1);
              cb1.bindChecked(personElement.getAttributePointer("selected_1").getAttributeInfo());
              tc.addChild(cb1);
        //@@end
    Context's structure is as follows:
    - Person (cardinality: 0..n; selection:0..n)
    - Text   (String)
    I cannot figure out why, when the program runs, it renders 2 checkboxes but only the first one is checked.
    The second checkbox should be checked off as well since its checked property is bound to the attribute selected_1 which is set to true.
    Thanks in advance.
    Marco

    Hi,
    As per my understanding you are trying to create group of check boxes dynamaically and all check boxes should work independent of each other. Please try the following code, I have modified your code:
    - Change the cardinality of the Peron node to 1..1
    public void wdDoInit()
        //@@begin wdDoInit()
         IPrivateTestComponentView.IPersonNode personNode = wdContext.nodePerson();
         IPrivateTestComponentView.IPersonElement personElement = personNode.currentPersonElement();
         //personElement.setText("John");
         personNode.getNodeInfo().addAttribute("selected_0", "ddic:com.sap.dictionary.boolean");
         personElement.setAttributeValue("selected_0", new Boolean(true));
         personNode.getNodeInfo().addAttribute("text_0", "ddic:com.sap.dictionary.string");
         personElement.setAttributeValue("text_0","John");
         //personNode.addElement(personElement);
         //personNode = wdContext.nodePerson();
         //personElement = personNode.createPersonElement();
         //personElement.setText("Walter");
         personNode.getNodeInfo().addAttribute("selected_1", "ddic:com.sap.dictionary.boolean");
         personElement.setAttributeValue("selected_1", new Boolean(true));
         personNode.getNodeInfo().addAttribute("text_1", "ddic:com.sap.dictionary.string");
         personElement.setAttributeValue("text_1","Walter");
         //personNode.addElement(personElement);
        //@@end
      public static void wdDoModifyView(IPrivateTestComponentView wdThis, IPrivateTestComponentView.IContextNode wdContext, com.sap.tc.webdynpro.progmodel.api.IWDView view, boolean firstTime)
        //@@begin wdDoModifyView
        if(firstTime)
         IWDTransparentContainer tc = (IWDTransparentContainer) view.getElement("container");
         IWDCheckBox cb0 = (IWDCheckBox) view.createElement(IWDCheckBox.class, "cb_0");
         IWDCheckBox cb1 = (IWDCheckBox) view.createElement(IWDCheckBox.class, "cb_1");
         //IPrivateTestComponentView.IPersonElement personElement = (IPrivateTestComponentView.IPersonElement) wdContext.nodePerson().getElementAt(0);
         cb0.bindChecked(wdContext.nodePerson().getNodeInfo().getAttribute("selected_0"));
         cb0.bindText(wdContext.nodePerson().getNodeInfo().getAttribute("text_0"));
         tc.addChild(cb0);
         //personElement = (IPrivateTestComponentView.IPersonElement) wdContext.nodePerson().getElementAt(1);
         cb1.bindChecked(wdContext.nodePerson().getNodeInfo().getAttribute("selected_1"));
         cb1.bindText(wdContext.nodePerson().getNodeInfo().getAttribute("text_1"));
         tc.addChild(cb1);
        //@@end
    Here I have used 1..1 cardinaltiy node and created all attributes dynamically.
    Regards
    Abhilash

  • Creation of project definition and wbs element

    I want creation of project definition and wbs element upto 4 level using bapis.
    i am using transaction cj27,cj01,cj02
    which function module to use for this??

    Hi,
    to create project definition with customer fields the BAPI you should use is : BAPI_BUS2001_CREATE
    to create WBS elements with different levels and specific fields the BAPI you should use is BAPI_BUS2054_CREATE_MULTI
    these bapi must be used in the sequence of call :
    BAPI_PS_INITIALIZATION
    BAPI_BUS2001_CREATE / BAPI_BUS2054_CREATE_MULTI
    BAPI_PS_PRECOMMIT
    BAPI_TRANSACTION_COMMIT
    before using the bapi, you must apply OSS note :
    637345 - Syntax error with enhanced PS tables
    i sent you the oss note to your mail
    please reward points if helpfull.

  • Dynamic Table control with context nodes and attributes?

    Hi all
    I have node and attributes in context. i want to create table dynamically using this node and attributes, can anyone give code how to do this???
    Thanks
    Madhan.

    Hi
    Go through this [link|http://www.sdn.sap.com/irj/scn/go/portal/prtroot/docs/library/uuid/80a3de18-ee00-2d10-bfb3-946d7e00fd91?quicklink=index&overridelayout=true].
    Regards
    Arun.P

  • Reg: Dynamic creation of context

    Hi,
    I have a value node Vn_node and one value attribute Va_att and i have binded it a table.
    I have another node Vn_node1 and attribute for this is Va_att1,
    based on the size of Vn_node1, i need to create value attributes in Vn_node of type checkbox and bind it to the table and the header text should be corresponding Va_att1.
    Kindly suggest.
    Regards,
    Prasanthi.

    For Dynammically creating Context use the following code:
    Ctx_bool1 is a context whose property is checked and it is set true and Context added to the node of type string.( you can change its type).
    Added code in OnActionget:
    if(!wdContext.currentContextElement().getCtx_bool1())
              wdContext.currentContextElement().setCtx_bool1(true);
              wdContext.getNodeInfo().addAttribute("nameValue","ddic:com.sap.dictionary.string");
    In wddomodifyView:
    You can bind the context attribute to a field or so shown and add it to RootContainer.
    Field is created.
    IWDInputField input = (IWDInputField)view.createElement(IWDInputField.class,"nameField");
    Binding of field to the context.
    input.bindValue("nameValue");
    Adding it to RootContainer.
    IWDTransparentContainer  c = (IWDTransparentContainer)view.getElement("RootUIElementContainer");
    c.addchild(input).
    I hope this wud help you as you would be able to create a context dynammically and bind it with field.
    Thanx.

  • Data storage in a context node and in a context attribute.

    Hi All,
    I want to know how exactly the data is stored in context node (internal table) and in context attribute (single value) in memory during the runtime.
    Regards,
    Yugesh A

    Hi Andrea,
    Sorry I got it wrong , for lr_comp you will have to take reference from controller IMPL class.
    DATA:
              lr_entity TYPE REF TO cl_crm_bol_entity,
            lr_comp TYPE REF TO ( component controller IMPL class),
             lv_ref_guid     TYPE        crmt_object_guid,
             lr_collection TYPE REF TO cl_crm_bol_bo_col,
             lr_bdc type ref to  if_crm_ui_data_context,
             comp_controller type cl_bsp_wd_component_controller.
    lr_comp  ?= me->comp_controller.
    IF lr_comp IS BOUND.
        TRY.
    lr_entity ?= lr_comp->ZTYPED_CONTEXT->ZBTCUSTOMERH->collection_wrapper->get_current( ).
         lv_ref_guid = lr_entity->get_property_as_string( iv_attr_name = 'REF_GUID' ).
          CATCH cx_sy_ref_is_initial.
          ENDTRY.
    ENDIF.
    Hope it helps.
    Regards,
    Manjeet Singh.

  • Dynamic Creation of Data Tables and Fields

    Hello all. I am currently working with a system that contains a bunch of windows. These windows are divided into two groups that represent their presentation style: Columns (such as a table) and Free (such as in a form). I created two tables in database to describe each and every window. These tables describe the type of presentation style, the fields of each window (title of the field, size of the field, position in window, and many more...)
    I did this to make the creation of the windows more effective. In this way that I have, I only have to make one window to display all the thousands of windows that I have in my database because the values of presentation are taken from the description in the tables.
    I was able to do this through TextFields and JTables in Swing. But now I run into JSC. Is this possible with JSC? Say in case the presentation style of the window is Column, can I tell the data table to go read the description of the window that needs to be opened to obtain the amount of columns, the column names, the size of each column... then create the tables and present the values?
    Or say the presentation style is Free... I need to go find how many fields need to be created and their positions in the form, and then the titles of each field. Any ideas how this can be performed?
    Thank you.
    Franklin Angulo

    >
    I was able to do this through TextFields and JTables
    in Swing. But now I run into JSC. Is this possible
    with JSC? Say in case the presentation style of the
    window is Column, can I tell the data table to go
    read the description of the window that needs to be
    opened to obtain the amount of columns, the column
    names, the size of each column... then create the
    tables and present the values?
    Or say the presentation style is Free... I need to go
    find how many fields need to be created and their
    positions in the form, and then the titles of each
    field. Any ideas how this can be performed?
    Creator won't help you with the graphical design, but it's definitely possible to dynamically compose the set of components that are children of a particular component. Doing so leverages the basic component APIs of JSF (javax.faces.component.UIComponent), so you'll want to grab yourself a copy of the JSF Javadocs (or use Creator's lookup facilities as you type your code) to understand what's possible.
    The most important detail is that all components have a getChildren() method that returns a java.util.List of the child components for that component (as well as a getParent() to get the parent component). Any manipulation you do on this returned list is reflected in the structure of the overal component tree.
    As a simple example, assume you want to add an input text component as a child of the form. You'd do something like this:
    HtmlInputText input = new HtmlInputText();
    input.setXxx(..); // Set properties as needed
    form1.getChildren().add(input); // add new childCraig McClanahan

  • Dynamic creation of xml node

    Hi there
    I can't quite figure out how to add a node based on a passed
    variable value
    If I hard code it as can be seen in the line of code
    commented out - it works.
    But if I try to pass a string, it doesn't work
    public function addNodeToXML(passedNodeName:String):void {
    //_qualificationSummaryScreenXML.appendChild(<pupil
    />);
    _qualificationSummaryScreenXML.appendChild(passedNodeName);
    This is the call to the function
    addNodeToXML("<pupil />");
    Would be very grateful if someone can help me fix this
    Thanks
    Paul

    Hi Suman,
    I would suggest that you ask questions about ABAP WD in the forum for ABAP WD.
    Kind regards,
    Ulrich

  • 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.

  • 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.

  • Element addition to context node at runtime.

    Hi all,
    I have a class array object in which all data comes at runtime.
    I created a node in context.
    i have to add the element to node. i ahve used that node as a datasource to table UI.
    EmpWrapper e[] = null;
    e = tmp1.Get(wdContext.currentContextElement().getDIVISION());
    // i am getting all data in e[]
            if (e.length != 0)
            for (int i=0;i<= e.length;i++){
    //how to add the e data to node EMP in context                       

    Hi Shefali,
    Here is the link to create dynamic context nodes and its attributes.
    https://www.sdn.sap.com/irj/sdn/downloaditem?rid=/library/uuid/b3f6e990-0201-0010-c087-c865f2c738b3
    Regards,
    Abhimanyu L

  • 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.

  • Dynamic Context Node Copying question

    I am trying to dynamically copy some context nodes from my component controller to the view controller.  In the source context, I have a node whose "Multiple" property is set to true.
    I use the function addMappedChild to copy the attribute info, but the copied node always has "Multiple" set to false!! In the definition of addMappedChild there is no paramter for "Multiple".  How do I do this?
    Thanks
    Walter
    public IWDNodeInfo addMappedChild(java.lang.String name,
                                      java.lang.Class elementClass,
                                      boolean singleton,
                                      boolean mandatorySelection,
                                      boolean multipleSelection,
                                      java.lang.String mappedPath,
                                      boolean selectionMapped,
                                      boolean initializeLeadSelection)

    Are you making like dscribed here
    https://www.sdn.sap.com/irj/servlet/prt/portal/prtroot/com.sap.km.cm.docs/library/webas/webdynpro/dynamically creating, building, and mapping a context in web dynpro.pdf 
    page 14?
    Best Regards, Maxim r.

  • How can I bind a dynamic attribute of a context node to ALV?

    Hi all,
    I'm trying to show data with Webdynpor ALV, but i met a question which blocked me. The situation is that there is a static context node and it's mapped to WD ALV, while programming I create a dynamic attribute to the context node. The dynamic column can be shown on the UI, but there is no any data in it. How can i deal with it?
    Thanks a lot!
    Edited by: Julia Zhu on Dec 3, 2009 7:48 AM

    Hi Julia,
    Welcome to SDN.
    Post it in the ABAP webdynpro forum to get quick replies. Web Dynpro ABAP
    Also search in sdn as there are chances that somebody has already posted the queries related to same issue.
    Regards,
    Swarna Munukoti.

  • Problem in accessing attribute of a context node

    Hi All,
    I have a context node called REFE and an attribute named REF to the node REFE. I am trying to get access to the attribute REF, so that i can dynamically set properties. But i am getting NULL Object error. I am successfully getting access to node REFE.
    Here is the code.
    lo_nd_refe = wd_context->get_child_node( name = wd_this->wdctx_refe ).
    lo_el_refe = lo_nd_refe->get_element(  ).
    lo_el_refe->set_attribute(
          EXPORTING
            name =  `REF`
            value = 'http://sapsndbp.sbic.co.za:8011/sap/bc/webdynpro/sap/zzdm_audit_report' ).
    Regards,
    RAvi

    Hi,
    What is the cardinality of the node.
    If it is 1:1 then you can get teh reference of the context element directly.
    If it 0:N or 1:N then you need to pass the index of the context element you are trying to get.
    Use the method get_element of the context node and pass the index value.
    Always check the element is initial or not before you process further for better coding.
    Regards,
    Lekha.

Maybe you are looking for