on 02-25-2010 4:00 AM
Hi Experts,
I have created dynamic checkboxes. I have provided On_Toggle an action called on_togg to these dynamically created checkboxes. Now I want to know how to read whether the checkboxes are checked or not. I have used a method called Get_checked which was giving me correct value of the checkbox which was checked but that code is running fine only in WDDOMODIFYMETHOD. When I use that method in my on_togg action it throwing me error ACcess Via Null Object Reference Not Possible !!
Pls help me int this matter.
Thanks,
Pratibha
answered
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
The question you should be asking yourself is if you really need dynamic programming to meet your checkBox requirement.
True dynamic programming via WDDOMODIFYVIEW should be extremely rare. WD is designed so that you donu2019t need such dynamic programming in most all cases. I think you should study the CheckBoxGroup UI element:
http://help.sap.com/saphelp_nw70ehp1/helpdata/en/cd/ad884118aa1709e10000000a155106/frameset.htm
With this UI element you bind to a context node. The framework will then generate one checkbox for each element in this context node. This allows you a great amount of dynamic manipulation simply by controlling the data in the bound context node. Such context binding approaches are highly recommended over dynamic coding in WDDOMODIFYVIEW.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Hi Pratibha
Your code will only work in method domodifyview method of view, as you are referencining to view and calling method get_element and others as well.
View Reference is only possible in this method.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Hi,
if you have bound the checked property of your dynamically created checkboxes to some attribute then you read the value of that attribute, rather than calling methods of class cl_Wd_checkbox.
a) Create Checkbox in domodifyview.
b) Bind the checked property to some context node ->attrbute. method bind_checked
c) Now you can read the bound attritute property to know the checkbox state.
Regards
Manas Dua
Hi,
I have created a dynamic node named DYNAMIC in that I have added the attributes dynamically. Now How To read that attributes? I have done like this in WDDOMODIFYVIEW :
IF first_time = abap_true.
lr_ui_root = view->get_element( 'TC2' ).
lr_container ?= lr_ui_root.
*clear internal tables
CLEAR: it_dom,
wa_dom.
*fill the requistion type drop down with person's id pre raised requisitions.
SELECT * INTO TABLE it_dom FROM dd07t
WHERE domname = 'ZREQTYPES'.
* str3 = 'ON_DYNTOGG'.
LOOP AT it_dom INTO wa_dom.
str1 = wa_dom-domvalue_l.
str2 = wa_dom-ddtext.
str = str1.
CONCATENATE 'DYNAMIC.' str1 INTO str.
lr_check = cl_wd_checkbox=>new_checkbox(
text = str2
bind_checked = str
id = str1
on_toggle = str3
* on_toggle = 'ON_DYNTOGG(str1)'
view = view ) .
cl_wd_grid_data=>new_grid_data( EXPORTING element = lr_check ).
lr_container->add_child( the_child = lr_check ).
ENDLOOP.
ENDIF.
hi
Your code will only work in method domodifyview method of view, as you are referencining to view and calling method get_element and others as well.
View Reference is only possible in this method.
view refernce is possible in WD DOMODIFY as well as the OnAction method of some UI ..
for getting the view refernce u can do it like this , as I had already told u earlier
create a attribute in ATTRIBUTE's tab , say mr_view of type IF_WD_VIEW ..
u can get the view refernce as
view= wd_this->mr_view .
regards,
amit
Hi,
I have written like this still i am getting error Access Via null Ojbject Not Possible
DATA : view3 TYPE REF TO if_wd_view.
view3 = wd_this->mr_view.
lr_container ?= view3->get_element( 'TC2' ).
I have declared mr_view in attribute tab.
I am geting error at this line :
lr_container ?= view3->get_element( 'TC2' ).
Thanks,
Pratibha
hi ,
use the method get_checked in the action on_togg . It shud work fine ..
thn u can create a attribute of type WDY_BOOLEAN in the attribute's tab and accordingly set or reset the same to create a flag for ur checkbox ..
regards,
amit
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
I have written get_checked in On_togg only ...Like This :
DATA : lr_ui_root TYPE REF TO if_wd_view_element,
lr_container TYPE REF TO cl_wd_uielement_container,
lr_container_t TYPE REF TO cl_wd_uielement_container,
lr_check TYPE REF TO cl_wd_checkbox,
lr_check1 TYPE REF TO cl_wd_checkbox,
it_dom TYPE STANDARD TABLE OF dd07t,
lr_delegate_button TYPE REF TO cl_wd_button,
lr_view_delegate TYPE REF TO cl_wd_button,
wa_dom LIKE LINE OF it_dom.
DATA : lo_nd_dynamic TYPE REF TO if_wd_context_node_info,
lo_el_dynamic TYPE REF TO if_wd_context_element,
lo_nd_dynamic2 TYPE REF TO if_wd_context_node_info,
ls_attribute TYPE wdr_context_attribute_info.
lo_nd_dynamic = wd_context->get_node_info( ).
lo_nd_dynamic2 = lo_nd_dynamic->get_child_node( 'DYNAMIC' ).
DATA : str TYPE string,
str1 TYPE string,
str3 TYPE string,
str2 TYPE string.
DATA: lo_componentcontroller TYPE REF TO ig_componentcontroller.
lo_componentcontroller = wd_this->get_componentcontroller_ctr( ).
DATA : id1 TYPE abap_bool,
get_reqtypes TYPE string,
flag1 TYPE c.
get_reqtypes = ''.
DATA : view3 TYPE REF TO if_wd_view.
view3 = lo_componentcontroller->view1.
lr_container ?= view->get_element( 'TC2' ).
SELECT * INTO TABLE it_dom FROM dd07t
WHERE domname = 'ZREQTYPES'.
lo_componentcontroller = wd_this->get_componentcontroller_ctr( ).
LOOP AT it_dom INTO wa_dom.
str1 = wa_dom-domvalue_l.
str2 = wa_dom-ddtext.
str = str1.
CONCATENATE 'DYNAMIC.' str1 INTO str.
lr_check ?= view->get_element( id = str1 ).
CALL METHOD lo_nd_dynamic2->get_attribute
EXPORTING
attribute_info = ls_attribute.
DATA : bool TYPE abap_bool.
CALL METHOD lr_check->get_checked
EXPORTING
* context_element = 'DYNAMIC.str'
context_node_path_name = 'DYNAMIC.str'
RECEIVING
value = bool.
IF bool = ' '.
CONCATENATE bool get_reqtypes INTO get_reqtypes.
ELSE.
CONCATENATE str get_reqtypes INTO get_reqtypes SEPARATED BY ','.
ENDIF.
lo_componentcontroller->reqtypes = get_reqtypes.
* ENDLOOP.
User | Count |
---|---|
86 | |
10 | |
10 | |
9 | |
6 | |
6 | |
6 | |
5 | |
4 | |
3 |
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.