on 08-12-2007 12:37 PM
Hi,
how is it possible to add a dynamically created UI Element (Group) to ROOTUIELEMENTCONTAINER? I try it with the following piece of code but i get always the error message: <b> Access via 'NULL' object reference not possible. </b>
IF FIRST_TIME EQ ABAP_TRUE.
DATA: lr_root TYPE REF TO cl_wd_uielement_container,
lr_groupbox TYPE REF TO cl_wd_group.
lr_root ?= view->get_element( 'ROOTUIELEMENTCONTAINER' ).
lr_groupbox ?= cl_wd_group=>new_group( id = 'GROUP' ).
cl_wd_flow_data=>new_flow_data( lr_groupbox ).
lr_root->add_child( lr_groupbox ).
ENDIF.
What is my mistake?
regards,
Sharam
Message was edited by:
Sharam Pourmir
Hi Sharam,
Firstly, I am not getting a null pointer exception. I got an ASSERT condition violated error, which I solved by defining a layout for the group. The layout has to be defined first and then the layout data. This is my code and it works. Try if it does for you too.
IF FIRST_TIME EQ ABAP_TRUE.
DATA: lr_root TYPE REF TO cl_wd_uielement_container,
lr_flow_layout type ref to cl_wd_flow_layout,
lr_groupbox TYPE REF TO cl_wd_group.
lr_root ?= view->get_element( 'ROOTUIELEMENTCONTAINER' ).
lr_groupbox ?= cl_wd_group=>new_group( id = 'GROUP' ).
CALL METHOD CL_WD_FLOW_LAYOUT=>NEW_FLOW_LAYOUT
EXPORTING
CONTAINER = lr_groupbox
RECEIVING
CONTROL = lr_flow_layout
.
lr_groupbox->set_layout( lr_flow_layout ).
cl_wd_flow_data=>new_flow_data( lr_groupbox ).
lr_root->add_child( lr_groupbox ).
ENDIF.
Regards,
Nithya
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Hi Sharam,
Just a question here. Is this the exact code that you are using or is there something different that you have coded? In my case, the problem was that I was using matrix layout and I had to use the following
lr_matrix_layout = cl_wd_matrix_layout=>new_matrix_layout( lr_groupbox ).
lr_matrix_head_data = cl_wd_matrix_head_data=>new_matrix_head_data( lr_groupbox ).
Previously I was just using new_matrix_head_data and it was not working because of that.
Regards,
Neha
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Hi,
Instead of the method get_element, try using get_root_element. Your rootuielement container is a transparent container. So the following code might help:
data: lr_container type ref to cl_wd_transparent_container.
lr_container ?= view->get_root_element( ).
Then create a group and do an add_child. It should work.
Regards
Nithya
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Hello!
I tried creating a Group myself. But I was getting the same error. I am not sure why this is happening. I will check again and get back. Do let me know if you find the answer.
Regards,
Neha
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
User | Count |
---|---|
88 | |
23 | |
11 | |
9 | |
8 | |
5 | |
5 | |
5 | |
5 | |
4 |
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.