cancel
Showing results for 
Search instead for 
Did you mean: 

Dynamic Creation of Checkboxes!

Former Member
0 Kudos

Hi,

i have an RFC which return the following Table:

Parameters

- checked --> DataType Boolean

- name --> DataType Char255

So, after calling the RFC, this table is filled, e.g.:

checked name

-


false ABAPCache

false JAVACache

true DB_DataSize

false ABAPBufferSize

true DB_LogSize

Now, reagarding to this table, i want to create checkboxes which can be set/unset by user! :

[ ] ABAPCache

[ ] JAVACache

[X] DB_DataSize

[ ] ABAPBufferSize

[X] DB_LogSize

Now, how to do that?

I have to "loop" over my table, within this loop i have to create my Checkbox. The visible Label of the Checkbox should be the "name":

Within this loop i have to create the checkboxes:


public static void wdDoModifyView(....)
  {
   if (firstTime) {

     IWDTransparentContainer tCont = (IWDTransparentContainer) view. 
     getRootElement(); 
    
    tCont.createLayout(IWDGridLayout.class);

        for(int i =wdContext.nodeParameters().size()-1; i>=0;i--)
        {

         IWDCheckBox theCheckBox = (IWDCheckBox) view.createElement  (IWDCheckBox.class, wdContext.nodeParameters().getParametersElementAt(i).getName());

theCheckBox.bindChecked( ??? )


        }


Am I on the right way?

Accepted Solutions (1)

Accepted Solutions (1)

Former Member
0 Kudos

Use a CheckBoxGroup, bind property "texts" to attribute "name. This will create as many checkboxes as there are elements in the context node. It will not set the values of attribute "checked" however because the checking a box will only set the node's multi-selection state. Thus you have to update (for example before you write data into model) the "checked" attribute values using a loop like


for (int i = 0; i < wdContext.nodeParameters().size(); ++i)
{
  IParametersElement parameter = wdContext.nodeParameters().getParametersElementAt(i);
  parameter.setChecked(wdContext.nodeParameters().isMultiSelected(i));
}

Armin

Former Member
0 Kudos

Thx for your help Armin, the creation of checkboxes works, but i do have another problem.

The checkboxes are created in pop up window. By closing (with window.destroyInstance();) and open again, the wdDoModify is called again with firsttime=true!

So, every time closing and opening the window, the initial values are shown and not the changed values from user.

Former Member
0 Kudos

Why do you destroy the window when closing the pop-up? Just use hide() instead.

Armin

Former Member
0 Kudos

Problem solved, i'v made a mistake, now it works fine.

Thanks a lot Armin

Edited by: Christopher Linke on May 9, 2008 8:35 AM

Think i did do a big mistake

Edited by: Christopher Linke on May 9, 2008 8:38 AM

Answers (1)

Answers (1)

i827647
Product and Topic Expert
Product and Topic Expert
0 Kudos

Hi,

Change de code into loop for this:


IWDCheckBox theCheckBox = (IWDCheckBox) view.createElement  (IWDCheckBox.class, wdContext.nodeParameters().getParametersElementAt(i).getName());
IWDAttributeInfo attInfo = wdContext.getNodeInfo().addAttribute(wdContext.nodeParameters().getParametersElementAt(i).getName, "ddic:com.sap.dictionary.boolean");
theCheckBox.bindChecked(attInfo);

Regards,

Edson Thomaz