Bind checked value of dynamically created checkboxes to node attruibutes

This is the scenario:
I need to Create n checkboxes(dynamically) based on the n elements present in a node. The values in the node are populated at runtime. i need to bind a boolean attribute in this node to the check boxes that are created.
Any help would be highly appreciated.
Regards,
Immanuel

Hi,
Try the following:
1. Create a node with 0..n cardinality with the following structure
NodeElement
Column1
Column2
Column3
CheckBoxattribute(boolean)
2. In the view, right-click on the root container>Apply Template>Table
3. Select the NodeElement and set the CheckBoxAttribute UI as Checkbox
In this way u can create a Table with checkbox that are loaded as many elements in the Node at run-time
The checkbox value can be set / get using:
wdContext().nodeNodeElement().getNodeElementAt(<selectedRow>).get/setCheckBoxattribute(true/false);
Hope this helps you.
Regards,
Poojith MV

Similar Messages

  • Cannot check dynamically created Checkbox

    Hi,
    I cannot check a dynamically created Checkbox which is binded to a dynamically created node.
    The same dynamically created Checkbox can be checked when it is binded to a static node.
    Any ideas?

    Hello MK,
    Checkbox UI element`s property "checked" can be binded only to attribute with type "boolean".
    If you create attribute inside the node, check whether node contains any node elements.
    Could you please post a piece of your code with dynamic attribute and UI element creation?
    Best regards, Maksim Rashchynski.

  • Appending values to dynamically created fieldsymbol

    Hi ,
    I have a requirement to append values to dynamically created fieldsymbols
    from internal table   .
    I am using the following code but it dosnt work
    <F4> declared as line of <dyn_table>.
    loop at it_tab into wa_tab .( this contain the data to be appended to dyn fieldsymbol)
    loop at it_fieldcat into wa_fieldcat. ( this contains the fieldnames )
    case wa_final_fieldcat-FIELDNAME.
    when 'AAA'.
    v_field_name = 'AAA.
    when 'BBB'.
    v_field_name = 'BBB'.
    endcase.
    ASSIGN COMPONENT v_field_name of STRUCTURE wa_tab to <F4>.
    endloop.
    append <f4> to <dyn_table>
    ********************************************8
    But only get one value i.e field BBB  value appended to
    <dyn_table>.
    is there any way i can do the append to field symbol looping through internal
    table ?
    thanks
    raj

    i done it in alv so take the part you need .
    1) to create dynamic table  :  CALL METHOD CL_ALV_TABLE_CREATE=>CREATE_DYNAMIC_TABLE
    also create dynamic fieldcatalog .
    2) you can pull data just one time from the DB to dynamic table
    so i take the data in regulare it table and in the and i put it
    in the dynamic table
    hope i help  , if you didnt understand some part  , say so  .
      DATA  : LT_FCAT   TYPE LVC_T_FCAT  ,
             lo_struct TYPE REF TO data,
               LV_STRUC_NAME TYPE TABNAME VALUE 'YMM_ST_TNUOT_MLY'.
    REFRESH ls_fcat.
      CALL FUNCTION 'LVC_FIELDCATALOG_MERGE'
        EXPORTING
          I_STRUCTURE_NAME       = LV_STRUC_NAME
          I_BYPASSING_BUFFER     = 'X'
        CHANGING
          CT_FIELDCAT            = IT_COLUM_HEADER
        EXCEPTIONS
          INCONSISTENT_INTERFACE = 1
          PROGRAM_ERROR          = 2
          OTHERS                 = 3.
      IF SY-SUBRC <> 0.
       MESSAGE e402(mo) WITH lv_struc_name.
        EXIT.
      ENDIF.
      DATA INDX(3) .
      IF G_COUNETR_NUMBER_OF_KOSTL > 0 .
        DO G_COUNETR_NUMBER_OF_KOSTL TIMES.
          INDX = SY-INDEX.
          SHIFT INDX LEFT DELETING LEADING SPACE.
          CONCATENATE 'KOSTL' INDX INTO LS_FCAT-FIELDNAME.
          LS_FCAT-INTTYPE    = 'I'.
          LS_FCAT-COL_POS =  27 +  SY-INDEX .
          CONCATENATE TEXT-028    INDX INTO LS_FCAT-COLTEXT.
          LS_FCAT-OUTPUTLEN = 10.
          APPEND LS_FCAT TO IT_COLUM_HEADER.
        ENDDO.
      ENDIF.
      CALL METHOD CL_ALV_TABLE_CREATE=>CREATE_DYNAMIC_TABLE
        EXPORTING
          IT_FIELDCATALOG           = IT_COLUM_HEADER
        IMPORTING
          EP_TABLE                  = GT_TABLE
        EXCEPTIONS
          GENERATE_SUBPOOL_DIR_FULL = 1
          OTHERS                    = 2.
      ASSIGN GT_TABLE->* TO <DYN_TABLE>.
    *--> Arbeitsbereich dynamisch erzeugen
      CREATE DATA LO_STRUCT LIKE LINE OF <DYN_TABLE>.
      ASSIGN LO_STRUCT->* TO <WA>.
      LOOP AT IT_COLUM_HEADER INTO LS_FCAT.
        IF LS_FCAT-FIELDNAME NE 'MANDT'.
          ADD 1 TO LS_FCAT-COL_POS.
          PERFORM TRANSLATE_HEADER.
          MODIFY IT_COLUM_HEADER FROM LS_FCAT.
        ENDIF.
      ENDLOOP.
    =============   assigning to dynamic table
    DATA  : FIELD(10)   ,
               INDX1(3) .
      DATA: WA_DREF TYPE REF TO DATA.
      DATA :  FS_SUM_GL LIKE LINE OF IT_YMM_ST_TNUOT_MLY.
      CREATE DATA LP_DATA LIKE LINE OF <DYN_TABLE>.
      ASSIGN LP_DATA->* TO <LS_LINE>.
      LOOP AT IT_YMM_ST_TNUOT_MLY.
        MOVE-CORRESPONDING IT_YMM_ST_TNUOT_MLY TO <LS_LINE>.
        INSERT <LS_LINE> INTO TABLE <DYN_TABLE>.
      ENDLOOP  .
      DATA L_COUNTER_ROLL TYPE I .
      LOOP AT <DYN_TABLE> INTO <LS_LINE> .
        MOVE-CORRESPONDING <LS_LINE> TO FS_SUM_GL.
        CLEAR : FIELD , INDX1 , L_COUNTER_ROLL .
        L_COUNTER_ROLL = 1 .
        LOOP AT IT_EKKN  WHERE EBELN = FS_SUM_GL-EBELN.
                        AND   EBELP = FS_SUM_GL-EBELP.
         IF SY-SUBRC  = 0  .
          INDX1 = L_COUNTER_ROLL.
          SHIFT INDX1 LEFT DELETING LEADING SPACE.
          CONCATENATE 'KOSTL'  INDX1 INTO FIELD .
          ASSIGN COMPONENT FIELD  OF STRUCTURE <LS_LINE> TO <FS1>.
          <FS1> = IT_EKKN-KOSTL .
          MODIFY <DYN_TABLE> INDEX SY-TABIX FROM  <LS_LINE> .
          L_COUNTER_ROLL = L_COUNTER_ROLL + 1 .
         ENDIF.
        ENDLOOP .
      ENDLOOP .

  • How to handle dynamically created checkboxes in JSP???

    Hello everybody,
    In a JSP page I would like to create checkbox dynamically on every
    result line (detail line), then check in some of them and finally pass the checked lines to a JSP bean which will handle them on a submit button press.
    The problem are:
    - how to index every checkbox in jsp result line in jsp page in order to avoid solutions like this:
    <input type=checkbox" name="value1">
    <input type=checkbox" name="value2">
    etc
    - how to read every checkbox to find the checked ones
    Is there anobody who has any experience from case like this?
    Please, help me.
    Best regards,
    Danny

    Hi, first off, no need to determine what has been checked or not. If the checkbox is checked, on the post, the value will be submitted as part of the request. If the checkbox is not checked, it will not be submitted (it's value will be null). Depending on what you need, I have approached this a number of different ways. One way is to name all checkboxes the same name. If you need to distinguish between two rows in the form, then in the value field for the checkbox, use some type of distinguishing factor, for example,
    <input type=checkbox name=chkName value="1:abc">
    <input type=checkbox name=chkName value="1:def">
    Now, you only have to make one call on the Servlet/JSP receiving the form post, request.getParameterValues("chkName") which will return an array of the non-null Strings that were checked.

  • Operations on dynamically created checkboxes

    Hi Experts,
                          In my application I have created 10 check boxes dynamically. All check boxes are for selecting different request types which the user can select. Out of these 10 one check box is for "ALL requests". Now I want that if All Check box is clicked all other checkboxes must be checked. I want to use on toggle action of checkboxes on dynamicaaly created checkboxes Is it possible? Or I have to create checkboxes statically and  only then  I can use ontoggle action of checkboxes..
      Please help me in this regard.
      Thanks,
      Pratibha

    Hi Amit,
               I have written following code in wddomodifyview. I have declared mr_view as attribute in my view and in component controller of the type IF_WD_VIEW.
    METHOD wddomodifyview .
      DATA: lr_container TYPE REF TO cl_wd_uielement_container,
            lr_checkbox TYPE REF TO cl_wd_checkbox,
            lr_node TYPE REF TO if_wd_context_node.
      CHECK first_time = abap_true.
    *  lr_container ?= view->get_root_element( ).
      lr_container ?= wd_this->mr_view->get_element( 'TC' ).
      cl_wd_matrix_layout=>new_matrix_layout( container = lr_container ).
      DATA lo_nd_node TYPE REF TO if_wd_context_node.
      DATA lo_el_node TYPE REF TO if_wd_context_element.
      DATA ls_node TYPE wd_this->element_node.
      DATA lv_str3 LIKE ls_node-str3.
      DATA lv_str1 LIKE ls_node-str1.
      DATA lv_str2 LIKE ls_node-str2.
    * navigate from <CONTEXT> to <NODE> via lead selection
      lo_nd_node = wd_context->get_child_node( name = wd_this->wdctx_node ).
    * get element via lead selection
      lo_el_node = lo_nd_node->get_element(  ).
    * get single attribute
      lo_el_node->set_attribute(
        EXPORTING
          name =  `STR3`
          value = 'ON_TOGGLE' ).
      lo_el_node->set_attribute(
    EXPORTING
    name =  `STR1`
    value = 'ALL_REQ' ).
      lo_el_node->set_attribute(
    EXPORTING
       name =  `STR2`
       value = 'DYNAMIC.ALL_REQ' ).
    * navigate from <CONTEXT> to <NODE> via lead selection
      lo_nd_node = wd_context->get_child_node( name = wd_this->wdctx_node ).
    * get element via lead selection
      lo_el_node = lo_nd_node->get_element(  ).
    * get all declared attributes
      lo_el_node->get_static_attributes(
        IMPORTING
          static_attributes = ls_node ).
      ls_node-str1 = lv_str1.
      ls_node-str2 = lv_str2.
      ls_node-str3 = lv_str3.
      lo_el_node->set_static_attributes(
        EXPORTING
          static_attributes = ls_node ).
      lr_checkbox = cl_wd_checkbox=>new_checkbox( bind_checked = ls_node-str2
                                                  bind_text    = ls_node-str1
                                                  on_toggle =    ls_node-str3
                                                  view = wd_this->mr_view   ).
      cl_wd_matrix_head_data=>new_matrix_head_data( element = lr_checkbox ).
      lr_container->add_child( the_child = lr_checkbox ).
    ENDMETHOD.
      I am getting this error : Access via 'NULL' object reference not possible 
    pls help.
    Thanks,
    Pratibha

  • Passing values to dynamically created internal table

    Hi,
    I have the flat file data as
    f1,f2,f3........so on
    where f1 f2 and f3 are field names.
    I have a variable var which contains the data
    V1,0001,0002.........so on
    data: var type string.
    The value of field f1 is v1
    The value of field f2 is 0001
    The value of field f3 is 0002.......so on
    FIELD-SYMBOLS:     <fs_1> TYPE STANDARD TABLE
    I have dynamically created an internal table for fields f1  f2 f3 ...... using 
      CALL METHOD cl_alv_table_create=>create_dynamic_table
        EXPORTING
          it_fieldcatalog           = lt_fieldcatalog
        IMPORTING
          ep_table                  = <fs_data>
        EXCEPTIONS
          generate_subpool_dir_full = 1
          OTHERS                    = 2.
      IF sy-subrc <> 0.
      ENDIF.
    ASSIGN <fs_data>->* TO <fs_1>.
    Now for <fs_1> I have to pass the corresponding values of the fields f1 f2 f3 .
    How can i solve this.
    Thanks and regards ,
    Parvatha Reddy

    Hi,
    There is no data in <fs_1>.
    I need to pass the data form the string var to the fields of <fs_1>..
    I understand that you want to populate the internal table <fs_1>.
    for that you fist need work area.. use below statement to create work area..
    DATA: new_line TYPE REF TO data.
    CREATE DATA new_line LIKE LINE OF <fs_1>.
    ASSIGN new_line->*  TO <fs_2>.
    <fs_2> is not your work aread...
    to assign value to each field of you work aread <fs_2>. use statement
    ASSIGN COMPONENT 1 OF STRUCTURE <fs_2> TO <fs_3>.
    <fs_3> = f1 .
    now <fs_3> will point to the first field of work area <fs_2>, f1 is value from your string .. repeat above for each field in workarea, by increasing the component number. Once your work area is filled
    append it to table.
    append <fs_2> to <fs_1>
    apologies if I am not getting the requiremnt correctly..

  • Error While Calling action on dynamically created checkboxes

    Hi,
         I am calling on_toggle action on dynamicallly created checkboxes . It is giving me error : " Access Via Null Object Not Possible "
    please help.
    Thanks,
      Pratibha

    Hi,
    Check ur application in debuggermode or go to the transaction ST22 and check the error analysis.
    The error may be because u have not assign any action for on toggle. It may be because of any node is initialized and using it....

  • How to set/get value in dynamically created components?

    I need to create dynamically form based on definition written in database.
    I created an empty panelGreed in my jsf page
    <h:panelGrid columns="2" id="parseg"
    binding="#{ParsegBean.uiKatparam}">
    </h:panelGrid>I can�t use dataTable, because my form contains various component types (SelectOneMenu, OutputText, and InputText).
    In my bean I create components dynamically:
    Private UIPanel uiKatparam = null;
    Iterator componentIt = myComponentList.iterator()
    while(componentIt.hasNext()){
         MyComponent myComponent = (MyComponent)  componentIt.next();
         HtmlOutputText prompt = new HtmlOutputText();
         prompt.setValue(myComponent.getPrompt());
         prompt.setId(myComponent.getPromptId());
         uiKatparam.getChildren().add(prompt);     
         switch (myComponent.type) {
         case 1: //InputText
              HtmlInputText iText = new HtmlInputText();
              iText.setId(myComponent.getId());
              iText.setValue(myComponent.getDefaultValue());
              uiKatparam.getChildren().add(iText);
              break;
         case 2: //SelectOneMenu
              HtmlSelectOneMenu selectOneMenu = new HtmlSelectOneMenu();
    // �
              uiKatparam.getChildren().add(select);
              break;
         default:
              break;
    }When I try to get values in my Action:
    Iterator it = myBean.getUiKatparam().getChildren().iterator();
    while (it.hasNext()) {
    Object ob = it.next();
    if (ob.getClass().getName().matches(".*HtlmInputText")) {
    HtmlInputText t = (HtmlIputText) ob;
         String id = t.getId();
         String value = (String) t.getValue();
    //�
    //�
    }and value is still equal initial value
    How can I get velue entered to my InputText created dynamically?
    Michal

    I solved my problem creating UIData with dynamically added and dynamically rendered components (in each row is rendered another component).

  • How to set a value to a dynamically created node/attribute?

    Hi,
    I dynamically created attributes using the following method,
    IWDNodeInfo cbOptions = wdContext.getNodeInfo().addChild("cbOpt"+count, null, true, true, false, false, false, true, null, null, null);
    cbOptions.addAttribute("opt"+critEle.getQuest_Critid(), "ddic:com.sap.dictionary.string");
    How do i assign a  value to it now, since the node/attribute cannot be accessed via wdcontext?
    On a side note, it seems really troublesome if i need to use a checkbox grp(s) dynamically. I actually need to dynamically create a seperate node + attribute for each checkbox grp i have. Is there any better way to do this?
    Thanx in advance

    Hi
    Steps:
    1) Create the  action click is done statically (you cannot create action dyanmically)
    2) binding the  action click to checkbox dynamically 
    code
    public static void wdDoModifyView(IPrivateDynamicProgrammingView wdThis, IPrivateDynamicProgrammingView.IContextNode wdContext, com.sap.tc.webdynpro.progmodel.api.IWDView view, boolean firstTime)
        //@@begin wdDoModifyView
         if(firstTime){
                      IWDTransparentContainer con=(IWDTransparentContainer)view.getElement("RootUIElementContainer");
              IWDCheckBox checkBox=(IWDCheckBox)view.createElement(IWDCheckBox.class,"ck");
              IWDAction act=wdThis.wdCreateAction(IPrivateDynamicProgrammingView.WDActionEventHandler.CLICK,"");
              checkBox.setOnToggle(act);
              con.addChild(checkBox);
        //@@end
    Thanks and Regards,
    Arun

  • Create checkboxes dynamically

    Hi all,
    how can i create checkboxes in my view dynamically?
    Please specify all classes i need...
    regards

    Hi,
    You would basically need to perform the following steps:
    1) First get the reference of the ROOTUIELEMENTCONTAINER using get_root_element.
    2) Set the desired layout to the container using the obtained reference.
    3) Create an instance of the checkbox using the new_checkbox method of class cl_wd_checkbox.
    4) Specify the correct layout information to this newly created checkbox.
    5) Add the checkbox to the container ui element.
    You would have to mandatorily bind 2 properties of the created checkbox:
    bind_checked & bind_text.
    The state of the checkbox would get saved into the attribute specified by bind_checked
    The text to be displayed beside the checkbox would come from the attribute specified by bind_text
    Try insert the following coding into your WDDOMODIFYVIEW:
    METHOD wddomodifyview.
      DATA: lr_container TYPE REF TO cl_wd_uielement_container,
            lr_checkbox TYPE REF TO cl_wd_checkbox,
            lr_node TYPE REF TO if_wd_context_node.
      CHECK first_time = abap_true.
      lr_container ?= view->get_root_element( ).
      cl_wd_matrix_layout=>new_matrix_layout( container = lr_container ).
      lr_checkbox = cl_wd_checkbox=>new_checkbox( bind_checked = 'NODE1.ATTR1'
                                                  bind_text    = 'NODE1.ATTR2' ).
      cl_wd_matrix_head_data=>new_matrix_head_data( element = lr_checkbox ).
      lr_container->add_child( the_child = lr_checkbox ).
    ENDMETHOD.
    Regards,
    Uday

  • How to access a dynamic created attribute in a context node?

    <i>Hello,</i>
    <i>who could help? I can't set a value for a dynamically created attribute which is bind to a table.</i>
    <i>My context of the view looks as follow (is defined in NetWeaver):</i>
      - Context
         - Availability (Node)
             - vctxService (Attribute)
             - vctxServiceDesc (Attribute)
             - ... (further predefined attributes)
             - ... (some have to be set dynamically as follows)
    <i>Then I have added attributes dynamically in the wdDoModifyView(...) - method, as follows:</i>
    for (int i = 0; i < max; i++) {
       // some code to dynamically create table columns
       // adding attributes dynamically
       IWDAttributeInfo attrInfo =       wdContext.nodeAvailability().getNodeInfo().      addAttribute("vctxAvailability_" + i, "ddic:com.sap.dictionary.string");
       tv.bindText(attrInfo); // bind to TextView in table
    <i>In the method onPlugFrom... I tried to set the values for the attributes "vctxAvailability_ + i" as follows:</i>
    for (int i = 0; i < max; i++) {
       IAvailabilityElement newAvailNodeElement =     wdContext.createAvailabilityElement();
       // some values will be set for the
       // predefined attributes of AvailabilityNode
       // newAvailNodeElement.set...( value );
       // newAvailNodeElement.setVctxService( xy.getServ() );
       // now the values of dynamically created and added
       // attributes in AvailabilityNode will be added
       // THIS DOESN'T WORK
       newAvailNodeElement.setAttributeValue    ("vctxAvailability_" + i, "value" + i);
    <i>It would be great if someone could help me.
    Thanks in advance.
    Kind regards,
    Carsten</i>

    Carsten,
    Here is a sample code that creates context attributes dynamically and also sets values:
    //Creates a node
    IWDNodeInfo nodeInfo = wdContext.wdGetAPI().getRootNodeInfo().addChild("TestNode", null, true, true, false, true, false, true, null, null, null);
    //If you want to bind the node to a model node then the
    //second argument to the above method should be the
    //model class.
    //Creates an attribute under the node just created.
    IWDAttributeInfo testAttrib = wdContext.wdGetAPI().getRootNodeInfo().getChild("TestNode").addAttribute("testAttrib", "ddic:com.sap.dictionary.string");
    IWDNodeElement testNode = wdContext.getChildNode("TestNode", IWDNode.LEAD_SELECTION).getCurrentElement();
    IWDNode testNode2 = wdContext.getChildNode("TestNode", IWDNode.LEAD_SELECTION);
    //Now you can bind testNode with the Model Node
    //You can also set a value to the newly created attribute
    testNode.setAttributeValue("testAttrib", new String("Value"));
    Hope this helps.
    Shakeel

  • Dynamically set checkbox with actionscript

    I'm trying to set checkboxes to selected/unselected based on
    variables pulled from a database.
    Problem is when the script is run is stops at this code
    (where cb is the id of a checkbox):
    cb.selected = true;
    The code compiles fine with no errors or warnings.
    Why isn't it possible to set the selected value of checkboxes
    through actionscript? Anyone have any ideas or workarounds?
    Thanks in advance

    Found a solution - here for anyone else who needs it:
    http://www.brucephillips.name/blog/index.cfm/2006/11/16/Dynamically-Create-CheckBoxes-Thei r-Labels-And-Their-Select-Values-In-Flex

  • Get bind variables of a dynamic view object

    I seem unable to retrieve the bind variables for a dynamically created view object, even though I can do the same thing for a regular view object.
    Here is the code:
    newVO = repServ.createViewObjectFromQueryStmt("newQry",strSql);
    VariableValueManager vvm = newVO.ensureVariableManager();
    if (vvm != null)
    Variable vars[] = vvm.getVariables();
    vars will be empty, even though the sql statement in strSql has bind variables in it.
    Is there any way to determine the bind variables of a dynamic view object?
    Thanks!

    I got the same problem as yours and still could not find any way out.
    However, as I can see, you wanted to get VariableValueManager of newly created ViewObject that may be not available at this moment.
    If you find way to solve the problem, please help.
    Cheer,
    MinhTran

  • How to Create Check Box in Dynamic Table

    Hi Friends,
    I've Created one Dynamic Table there i want to display 2 columns as Check Box.
    How to Add this check box as column cell variant.
    Looping the columns. In this One method SET_TABLE_CELL_EDITOR is ter. But i'm getting how to use this method. Kindly help in this Issue.
    Regards,
    jack.

    Hi upendra
    There are slight changes in the sivas code.Where is the data coming into the table.If its from a Model Node then iterate each element of the source node get that value compare and set the corresponding value in the element of the node binded to table.
    Create a boolean attribute "select" in the table node and bind it to checked property of the check box.
    for(int i=0;i<wdContext.node<tablenode>()..size();i++)
    if(wdContext.node<tablenode>().get<tablenode>ElementAt(i).select())
    wdContext.node<tablenode>().get<tablenode>ElementAt(i).set<yourattribute>(true);
    else
    wdContext.node<tablenode>().get<tablenode>ElementAt(i).set<yourattribute>(false);
    See the attribute is boolean so pass true or false as a values in setter methods.
    Regards
    Kalyan

  • Dynamic Table checkbox binding problem

    I have a dynamically created table bound to a objectArrayDataProvider where all the columns have a check box. The thing is when I read the values in the objectArray it has the values as I loaded it. If a checkbox is changed in the table the objectArray dosn't get the change. How can I make this happen?
    Thanks in advace.
    Azeroth.

    Hi There,
    This should be of help to you
    http://developers.sun.com/jscreator/reference/techart/2/checkbox_component.html
    Thanks
    K

Maybe you are looking for