Custom controller init & arguments

Hi there,
i would like to know if it is possible to pass arguments to a custom control constructor that are not properties/events/aggregation/etc.
I already read a lot of documentation as UI Controller without finding a way to do this.
I tried (and failed) some ways  :
-Instantiation
var oObject = new custom.TreeNode(sId,iNumber,mSettings);
or
var oObject = new custom.TreeNode(sId,{text:"test, width:100, ... , anArgumentThatIsNOTAproperty:12});
-Controller
custom.TreeNode.prototype.init = function(aThing){
console.log(arguments); //empty array
console.log(mSettings);//error not defined
console.log(aThing);////undefined
console.log(anArgumentThatIsNOTAproperty);//error not defined
console.log(this.anArgumentThatIsNOTAproperty);//undefined
if(sap.ui.commons.TreeNode.prototype.init){
     sap.ui.commons.TreeNode.prototype.init.apply(this,arguments);
Thanks for your help,
Regards,
Marc

If you read the documentation for the init() function it seems that the values provided in the constructor are not available in the init function.
https://sapui5.hana.ondemand.com/sdk/#docs/guide/6d6b5bda5727419eadcc9cbac1f6e6a1.html
Values that are given in the constructor method are not yet available in the init method. This is to prevent that a control only works when the values are set initially, but not when the values are changed.
It's not something I've tried, and not sure why you wouldn't want to use properties, however I think the following example would work.
http://jsbin.com/wigupuqikofe/1/edit
Regards,
Jason

Similar Messages

  • How to Call BAPI From the Custom Controller

    Hi
    I developed frist WD Application Using RFC Adapter.
    i did the following steps
    1. created the project
    2. created the model.
    3. created the customer controller and mapped the model of the controller to the model.
    4. mapped controller context to the views
    5. created one action in the start view
    6. created one method in the customer controller.
    so please let me know the lines of code to call BAPI using RFC.
    and  how to pass input valus to the bapi and how to execute the BAPI
    plese send the reply ASAP
    regards
    mmukesh

    Hi
    i did like this
    In  Start View OnActionSearch () method code
    public void onActionsearch (com.sap.tc.webdynpro.progmodel.api.IWDCustomEvent wdEvent )
           wdThis.wdGetTestCustControllerController().executeGetlistBapi();
    in CustomController Init method
    public void wdDoInit()
        Bapi_Flight_Getlist_Input input = new Bapi_Flight_Getlist_Input();
        wdContext.nodeBapi_FlightGetlist_Input().bind(input);
        input.setDestination_From(new Bapisfldst());
        input.setDestination_To(new Bapisfldst());
    In CUSTOMECONTROLLER executeGetlistBapi();
    METHOD
    public void executeGetlistBapi( )
        //@@begin executeGetlistBapi()
        try{
           wdContext.currentBapi_FlightGetlist_InputElement().modelObject().execute();
           wdContext.nodeOutput().invalidate();
        }catch(Exception ex){
           ex.printStackTrace();
    Then let me know what is wrong in this
    i did as per pdf
    please correct if there is any worng in this code.
    this is flight example .
    regards
    mmukesh

  • Accessing Custom Controller from setter and Getter methods

    Hi Gurus
    How can we access the custom controller from setter and getter methods,is there any way to do that.
    Thanks & Regards
    Rajasekhar

    Hi Steve.
    Thanks very much for valuable information,  the main controller class is getting tracked in mo_owner which is declared as  CL_BSP_WD_VIEW_CONTROLLER, and I'm getting the reference through
    mo_owner ?= owner. (since mo_owner = owner is not getting converted of type mo_owner ). After doing this on whatever the contexnode class (say zl_xxxx_xxx_cnxx) the corressponding context node values are getting turned as  <#ERROR IN METADATA.
    I mean when I'm checking the configuration in bsp_wd_cmpwb configuration tab -> Available Fields->Enlarge the contex node->BTSTATUS (say for Example) there the values are showing as <#ERROR IN METADATA , After executing the above procedure
    I cross checked several times before and after redefining the context node method IF_BSP_MODEL~INIT, before redefining this method UI is working fine, after redefintion UI is throwing below error .
    Exception Details
    CX_SY_REF_IS_INITIAL - Dereferencing of the NULL reference
    Method: CL_BSP_MODEL=>IF_BSP_MODEL_BINDING~IS_ATTRIBUTE_VALID
    Source Text Row: 13
    Thanks & Regards
    Rajasekhar

  • How to get my custom controller updated with the global custom controller?

    Hi all,
    I'm new to CRM Web UI and need some advice from the expert. Currently I'm working on component ICCMP_BT_DATES and noticed something weird with this component. When this component is first launch it display the dates of a service ticket correctly. However when I navigate to another screen, save a new ticket and back, the dates are not reflected. When I went in and debug the component, I noticed that the context is still tied to the previous ticket. I think the custom controller is not updated with the latest from the global custom controller.
    My question is how do I get my custom controller updated with the latest.
    Regards,
    Ricky

    You have to bind your custom controllers context node to the event NEW_FOCUS of the collection wrapper on the global custom controller.
    Best place to do this might be the CONNECT_NODES of the context of your custom controller.
    Get the global CuCo with GET_CUSTOM_CONTROLLER() and then the appropriate context node. Now:
    SET HANDLER yourMethod for lr_global_cuco->typed_context->thecontextnode->collection_wrapper activation iv_activate.
    Of course you have to implement a method similar to ON_NEW_FOCUS as it is on many other nodes.
    cheers Carsten

  • Can i Bind more than one Model object to the Custom controller or not

    Hi All, I trying to bind more than one model object to the custom controller, Both the model objects contains same attribute name called ( output). Both model objects created on to top of the BAPI. So when i bind first model object to the custom controller will work fine. When i am trying to bind the second model object to the same controller. This second model object also having the same attribute name called "output" . So it is giving an error of "Duplicate context element "Detail". Rename or uncheck duplicate elements.
    can i assign more than one model object to the single controller or not?
    But in the reference document, it has given that , we can create model object with more than one bapi.So in this case if both the bapis contains any element with the same name will also be problem. Any body give me the solution.
    Initially we have created one custom controller for each model object. But later i realized that, why con't we use same controller for all the model object. Because, the custom controller context is the public context. this context shared across all the view controllers.
    The concept which I am trying to do is right or wrong?

    Hi Vishal,
    of course, you can bind one controler to many models. When the same name occours you can simply RENAME binded node in controler.
    Regards
    Bogdan

  • How to read the details in the context node of the custom controller

    Hi friends,
        My requirement is i enhanced the component ICCMP_BP_DETAILS , now on EH_ONSAVE i want to read the details of the Context node in the Custom COntroller .
    In custom controller from ICCMP_BP_DETAIL/CuCoBPDuplicate  From this in context node CUSTOMER is there in that attributes first name last name is there i want to read those details
    so can u pls provide the logic for this how can i get the values.
      am very new to the BSP programming
    Regards
    Yogesh

    Hi Suchitha,
    when i am following the above code the lr_entity is not Bound, so can u pls suggest is there any thing is missing
    i used the below mention code but lr_entity is not bound
    DATA: lr_cuco type ref to CL_ICCMP_BP_CUCOBPDUPLICA_IMPL.
                lr_entity type ref to cl_crm_bol_entity.
    lr_cuco ?= me->get_custom_controller( 'ICCMP_BP_DETAIL/CuCoBPDuplicate') .
    CHECK lr_cuco IS BOUND.
    lr_entity ?= lr_cuco->typed_context->customer->collection_wrapper->get_current( ) .
    CHECK lr_entity IS BOUND .
    lr_entityIF_BOL_BO_PROPERTY_ACCESSGET_PROPERTY_AS_VALUE( iv_attibute =  'FIRST_NAME' ev_attribute = lv_firstname ) .
    Please correct the code if any thing is missing
    Regards,
    Yogesh

  • Error when creating custom controller

    I have a non-visual WebDynpro DC that contains a single data model.  The model has been added to the public part of the DC.
    I have another visual WebDynpro DC that makes use of the data model in the first DC.  If I explicitly reference the model in the first DC, everything works just fine.  I can input data, invoke the model, and see the response displayed on the page.
    However, I'm trying to create a custom controller that hides the data model.  When in the data modeller for the visual WD DC, I right click on the 'Custom Controllers' pane, and select 'Apply Template'.  I create a Service Controller, and select the model that's been imported (actually, that's been referenced as a used component) from the first DC.  I then select the data elements from the context that I want bound into this custom controller.  Click next, give a more descriptive method name, and then click Finish.  I get an internal error as follows:
    Source controller implementation file is not accessible (D:/src/.dtc/LocalDevelopment/DCs/example.com/test-wd-view/_comp/gen_wdp/packages/com/example/wd/AdderModelCust.java)
    Exception: java.lang.NullPointerException
    Am I doing this correctly, or am I missing a step or two?

    Hi Ken,
    you didn't miss some steps, this seems to be a bug in the tools. Please open a OSS message with the following information:
    - which Studio version you use (NW04/04s? SP?)
    - description of how to reproduce the effect
    - Studio's error log attached (.log file in <YourWorkspaceFolder>/.metadata)
    In the meanwhile to circumvent the error you should try to
    - create a new custom controller manually in WD explorer and launch Service Controller template from this controller (context menu in WD explorer)
    - if this fails as well, manually create the context definitions and method implementation that the template would produce.
    Regards
    Christian

  • How to get the reference of the View controller in from Custome controller

    Hi friends,
    From one of the Custome controllers in my Component,I am raising a popup based on conditions.
    I want to subscribe to popup buttons.
    Following is the code that I have written.
    IF LT_RECEIPTS_T[] IS not INITIAL.
        data lo_window_manager type ref to if_wd_window_manager.
        data lo_api_component  type ref to if_wd_component.
        data lo_window         type ref to if_wd_window.
    *BREAK-POINT.
        lo_api_component  = wd_comp_controller->wd_get_api( ).
        lo_window_manager = lo_api_component->get_window_manager( ).
        lo_window         = lo_window_manager->create_window(
                           window_name            = 'W_PERSONALCARDPOPUP'
                           message_display_mode   = if_wd_window=>co_msg_display_mode_selected
                           button_kind            = if_wd_window=>co_buttons_okcancel
                           message_type           = if_wd_window=>co_msg_type_none ).
        lo_window->open( ).
        DATA: view_controller TYPE REF TO if_wd_view_controller.
        view_controller = wd_this->wd_get_api( ).
        CALL METHOD lo_window->subscribe_to_button_event
          EXPORTING
            button      = if_wd_window=>co_button_ok
            action_name = 'OK'
            action_view = view_controller.
    as I am In Custome controller,wd_get_api is returing of type if_wd_controller,but the subscribe_to_button_event
    requires action_view of data type if_wd_view_controller.
    but,my problem is that I can keep the view only Custome controller.
    when I pass the 'VIEW_CONTROLLER' variable to method subscribe_to_button_event,I am getting the error  as type missmatch.
    Please suggest how I can rectify this error.
    Regards,
    Xavier.P

    Hi Xavier,
    You try this
    1. Define an attribute in your custom controller to hold your popup window reference for e.g lr_popup of type if_wd_window
    2. Store the popup window reference in lr_popup when calling your popup
    lo_api_component = wd_comp_controller->wd_get_api( ).
              lo_window_manager = lo_api_component->get_window_manager( ).
              wd_this->lr_popup = lo_window_manager->create_window(
                              window_name = 'W_PERSONALCARDPOPUP'
                              message_display_mode = if_wd_window=>co_msg_display_mode_selected
                              button_kind = if_wd_window=>co_buttons_okcancel
                              message_type = if_wd_window=>co_msg_type_none ).
             wd_this->lr_popup->open( ).
    3. Define the custom controller usage in the properties of your popup view
    4. In WDDOINIT of your popup view write the following
    DATA lr_custom_controller TYPE REF TO ig_<Custom Controller>.
            lr_custom_controller = wd_this->get_<Custom Controller>_ctr( );
            lr_custom_controller->lr_popup->subscribe_to_button_event(
         button = if_wd_window=>co_button_ok
         action_name = 'OK'
         action_view = wd_this->wd_get_api( ) ).
    5. Define the event handler for OK in your popup view
    Best Regards,
    Loveline

  • How to call a custom controller method from view

    Hi,
    I ve created a simple web service and consumed it in a model. Mapped the input & output parameters to custom controller context which in turn mapped to component controller's context which in turn to view's contexts.
    How to call a custom controller method from view?
    Please explain the syntax.
    Regards,
    Manoj.

    Hi Patralekha,
    Give some idea for the below scenario:
    I ve created a simple web service and consumed it in a model. What I did was
    1) for the input parameters, mapped the node from view->custom controller->model
    2)for the output parameter, mapping from model->custom controller->view.
    It works fine.
    But I don't want to access model nodes directly, rather I want to set the input param in somewhere else (like custom controller) before calling the appropriate method, same for the response also.
    Share me your thoughts.
    Regards,
    Manoj.

  • How to call a custom controller method in a view

    Hi ,
    I am getting the partner no in the custom controller method . I want  to call that method in the view.How is it possible......?

    Hi Masood,
    now i dont want cross compnent navigation ....
    Requirement : Account Identification number in ZVIEW
    My component is  CRMCMP_BPIDENT
    In the custom controller   CRMCMP_BPIDENT/CuCoBuPa  under context node   SEARCHCUSTOMER
    the attribute struct.partner is available 
    in this component  im navigating from  
    CRMCMP_BPIDENT/ObjectCompVs   to   ZCRMCMP_BPIDENT/ZProducts 
    in the layout of   ZCRMCMP_BPIDENT/ZProducts
    TRY .
    lr_cuco ?= controller->get_custom_controller( 'CRMCMP_BPIDENT/CuCoBuPa' ).
    CATCH cx_sy_move_cast_error.
    RETURN.
    ENDTRY.
    check lr_cuco is bound.
    lr_entity ?= lr_cuco->typed_context->SEARCHCUSTOMER->collection_wrapper->get_current( ).
    check lr_entity is bound.
    lv_account_name = lr_entity->get_property_as_string( iv_attr_name = 'BP_NUMBER' ).
    this code is written to get the account identification number but still the same problem
    lr_entity not getting populated .......
    i checked  IF_BSP_WD_HISTORY_STATE_DESCR~IS_RESTORABLE 
    hr rv_result is set to x.....
    any  suggestions....
    Regards,
    Sijo...

  • Error while creating the custom controller

    Hi experts,
    I am working on a web dynpro object where i need to create an application configuration.I created a custom controller context.I mapped it to main view.I am using the attribute of custom controller context in main view so that another view view1 is displayed based on this attribute.
    custom controller context
    node1 --> display_view1
    mapped above node to main view.
    view1 is triggered in main view onaction method based on display_view1 value.
    Presently i am getting the dump " node1.1.main doesnot have elements."
    Please help.
    Edited by: ch_ravi_sap on Nov 22, 2011 2:11 PM

    Hi I get rid off the error.
    Changes i have made are cardinality from 0:n to 1:n. selection 0:n
    But presently i am changing the attribute of custom controller in component configuration browser.I am not able to see the changed value in main view ( where i have used this attribute ).
    Any help is appreciated
    Edited by: ch_ravi_sap on Nov 23, 2011 12:17 PM

  • Error while binding the model with the custom controller

    Hi All,
    I first started with a dummy project and in that binded the model with the custom controller.
    For some reason, I deleted the project and created a new one. I have deleted the whole project from the workspace.
    Now, when I am trying to bind the model  again , I am getting an error when selecting the response parameters saying that DUPICATE ENTRIES.Ideally it should not happen when I am deleting it completely.
    I am using a Webservice Model. Can any one help me out to resolve the same.
    Looking forward for your response.
    Regards
    Dipendra

    Hi Raman,
    I did that and even I have Installed the IDE again.
    Still I have that error.
    Regards
    Dipendra

  • Issue in Binding Custom controller to Component Controller

    Dear All,
    I have enhanced a standard component ERP_H.
    I created a custom controller with context nodes BTSTATUS, BTSTATUSH
    I enhanced the component controller with context node BTSTATUS, BTSTATUSH
    Now when i try to bind the custom controller to component controller using this code in the context class of my custom controller
    bind to component controller
      owner->do_context_node_binding(
               iv_controller_type = CL_BSP_WD_CONTROLLER=>CO_TYPE_COMPONENT
               iv_target_node_name = 'BTSTATUS'  " component controller context node
               iv_node_2_bind = BTStatus ).
    its not working since this context node in component controller is not the standard one but the custom added one.
    Am i missing something, or is there any way to bind customer context node in custom controller to customer context node in component controller.
    regards,
    pradeep

    Hi pradeep,
        Try the other way round go to the context class in the component controller and paste the following code in the
    create_contextnode( context node = name of the node to be linked).
    *owner->do_context_node_binding(
            iv_controller_type = cl_bsp_wd_controller=>co_type_custom   <-----linking from component to custom
            iv_target_node_name = 'BUILHEADER' "target node: component controller node
            iv_node_2_bind = BUILHEADER ). "source node: current node.
    See if this works.
    Thanks

  • Do I need to use a custom controller & view set

    Good Day,
    Please excuse the long question.
    I am in the process of creating a new BSP application.  In a nut shell, my application is going to accept a bunch of data in the URL and pass the data to an external system.  Depending on what is returned from the external system, it will prompt the user to either supplement the data or to confirm what the external system has sent back. 
    I would like to have all of the business logic that communicates with the external system and decides what type of user interaction to be located in one central class.  I was thinking that I could have a custom controller that is resident for the life of the application.  It would call the external system and navigate to other views depending on what is required.  When the user responds, the response would go to the custom controller and be sent to the external system.  So, my first question is does this sound reasonable?  For my second question, is it possible to have a view associated with the custom controller.  If so, I can use it for the confirmation "screen".
    While looking at the Web IC cookbook, I ran accross the section on view sets.  Are there pros and cons to using a vew set for an application like this?  I expect the browser window to contain one view at a time and it kind of seems like view sets may intended more for where there are several views displayed within the browser and the view set allows you to change only one.  Is that true?
    Thank you very much for any insight you can offer.  I promise to award points for helpful responses.
    Thanks and kind regards,
    John

    Hi John,
    My suggestions would be to use a model class for the business logic and call to the external system.  The controller would only be for eventing and determining what view to call.  I would create a parameter called view_name on the controller and toogle this between your views depending on what returns from your model methods.  As a personal preference I would pass the 'bunch of data' in the form rather than the URL.  Validate it in a model method before sending it to the external system.  I tend to use URL querystrings for small stuff rather than large application data.  Also what would happen to the application if someone saves your URL as a favorite and launchs the app.
    Those are my thoughts hope it was helpful.
    Regards
    Matt

  • What is the use of Custom Controller in ABAP WebDynpro?

    Hi,
    Can you explain me about Custom Controller and its uses and some example on it?
    I have gone through SAP help but not understand clearly. Wish to see some good explanation here?
    Thanks in advance.
    Regards,
    Meera.

    In addition to above,
    1. Custom controller can acts as "Config Controller"
    2. it is bit different than component controller in the manner that Hook methods will be different here ( only two ) and
    these methods will not participate in the phase model unless there is a method call of custom controller as opposed to component controller which always participate in the phase model.
    someone please correct me for the last statment if i am wrong.
    Edited by: kranthi kumar on Dec 31, 2010 11:37 AM

Maybe you are looking for