on 03-26-2008 2:18 PM
I have created a button in my coding, and successfully added it to the view.
DATA lo_button TYPE REF TO cl_wd_button.
DATA lo_flow_layout_data TYPE REF TO cl_wd_flow_data.
lo_button = cl_wd_button=>new_button( view = mo_view ).
lo_button->set_text( me->mv_refresh_button_text ).
lo_button->set_on_action( value = 'do_a_dummy_refresh' ).
* set layout (matrix, flow, etc.)
* ....
lo_container->add_child( lo_button ).
When the user clicks the button, I would just like to refresh the view (i.e. go to WDDOMODIFYVIEW etc.).
Currently, if the button is clicked, I get the dump "Access via 'NULL' object reference not possible" because for the action there is not action handler.
Is there a way to avoid the dump, or to dynamically create an action handler?
Regardsd,D.
hi daniel...
just create an empty metho say... sample.
and in the action handler give this method name.
---regards,
alex b justin
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Hi Daniel,
Try the below code.
data: LR_CONTAINER type ref to CL_WD_UIELEMENT_CONTAINER,
LR_BUTTON type ref to CL_WD_BUTTON.
LR_BUTTON = CL_WD_BUTTON=>NEW_BUTTON( id = 'BUTT_1' text = 'NEW' on_action = 'CLICK' ).
LR_CONTAINER ?= view->GET_ELEMENT( 'ROOTUIELEMENTCONTAINER' ).
LR_CONTAINER->ADD_CHILD( LR_BUTTON ).
Here Click is the your action name. So using the following code you can map the button and the corresponding event.
DATA:
lt_parameters LIKE if_wd_event=>parameters,
parameter LIKE LINE OF lt_parameters,
lr_link1 TYPE REF TO cl_wd_button.
lr_link1 ?= view->get_element( 'BUTT_1' ).
parameter-name = 'CLICK'.
parameter-value = 1.
parameter-type = 'g'.
INSERT parameter INTO TABLE lt_parameters.
lr_link1->map_on_action( lt_parameters ).
Now create one attribute 'clicked_at' and set the value as 'click' ( event name for your button ).
wd_context->set_attribute( name = 'CLICKED_AT' value = CLICK ).
So when ever the button is clicked, then the value of your attribute should be 1(parameter-value = 1).
So based on that attribute value you can write your code for refresh the view.
Actually this code for a method with in a view. But you can make it as other views also.
Thanks.
Hi Viji,
I tried your coding, but it still gives me a dump called "Access via 'NULL' object reference not possible" (in CL_WDR_WINDOW_PHASE_MODEL=>GET_ACTION_FROM_EVENT ) when clicking the button.
lo_button->set_text( me->mv_refresh_button_text ).
lo_button->set_on_action( value = 'DO_DUMMY_REFRESH' ).
DATA lt_parameters LIKE if_wd_event=>parameters.
DATA ls_parameter LIKE LINE OF lt_parameters.
ls_parameter-name = 'DO_DUMMY_REFRESH'.
ls_parameter-value = 1.
ls_parameter-type = 'g'.
INSERT ls_parameter INTO TABLE lt_parameters.
lo_button->map_on_action( lt_parameters ).
* set layout (matrix, flow, etc.)
/psc/cl_zxa_wd_tools=>set_layout_data_for_ui_element(
io_ui_element = lo_button
iv_layout_data_type = me->mv_layout_data_type ).
Any idea?
Hi Daniel,
Using debugging you can try to find exactly where the dump is raised.
Instaed of using following code,
lo_button->set_text( me->mv_refresh_button_text ).
lo_button->set_on_action( value = 'DO_DUMMY_REFRESH' ).
Give the text and action in New button itself.
Please refer my code.
LR_BUTTON = CL_WD_BUTTON=>NEW_BUTTON( id = 'BUTT_1' text = 'NEW' on_action = 'CLICK' ).
Thanks.
By the way, after creating the event handler method manually, it also works without the event parameters, so i did not need the following coding.
What exactly is it used for?
DATA lt_parameters LIKE if_wd_event=>parameters.
DATA ls_parameter LIKE LINE OF lt_parameters.
ls_parameter-name = 'DO_DUMMY_REFRESH'.
ls_parameter-value = 1.
ls_parameter-type = 'g'.
INSERT ls_parameter INTO TABLE lt_parameters.
lo_button->map_on_action( lt_parameters ).
User | Count |
---|---|
94 | |
11 | |
11 | |
10 | |
9 | |
8 | |
6 | |
5 | |
4 | |
4 |
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.