5 Replies Latest reply: Feb 27, 2006 5:57 AM by Anilkumar Vippagunta RSS

Dynamic Node Creation

Mukesh mani
Currently Being Moderated

Hai all,

          I am new to the Dynpro. i have to create 'n' number of drop down at dynamically. The values of 'n' only known at runtime, that is fetch from database. 

          Basically each dropdown must have one node and one attribute. So i have to create 'n' number of nodes. Each drop down have different values.

           I created some node at runtime using the following code.

       

      for(int j=0;j<count;j++){

      IWDNodeInfo node = wdContext.getNodeInfo

      ().addChild ("Roles"+j,null,true,     true,false,

      false,false,true,null,null,null);

 

      node.addAttribute(roles[j].toString  

      (),"com.sap.dictionary.string");

   }

 

This is done inside the wdDoInit() method.

 

Then i have to fetch the node one by one and load values from database and finally bind into the drop down inside the wdDoModifyView() method.

      I tried the following code,but i don't know whether is it correct way or not.

 

if (firstTime) {

          IWDTransparentContainer container = 

                (IWDTransparentContainer) view.getElement

                ("RootUIElementContainer");

container.createLayout(IWDMatrixLayout.class);

 

for(int rolecunt=0;rolecunt<size;rolecunt++){

 

IWDNode node = wdContext.currentContextElement().node().getChildNode("Roles"+rolecunt,rolecunt);

 

IWDNodeElement nodeElement1 = node.getCurrentElement();

}

}

 

thanks in advance,

 

Mukesh Mani.

  • Re: Dynamic Node Creation
    Currently Being Moderated

    Please avoid the code for populating values in the nodes from the domodify().You can create the dropdown there and just bind the node attribute to the dropdown.

     

    You can populate the values in the node elsewhere by creating the elements in the node and enterng values into it.

     

    Noufal

    • Re: Dynamic Node Creation
      Mukesh mani
      Currently Being Moderated

      Hai Noufal,

                  Thanks for your reply. I couldn't get you. From your suggestion i created dropdown only in domodify() like this,

       

      IWDDropDownByIndex dropDownList = (IWDDropDownByIndex)

      view.createElement (IWDDropDownByIndex.class, "inp");

                  How to bind node attribute into the above drop down. Before i created 'n' number of nodes in

      wdinit() method using the following code.

       

      for(int j=0;j<count;j++){

                      

                     IWDNodeInfo node =

                                 wdContext.getNodeInfo().addChild(

                                    "Roles"+j,

                                    null,

                                    true,

                                    true,

                                    false,

                                    false,

                                    false,

                                    true,

                                    null,

                                    null,

                                    null);

                                     

                                     

      //                    for(int k=0;k<count;k++){          

                               node.addAttribute(roles[j].toString(),"com.sap.dictionary.string");

                                

      //                    }

                                                                   

                }

      • Re: Dynamic Node Creation
        Currently Being Moderated

        dropDownList.bindTexts(<IWDAttributeInfo>);

         

        get the attribute info of the dynamiaclly created attribute and with the abpve code you can bind it to the dropDownList.

         

        IWDAttributeInfo info=wdContext.getNodeInfo().getChild("<name>").getAttribute(""<attributename>");

         

        Noufal

    • Re: Dynamic Node Creation
      Mukesh mani
      Currently Being Moderated

      Hai Noufal,

       

      <b>Sorry ignore my previous reply.</b>

       

      Thanks for your reply. I couldn't get you. From your suggestion i created dropdown only in domodify() like this,

       

      IWDDropDownByIndex dropDownList = (IWDDropDownByIndex)

      view.createElement (IWDDropDownByIndex.class, "inp");

       

      How to bind node attribute into the above drop down?.

       

      Before i created 'n' number of nodes in

      wdinit() method using the following code. I assume 'count' is 10 and have one string array, which name is 'roles'.

       

       

      for(int j=0;j<count;j++){

      IWDNodeInfo node =

      wdContext.getNodeInfo().addChild(

      "Roles"+j,

      null,

      true,

      true,

      false,

      false,

      false,

      true,

      null,

      null,

      null);

      node.addAttribute(roles[j].toString

      (),"com.sap.dictionary.string");

      }

            Is this correct?

            1. roles+j equal to node name.

            2. roles[j] equla to node element.

       

        How can i populates values(store) into the node?.

       

      Thanks in Advance,

      Mukesh Mani.

  • Re: Dynamic Node Creation
    Anilkumar Vippagunta
    Currently Being Moderated

    Hi Mukesh,

     

    Please try the following in wddoModifyView method

     

    IWDDropDownByIndex dropDownList = (IWDDropDownByIndex)

    view.createElement (IWDDropDownByIndex.class, "inp");

    for(int j=0;j<count;j++){

    IWDNodeInfo node =

    wdContext.getNodeInfo().addChild(

    "Roles"+j,

    null,

    true,

    true,

    false,

    false,

    false,

    true,

    null,

    null,

    null);

    node.addAttribute(roles[j].toString

    (),"com.sap.dictionary.string");

     

    inp.bindTexts(""Roles"j"."+roles[j].toString);

     

    }

     

     

     

    Best Regards, Anilkumar

Actions