cancel
Showing results for 
Search instead for 
Did you mean: 

Getting Instace of the component in the class.

arafat_shaik
Explorer
0 Kudos

How do we get the instance of a webdynpro component into some class.Can somebody please help me.

Accepted Solutions (0)

Answers (6)

Answers (6)

arafat_shaik
Explorer
0 Kudos

got the answer by myself, thanks fareez.

arafat_shaik
Explorer
0 Kudos

Hi Fareez,

   Can you please eloborate a bit. I am not getting what you are suggesting.

Former Member
0 Kudos

Hi,

What I was trying to tell is to pass the reference of the wd_comp_controller and wd_this of the view you wish to the your class through a method or constructor. You are going to do everything as usual. Instead of doing the process in the action, you should call the method of the class passing wd_comp_controller(current component) and wd_this (current view) to the method.

Regards,

Fareez

Former Member
0 Kudos

Hi,

What I was trying to tell is to pass the reference of the wd_comp_controller and wd_this of the view you wish to the your class through a method or constructor. You are going to do everything as usual. Instead of doing the process in the action, you should call the method of the class passing wd_comp_controller(current component) and wd_this (current view) to the method.

Regards,

Fareez

Former Member
0 Kudos

1. Get the reference of type IF_WD_COMPONENT

lo_component = wd_comp_controller->wd_get_api( ).

2. Pass this to any method of your class where you need it.

If you want component controller, yo can pass WD_COMP_CONTROLLER which is of type IF_COMPONENTCONTROLLER to the method of the class.

arafat_shaik
Explorer
0 Kudos

I am trying like,

In WD Component.

METHOD get_ref .
   DATA: lo_comp TYPE REF TO if_wd_component.
*        lo_ctrlr type ref to IF_WD_CONTEXT_NODE.

   lo_comp = wd_this->wd_get_api( ).

   lo_context ?= wd_context.
  
   go_obj->get_comp( LO_COMP_CONTEXT = lo_context ).

*  wd_assist->get_context( lo_context = lo_context ).


ENDMETHOD.

***************************************************************

In constructor of my class i am creating the object go_obj.

************************************

IF go_obj IS NOT INITIAL.
     CREATE OBJECT go_obj.
   ENDIF.

***************************************

Its giving error as go_obj unknown in my method get_ref in webdynpro(I have declared it in attributes of the comp controller and parameters of the get_ref method).


Former Member
0 Kudos

Hi

Have you declared your class as assistance class in your component?


REGARDS
yuval peery

Former Member
0 Kudos

Hi

I think what you try to achieve is wrong.

SAP designed the controller (view or component) in order to maintain

your code there. No where else. If you feel you must have a different

class, you can always start a new custom controller.

In this way you will have a robust design that is supported

by the framework.

regards

yuval peery

arafat_shaik
Explorer
0 Kudos

Actually the requirement is to get the instance of the component controller context into one class and handle all UI related bindings over there. How to achieve this, any help regarding this is very helpful.

Former Member
0 Kudos

Hi arafat,

Just pass the wd_comp_controller to the class. That instance is the component controller. However, UI Elements will be present in views only. wd_this in a view corresponds to that view. So you may need to pass that too.

Regards,

Fareez

Former Member
0 Kudos

Hi Arafat,

What is the requirement you are trying to achieve. Can you specify more clear?

Regards,

Fareez

former_member198064
Participant
0 Kudos

Hi Arafat shaik,

look the below code you can understand.

* Declare ALV config table
  data: ALV_CONFIG_TABLE  type REF TO CL_SALV_WD_CONFIG_TABLE.

  DATA: wd_table_usage TYPE REF TO if_wd_component_usage.

* Create an instance of ALV component created ALV_COMP is usage name
  wd_table_usage = wd_this->wd_cpuse_alv_comp( ).
  IF wd_table_usage->has_active_component( ) IS INITIAL.
    wd_table_usage->create_component( ).
  ENDIF.

* Get ALV component
  DATA: wd_table TYPE REF TO iwci_salv_wd_table.

  wd_table = wd_this->wd_cpifc_alv_comp( ).
  alv_config_table = wd_table->get_model( ).

* Declare variable to store column details
  DATA: column_settings TYPE REF TO if_salv_wd_column_settings,
        column          TYPE REF TO cl_salv_wd_column.

  column_settings ?= alv_config_table.

Thanks,

Venkatesh