on 10-04-2007 10:01 AM
How do I bind a static UI element (in my case, its a text view) to a context attribute that has been created dynamically ?
There will be only one instance of the node that contains this attribute !
Hi,
you can bind it on creation to a dummy attribute
and when you are generating your ctx,
do on the wddomodifyview:
lo_textview = view->get_element( ).
lo_textview->bind_text( path = 'new path').
grtz,
Koen
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Hi, I have created a textview for CARRID and CONNID fields on the view.
In the WDDOMODIFY method, I have dynamically created the FLIGHT node. Then i have created the attributes for CARRID and CONNID for the flight node.
The coding is as follows:
METHOD wddomodifyview .
IF first_time EQ abap_true.
DATA: lr_context_node_info TYPE REF TO if_wd_context_node_info,
lr_flight_node_info TYPE REF TO if_wd_context_node_info,
lr_carrid_attr_info TYPE wdr_context_attribute_info,
lr_connid_attr_info TYPE wdr_context_attribute_info.
****************************************************************************
Add attributes to the node of the context, dynamically
****************************************************************************
Get reference to the context node metadata
lr_context_node_info = wd_context->get_node_info( ).
Create a new node FLIGHT under the context node
CALL METHOD lr_context_node_info->add_new_child_node
EXPORTING
name = 'FLIGHT'
is_mandatory = abap_false
is_multiple = abap_true
is_mandatory_selection = abap_false
is_multiple_selection = abap_false
is_singleton = abap_true
is_static = abap_false
RECEIVING
child_node_info = lr_flight_node_info.
Build attribute CARRID and add the attribute under the node FLIGHT
lr_carrid_attr_info-name = 'CARRID'.
lr_carrid_attr_info-type_name = 'S_CARR_ID'.
CALL METHOD lr_flight_node_info->add_attribute
EXPORTING
attribute_info = lr_carrid_attr_info.
Build attribute CONNID and add the attribute under the node FLIGHT
lr_connid_attr_info-name = 'CONNID'.
lr_connid_attr_info-type_name = 'S_CONN_ID'.
CALL METHOD lr_flight_node_info->add_attribute
EXPORTING
attribute_info = lr_connid_attr_info.
****************************************************************************
Bind the attributes to the TextView fields on the view.
****************************************************************************
*
DATA: lr_txtvw_carrid TYPE REF TO cl_wd_text_view,
lr_txtvw_connid TYPE REF TO cl_wd_text_view.
lr_txtvw_carrid ?= view->get_element( 'TXT_CARRID' ).
lr_txtvw_carrid->bind_enabled( 'FLIGHT.CARRID' ).
lr_txtvw_carrid->set_text( value = 'AA' ).
lr_txtvw_carrid->bind_text( path = 'FLIGHT.CARRID').
lr_txtvw_connid ?= view->get_element( 'TXT_CONNID' ).
lr_txtvw_connid->bind_enabled( 'FLIGHT.CONNID' ).
lr_txtvw_connid->set_text( value = '0107' ).
ENDIF.
ENDMETHOD.
Hi,
first of all, you shouldn't change the context in wddomodify view,
do this in wddoinit or wddohandledefault.
if you want to display in textview, also set is_miltiple on the node creation on abap_false
(now you create a 0..N cardinality node)
The rest seems ok,
where exactly do you receive the null reference?
can you check st22 for that?
grtz,
Koen
i have changed the code that modifies the context to the wddoinit method.
again i am facing the same problem.
when i use the method bind_enabled or bind_text. i get the same error message.
on inspection of the problem in st22, i get the analysis as follows:
-
The exception, which is assigned to class 'CX_SY_REF_IS_INITIAL', was not caught in procedure "GET_ATTRIBUTE_INTERNAL" "(METHOD)", nor was it propagated by a RAISING clause.
The reason for the exception is:
You attempted to use a 'NULL' object reference (points to 'nothing') access a component.
An object reference must point to an object (an instance of a class) before it can be used to access components.
Either the reference was never set or it was set to 'NULL' using the CLEAR statement.
I am not understanding what exactly is the problem !!
User | Count |
---|---|
85 | |
10 | |
10 | |
10 | |
7 | |
6 | |
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.