Calling component controller's method

Hi,
How can i call component controller's method from a view?
Thanks.

Yes, You can call method of component controller from View.
If you have already mapped any context node/attribute between your view and component controller then it means component controller is already added in your view. If you have not done same then you can add component controller by going into the properties of view.
To access the method use following code.
wdThis.wdGet<Your_controllername>Controller().<methodName>();
Regards,
Rohit

Similar Messages

  • Calling Component controller method in webdynpro

    Hi All,
    Is it possible to call a method from component controller to view controller?
    Regards,
    Sasikala

    yes it is possible.
    hope this would help you
    http://help.sap.com/saphelp_nw70/helpdata/en/3b/29933f09a5fb47e10000000a114084/content.htm
    Regards,
    nag

  • Call component controller method from view

    Hi
    I have created an action in view Thus its event handler is "OnActionDoSomething()"
    And, I have a method in component controller "MethodSaySomething()".
    Now, how can I call MethodSaySomething() from OnActionDoSomething().
    OnActionDoSomething()
    // Call  MethodSaySomething() defined in component controller
    Thanks

    Hi,
        To access the methods present in component controller from View , first u need to add the component controller as the required controller.
    open the view controller --> switch to propertues tab --> add the component controller as required controller(click add controller).
    Now in your action handler , write this below code to add the method:
    wdThis.wdGet<COmponent Controller>().MethodSaySomething();
    Hope it helps
    Thanks and Regards,

  • Coupling between component controller and view controller

    Hello,
    I have seen some discussions in this forum regarding the possibilities of calling / triggering a view controllers's method from a component controller's method;  obviously the Web Dynpro framework only provides for the other direction (view ctrl -> comp ctrl) via handle <i>wd_comp_controller</i>.
    Some people proposed raising events in the comp controller and catching these in the view controller, others pointed out that any dependance of a view controller on a component controller would violate MVC principles.
    Now, I can't see why a tighter coupling (in both ways) between controllers within one component would harm MVC in any way. So I suggest to "register" a view controller in the pertaining component controller if necessary:
    this_controller = wd_this->wd_get_api( ).
    wd_comp_controller->register_view_ctrl_XYZ( this_controller ).
    This way the component controller can save the reference and later call any method on it. What do you think, does anything argue against this practice?
    Regards,
    Sebastian

    Hi Sebastian,
    I wouldn't try to explain whether it is violating the MVC principles or not.
    Can you please explain how to call methods of view using the view controller?
    have you tried using an example???
    I want to give a small example which I think is a basic disadvantage of calling View methods from component controller.
    Suppose I have 30 methods in a view and such 7 views in a component (I think this is a very common example).
    Till now one is very clear that if I have a method in view, it will be called at maximum by other methods with in the view. That means at any point of time, my search is limited to 30 methods.
    Now if component controller can also call my search will become horrible and spread to 210 methods, unless otherwise, you are very good at naming attributes and wont make the mistake of assigning attributes wrongly.
    Imagine the effort if the outside components also access these methods through interface.
    Also I dont think that the webdynpro phase model can support this way of calling view methods. You might be successful once, but then you are trying to open a can of worms.
    This is my way of thinking...
    Also, it would be great if you can tell me whether you are successful in calling views methods or not???
    Thanks,
    Anand

  • Design question: Interface Controller vs. component controller

    Hello,
    I have a component A. This component has a component controller (compController) and an interface controller (intController).
    Component controller has method compMethod()
    Interface controller has method intMethod()
    - Am i allowed to call intMethod from component controller? ( i'm pretty sure this isnt bad design because this is also done in the tutorial on eventing)
    - Am i allowed to call compMethod from intController or is this bad design?
    - Am i allowed to subscribe compController to event in intController or is this bad design?
    Kind regards,
    Joren

    Hi Joren,
    like Valery already pointed out, we recommend not to implement any logic in the component interface controller but only implement methods used for delegating logic to the component controller. This is based on the fact, that the component interface controller will be implemented by the component controller in the the next major SAP NetWeaver Release. This means that it will not have its own Java class like in NW04 and NW04s. To simplify migration the interface controller code should be as slim as possible by applying the delegation principle.
    You wrote:
    <i>- Am i allowed to call intMethod from component controller? ( i'm pretty sure this isnt bad design because this is also done in the tutorial on eventing)</i>
    Yes, my (very old) tutorial on serverside eventing exposes a public method <i>fireEvent()</i> which is invoked by the component controller. In early versions of NW04 the wdFireEventInnerEvent() method was not exposed in the IPublic-API of the component interface controller but only in the IPrivate-API. Therefore an additional method fireEvent() must be defined to fire the event from another controller. As a negative side effect, this public fireEvent() method is also exposed by the IExternal-API of the component interface  controller so that the event can be fired from outside (by the Embedder component) which is not desired in most cases.
    Meanwhile the wdFire<event name>() method is exposed by the IPublic-API of the component interface controller, so that the public method fire<Event name>() is no longer needed.
    I will update the tutorial in this respect so that it again propagates best practices.
    Regards, Bertram

  • Unable to access Component Controller attributes from Views.

    Hi,
      I am unable to access the attributes in component controller from methods in View even by using WD_COMP_CONTROLLER.
    Say, I want to access the attribute G_FLAG in component controller from a method in the View Controller by the following code :
      WD_COMP_CONTROLLER->G_FLAG = 2.
    Then an error message is showing up saying -  Field G_FLAG is unknown. It is neither in one of the specified tables nor defined by a DATA statement.
    What should I do? Plz suggest..

    Hi,
    Please check the Public check box of the attribute in the component controller.
    Hopefully it will solve your problem.
    Thanks

  • Find out the "Action" invoked in component controller

    Hi,
    Is there a way where i can find out in my component controller(wdPostProcessing) which button was clicked in the View?

    I am using EVS. In that when the entered value doesn't match the enumeration values, it gives a error "String "xxx" doesn't match the enumeration". Now i when i click my custom Reset button in my WD application i want that all the values to be cleared (I have a bunch of EVS's ) on the screen. But when i have such error like the above my OnActionReset is not invoked at all until i clear manually all the invalid values in the EVS.
    In debug i found that the control directly goes to component controller wdPostProcessing methods even before it invokes the OnActionXXXX events. So, here i want to identify the action generated on the view and do something to handle it.
    I also want to give my custom message instead of seeing the standard message "String XXX doesn't match the enumeration".
    Message was edited by: Aditya Atluri
    Message was edited by: Aditya Atluri

  • Calling a method in view from component controller?

    Hi,
    Is it posible to call a method that is defined in the Component Controller in the View?
    If it is posible please give some sample code how to call the method?
    Regards,
    Padmalatha.K

    Padmalatha, all the methods defined in a controller from 'Methods' tab are instance methods. An instance method defined in a component controller is callable from any view controller that holds a reference to the component controller.
    Defining methods between the tags
    //@@begin others
    //@@end
    is useful if you want to declare static methods.

  • Calling a method in the view controller from the component controller

    Hi
    Is there anyway to call a method in the view implementation from the component controller??
    Thanks
    jack

    Thanks for all your replies. I want this kind of a functionality because Im trying to invove a DC (Child DC) from a Parent DC such that the Child DC's view is displayed onto the view container of the Parent DC. I have embedded using 'interface view of a component instance' in the Parent Window and am able to create the component and set usage though the onPlugDefault of the Child View.
    But I observe that when i make a call from the parent, the flow is like this:
    1. The wdDoInit of the Child Component Controller gets triggered first.
    2. Then the wdDoInit of the Child's <b>VIEW</b> gets triggered
    3. and <b>THEN</b> the onPlugDefault of the Child Component Interface View
    What I had actually wanted was to Fire onPlugDefault where Im calling a method LoadData(), after which the Child DC's view must be triggered so it can display the fetched data.
    What is actually happening is the view gets displayed, but no data is displayed in the view.
    Right now I have just given a work around where Im triggering <b>LoadData()</b> of the <b>COmponent COntroller</b> from the <b>wdDoInit</b> of the <b>VIEW</b>.
    Is there a better way to do this? I find it strange that I have to load the Data from the view.
    Thanks
    Jack

  • Call a method in the view from Component Controller

    Hi Friends,
    I have written the code for calling the RFC in Component Controller.
    My requirement is to change the properties of UI elements in the view, if I get any exception while calling RFC.
    Can Call a method in the view from Component Controller.
    Regards,
    Lakshmi Prasad.

    HI,
    You can get the error message during the exception of calling RFC in view itself.
    Any way you may call the RFC at some action in the view only.
    Can you explain me what you are trying to do?
    Kind Regards,
    Mukesh

  • How to call Custom or Component Controller methods from View Controller

    Hy Guys,
    how do I call Custom Controller or Component controller methods from a View or Context Controlller?
    thanks in advance
    Jürgen

    Hi Juergen
    Yes it is possible, pls follow the below approach to access the component controller in context node class
    1) since the standard component controller class is protect variable , declare a variable of type component controller in your controller class.
    say for example the public variable you declared is  g_comp_controller
    2)  now redefine the controller class method WD_CREATE_CONTEXT  and add the below lines of code
       g_comp_controller ?= me->comp_controller.
    3) go to context node class  (CNXX)  there declare the varaible which of type controller class (IMPL)  as public variable, for example g_owner
    4) redefine the method  IF_BSP_MODEL~INIT  and write the below code
         CALL METHOD super->if_bsp_model~init
        EXPORTING
          id    = id
          owner = owner.
      g_owner ?= owner.
    5) now the variable   g_owner  that is declared in  (CNXX)   contains reference to your controller class
    6) in  on_new_focus  method access your component controller in the below manner and access the entities also.
    DATA: lv_owner                    TYPE REF TO xxxxx_impl,  " Implementation class
                 lr_comp_cont                TYPE REF TO xxxx_bspwdcomponen_impl, " component controller class
                 lv_entity type ref to cl_crm_bol_entity.
    lv_owner ?= g_owner.
    lr_comp_cont    ?= lv_owner->g_comp_controller.
    IF lr_comp_cont IS BOUND.
       lv_entity ?= lr_comp_cont->typed_context->mdfcampaign->collection_wrapper->get_current( ).
    now lv_entity contains the value of component controller context node.
    Thanks & Regards
    Raj
    Edited by: bmsraj on Sep 27, 2011 3:28 PM

  • WD ABAP: call dialog window from component controller method

    Hi all,
    I need to call a dialog box from a method in the component controller. It would be helpful if u could post the code too.
    Thanks,
    Sravanthi

    Hi Maksim,
    this is the code i wrote:
    DATA: api_component  TYPE REF TO if_wd_component,
          window_manager TYPE REF TO if_wd_window_manager.
    api_component = wd_this->wd_get_api( ).
    window_manager = api_component->get_window_manager( ).
    wd_this->window = window_manager->create_window(
               window_name = 'OPTIONWD'
               close_button = abap_false ).
    wd_this->window->open( ).
    When i test it, this is the error i get.
    "An Instance of the View OPTIONWD Already Exists in the Component"
    how do i correct it?
    Thanks,
    Sravanthi

  • Call a view's method from Component Controller.

    Hi
    Is it possible to call a view's method from Component Controller.
    Regards
    Nikhil

    Hi Tummuru,
    I have created an event in Component Controller by the name toMenuView. Now I created a method in which this event is getting fired. Foll. is the code of the method.
      public void fireToMenuView( )
       wdComponentAPI.getMessageManager().reportSuccess("fireToMenuView");
       wdThis.wdFireEventToMenuView();
    Now I have created an event handler "handleToMenuView" in the MenuView and subscribed the event handler to the event in Component Controller.
    The control is reaching to the fire event in component controller but not to the Event handler in view controller.
    What am I missing.
    Regards
    Nikhil

  • Call method of interface controller from component controller

    hi,
    I have created one method in the interface controller of a component. Now i have this method along with attributes to the component controller. Now from the component controller i want to call the method of the interface controller. How do i do it???

    Hi,
    You dont need to call the method from the interface controller when you are in the same component.
    You can call the method which is in the component controller.
    Interface controller is used to expose some methods to a different component.
    Ex Comp a want to expose a method which will be used by comp b then  you need the interface controller in comp a.
    Comp b will use comp a as used component
    then it will invoke the methods.
    Regards
    Ayyapparaj

  • Calling view controller method from component controller method

    Hi,
    Is there any way to call view controller method from component controller method?
    Thanks,

    Hi Khandal.
    You should not make you component controller dependent from a view controller.
    But what you can do is to define an event in the component controller. The view
    controller can register for this event.
    In the stage where you currently want to call the view controller method just fire
    the event. In the event handler method in the view controller you can call the
    method then.
    Why do you need to call a view controller method? Can you give more details
    about the scenario?
    Cheers,
    Sascha

Maybe you are looking for