cancel
Showing results for 
Search instead for 
Did you mean: 

How to access to the attribut that created in COMPONENTCONTROLLER

Former Member
0 Kudos

Hi experts,

I created a attibute under the tab of 'Context' in COMPONENTCONTROLLER, then in the view I want to use the value of this attribute, how could I access to it?

or should I created attibute under the tab of 'Attribute' in the COMPONENTCONTROLLER? if I did this way ,How could I access to it ?

Many thanks for your help!

Anna

Accepted Solutions (1)

Accepted Solutions (1)

Former Member
0 Kudos

For attribute created in the context tab in compcontroller, create a node first and then create an attribute under it, Then map the node to your view context.

For general attribute created under attributes tab in comp controller, no need to mark it as interface ( option not available also ) just mark the attr as public and access it in your view as

wd_comp_controller-><attr_name>.

Former Member
0 Kudos

Hi Manas,

Thanks for your help, it's very useful~~

Answers (2)

Answers (2)

0 Kudos

Hi Anna

If you have created the attribute in the component controller you can mark it as interface (check box) so that you can access from the underlying objects like(view/windows) directly with wd_comp_controller ref. as follows.

wd_comp_controller->attribute_marked_as_interface .

Regards

Kartik

Former Member
0 Kudos

Hi Kartik,

Thanks for your help, Could you please tell me where I could mark the attibute as interface? 'cause I didn't find the check box 'Interface' under the tab of 'attibute' under COMPONENTCONTROLLER, only check box of 'Public' and 'RefTo'.

saket_abhyankar
Active Participant
0 Kudos

1) Go to the view where you want to access the attribute

2) Click on the context tab

3) Map the attribute created in COMPONENTCONTROLLER with view context using drag and drop

4) Use following code in the method of view to access value of attribute

You can also generate this code using wizard.

i) Click on wizard

ii) Select 'Read Context' radio button

iii) Select the attribute name created in step 1 (that you want to read) and enter



    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. " Replace with your node name
    DATA lv_name LIKE ls_node-name.     " replace with your node and attribute name
*   navigate from <CONTEXT> to <NODE> via lead selection
    lo_nd_node = wd_context->get_child_node( name = wd_this->wdctx_node ).     " Replace with your node name

*   get element via lead selection
    lo_el_node = lo_nd_node->get_element(  ).

*   get single attribute
    lo_el_node->get_attribute(
      EXPORTING
        name =  `NAME`     " Replace with your attribute name
      IMPORTING
        value = lv_name ).

Regards,

Saket.

Former Member
0 Kudos

Hi Saket,

Thanks for your help.

I created a attribute not a node under the 'context' tab of the COMPONENTCONTROLLER, so mapping for the attribute is not working.

saket_abhyankar
Active Participant
0 Kudos

Hi,

If you have directly created attribute under context of componentcontroller, I think that can also be mapped with the context of the view. That attribute can be accessed in the view using wizard as told in earlier post.

Better you create node in the context of componenrcontroller, create attribute under it and then map that node with the context of view.

Regards,

Saket.

Former Member
0 Kudos

Hi Saket,

Thank you very much!