Skip to Content
author's profile photo Former Member
Former Member

Dynamic Binding of Node to DropdownBYKey

Hi Colleagues,

I am new to WebDynpro.

I am facing an issue with "DropDownByKey" UI Element.

The scnario is:

1) There are 15 number of "DropDownByKey" UI Elements to be displayed on a page with the same data (time intervals).

One approach to achieve this would be:

1) Create a 15 attributes of simple data type and enter options in

enumerations.

2) Now bind each of these simple data types to all the 15 DropdownByKey elements.

The second approach could be:

1) Create a node with attribute type string.

2) Write functionality to add values to this attribute.

3) Create instances of Node.Attribute.

4) Bind these instances to individual 15 DropdownBykeys elements.

Please tell me which one of the two approaches would be better or if there is any other better approach.

In case, if the second appraoch is better, how to achieve this?

Thanks & Regards,

Ankit.

Add a comment
10|10000 characters needed characters exceeded

Assigned Tags

Related questions

6 Answers

  • Best Answer
    author's profile photo Former Member
    Former Member
    Posted on Sep 22, 2008 at 12:10 PM

    Hi,

    Create one SimpleType in Dictionaries with time data .

    Then use Dynamic programming to achieve your need

    in wdDomodifyView() method, write following code

    wdContext.getContext().reset(false);

    IWDTransparentContainer tc= (IWDTransparentContainer)view.getElement("RootUIElementContainer");

    tc.destroyAllChildren();

    for(int i=0;i<15;i++)

    {

    wdContext.getNodeInfo.addAttribute("attr"+i,"<SimpleTypePackage>.<SimpleTypeName> ");

    }

    for(int k=0;k<15;k++)

    {

    IWDDropDownByKey ddk=(IWDDropDownByKey)view.createElement(IWDDropDownByKey.class,"ddk");

    ddk.bindSelectedKey("attr"+k);

    tc.addChild(ddk);

    }

    Regards

    LN

    Add a comment
    10|10000 characters needed characters exceeded

  • Posted on Sep 19, 2008 at 11:09 AM

    Hi,

    Below way you can set values to a dropdown by key without using enumaration(your 2nd approcah) .

    /*Setting the Dropdown/

    IWDAttributeInfo info_propno =wdContext.nodeVn_From1NoOfPropsDropDown().getNodeInfo().getAttribute("Va_F1noOfProps");

    ISimpleTypeModifiable mod_propno =

    info_propno.getModifiableSimpleType();

    IModifiableSimpleValueSet svs_propno =

    mod_propno.getSVServices().getModifiableSimpleValueSet();

    String strcount=null;

    for (int count = 0;count<

    form1List.size();//wdContext.currentVn_FormDetailsElement().getVa_Form1List().size();

    count++) {

    strcount=""(count1);

    svs_propno.put(strcount,strcount);

    strcount="";

    }

    /** End of Setting the Dropdown*/

    Note : If you use a dropdown element and if you dont assign a context variable to it, you will get a null pointer exception.

    Regards,

    Srinivas.

    Add a comment
    10|10000 characters needed characters exceeded

    • Former Member Former Member

      Ankit,

      Here is how you can achieve what you want to do.

      public static void wdDoModifyView(IPrivateMulti_DropDownCompView wdThis, IPrivateMulti_DropDownCompView.IContextNode wdContext, 
      com.sap.tc.webdynpro.progmodel.api.IWDView view, boolean firstTime)
        {
          //@@begin wdDoModifyView
      	  if(firstTime)
      	  {
      		  for(int i=1; i<=15; i++)
      		  {
      			  IWDDropDownByKey theDropDown = (IWDDropDownByKey) view.getElement("DropDownByKey"+i);
      			  IWDAttributeInfo att1 = wdContext.nodeDDNode().getNodeInfo().addAttribute("DD"+i+"Data", 
                                                                  "ddic:com.sap.demo.multi_dropdowns.DataValue");
      			  theDropDown.bindSelectedKey(att1);
      		  }
      	  }
          //@@end
        }
      

      The assumption here are

      1. Your DropDownByKey element ids are DropDownByKey1 through DropDownByKey15.

      2. You have an independent node DDNode with cardinality 0..n

      3. You have one simple type DataValue with required enumeration created under path com.sap.demo.multi_dropdowns

      This works fine and different values can be selected for separate DropDownByKey elements.

      Having said this, I am not sure why you want to do this dynamically when this can be achieved easily by creating 15 attributes of a simple type 'DataValue' and binding them to your DropDownByKey elements at design time. I hope you are not getting confused among 15 attributes and 15 elements as binding an element to DropDownByKey is not possible (as far as I know).

      It is better to construct as much of the view layout as possible at design time to keep things simple for you and later for people supporting the application.

      Anyway, you have both the options now :-). Take your pick.

      Hope this helps.

      Vishwas.

  • author's profile photo Former Member
    Former Member
    Posted on Sep 19, 2008 at 11:21 AM

    I suggest first option because we may select different value in each dropdown.

    If we maintain only one attribute to all dropdown elements selected value will be same for all dropdowns

    Let me know if you need more clarifications

    Thanks

    Add a comment
    10|10000 characters needed characters exceeded

    • Former Member

      Hi Tatayya,

      It means that I should create 15 separate attributes for 15 different UI Elements of same type (DropDownByKey).

      Is there any way to create instances of a Ui Context node and attach these instances to UI Elemnts at runtime?

      Thanks & Regards,

      Ankit.

  • author's profile photo Former Member
    Former Member
    Posted on Sep 19, 2008 at 11:42 AM

    Hi,

    follow below steps,

    1.create one simple type which holds required values

    2.create 15 value attributes of type simple type.

    3.bind with DropDownByKey.

    it is easy way to achieve your requirement.

    Regards,

    ramesh.

    Add a comment
    10|10000 characters needed characters exceeded

  • author's profile photo Former Member
    Former Member
    Posted on Sep 19, 2008 at 12:46 PM

    Hi Ankit,

    check these threads :[thread1|Dynamic Drop Down;

    [thread2|Dynamic Web Dynpro Project;

    hpe it hlps

    Regards

    Khushboo

    Add a comment
    10|10000 characters needed characters exceeded

  • author's profile photo Former Member
    Former Member
    Posted on Sep 23, 2008 at 08:21 AM

    Thank you all.

    Your replies were really helpful in resolving the issue.

    The question has been answered now.

    Best Regards,

    Ankit.

    Add a comment
    10|10000 characters needed characters exceeded

Before answering

You should only submit an answer when you are proposing a solution to the poster's problem. If you want the poster to clarify the question or provide more information, please leave a comment instead, requesting additional details. When answering, please include specifics, such as step-by-step instructions, context for the solution, and links to useful resources. Also, please make sure that you answer complies with our Rules of Engagement.
You must be Logged in to submit an answer.

Up to 10 attachments (including images) can be used with a maximum of 1.0 MB each and 10.5 MB total.