Skip to Content
avatar image
Former Member

Dynamic Checkbox

All,

I need to read the DB tables, based on the table row entries I need to create the checkbox dynamically under the Tray called "Manager".

1. How can i create the multiple checkbox dynamically.

2. How can i add it under the tray..

I went thro some thread, but i could not get much detail..Can anyone give me a code please...

Thanks in advance..

<i>I will reward each useful answer...</i>

BM

Add comment
10|10000 characters needed characters exceeded

  • Get RSS Feed

7 Answers

  • Best Answer
    May 20, 2007 at 05:10 AM

    Hi Bharathi

    you can create a check box dynamically bu using the following code in wdModify method because what ever modifications to the Screen in webdynpro must be performed in this method

    IWDCheckBox cb=(IWDCheckBox)view.createElement(IWDCheckBox.class,"checkbox1" ) ;

    cb.setOnToggle(<any action reference>);

    Like this you can create number of check boxes

    //adding to tray

    IWDTransparentContainer cont=(IWDTransparentContainer)view.getElement("<tray id.>");

    cont.addElement(<your check box>);

    regards

    kalyan

    Add comment
    10|10000 characters needed characters exceeded

  • avatar image
    Former Member
    May 21, 2007 at 05:11 AM

    I forgot one thing. Bind the value attribute CB.CheckBox in "texts" property of CheckBoxGroup

    Regards

    Fahad Hamsa

    Add comment
    10|10000 characters needed characters exceeded

  • avatar image
    Former Member
    May 20, 2007 at 11:36 AM

    Hi,

    You don't need to create the check box dynamiclly, you can just bind text and map the actions:

    1. Create a CheckBoxGroup UI element.

    2. Bind the texts field to a node (Which will be filled dynamiclly, it should also contain a value attribute of type boolean which will store the check box status).

    3. Add the following in the wdDoModifyView method of the view:

    if (firstTime) {

    IWDCheckBoxGroup checkBoxGroup = (IWDCheckBoxGroup)view.getElement(<check box group ID>);

    checkBoxGroup.mappingOfOnToggle().addSourceMapping("checked","checked");

    checkBoxGroup.mappingOfOnToggle().addSourceMapping("index","index");

    }

    4. Create an action and bind it to the "OnToggleEvent" of the CheckBoxGroup:

    wdContext.node<yourNode>().setLeadSelection(index);

    wdContext.current<yourNode>Element().set<yourBooleanAttribute>(checked);

    5. You can check the status of the check boxes by going through your node and checking the status of your boolean attribute.

    Hope this helps.

    Yaniv

    Add comment
    10|10000 characters needed characters exceeded

  • avatar image
    Former Member
    May 21, 2007 at 05:08 AM

    Hi Bharathi,

    1.Create a Node ( Say CB) in ur context with value attribute(Say CheckBox) of type String

    2. Make cardinality and Selection properties of Node CB as 0.N

    3.In ur tray, add a CheckBoxGroup UI Element

    4.Create an action(Say onActionChecked) and bind it to this CheckBoxGroup

    5.After calling RFC, u can add the following code

    IPrivateMyCompView.ICBNode cN=wdContext.nodeCB();

    IPrivateMyCompView.ICBElement cE;

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

    {

    cE=cN.createCBElement();

    cN.addElement(cE);

    cE.setCheckBox("Value"+i);

    //svs1.put("Key"i,"Value"i);

    }

    This will add 5 checkboxes with text as Value0....Value4.

    In this for loop , instead of hardcoding the values, u can put the values from RFC by accessing those model nodes

    Hope this will be helpful

    Regards

    Fahad Hamsa

    Add comment
    10|10000 characters needed characters exceeded

  • avatar image
    Former Member
    May 21, 2007 at 09:44 AM

    BM,

    Type casting IWDTray object to IWDTransparentContainer is simply not allowed in WD. So, do this.

    IWDCheckBox cb = (IWDCheckBox) view.createElement(IWDCheckBox.class, null ) ;
    ....
    ....
    
    // Type cast the object to IWDTray
    IWDTray tray= (IWDTray) view.getElement("tray1");
    tray.addChild(cb);
    

    Bala

    Add comment
    10|10000 characters needed characters exceeded

  • avatar image
    Former Member
    May 21, 2007 at 08:57 AM

    Hi Bharthi,

    Can you please elaborate on the following:

    1. Where are you getting the class cast exception.Line 337 does'nt make sense here.

    2. Have you binded it dynamically to some attribute.

    Regards

    Amit

    Add comment
    10|10000 characters needed characters exceeded

  • avatar image
    Former Member
    Sep 25, 2013 at 07:24 AM

    Thanks!!!

    Add comment
    10|10000 characters needed characters exceeded