Custom controller - WEBDYNPRO
My friends what is the use of custom controller at what situation we should use that.
And if we declare custom controller will it be considered globally
Edited by: VENKATESH MADANAGOPAL on Sep 30, 2008 7:33 AM
Hi Venkatesh,
Try going through the SAP documentation you will come across the desired information. The below lines are taken from 1 such source.
Regards,
Uday
Custom controllers are optional controllers that must be defined by the developer. These controllers can be used to modularize the component content. For example, custom controllers can act as local controllers for some views, or they can be used to encapsulate the logic related to a certain model class (business logic).
This allows you to reduce the content of the component controller by populating sub-functions.
Custom controllers are optional. They have to be defined at design time and can be used to encapsulate sub-functions of the component controller. Multiple custom controllers can be defined in a component. Custom controllers are instantiated automatically by the Web Dynpro framework and the instantiation order is undefined; therefore, the coding in a custom controller should
Similar Messages
-
Resue of Custom Controller to another webdynpro component
Hello,
I would like to use all the methods and context of one custom controller residing in one webdynpro component from another view residing in another webdynpro component.
Could you please give me an idea asto how this can be achieved?
For this I have added the first webdynpro component(which has the custom controller) to its public part and added the first component to the other webdynpro component(which will resue the previous one) as a used DC.Now I want to access all the methods of this custom controller in the view of this second component.
Thanks and Regards,
AryaHi
To make uses of component and its other controller u have to deal with [ Interface controller|https://www.sdn.sap.com/irj/scn/go/portal/prtroot/docs/library/uuid/f07c3625-c971-2910-3a9c-ce131487f82c]
For [Custom Controller|http://help.sap.com/saphelp_nw04/helpdata/en/c4/862594e85911459301aa71a2b7b6b4/frameset.htm] it is nothing but a separation of the component controller task into unit for example want to implement OVS ,so put it in one dedicated custom controller etc.
Best Regards
Satish Kumar -
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 -
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 -
Difference between component controller & Custom controller
Hi all
what is the main difference b/w component controller , custom controller & interface controller.
i want to know the difference of these three in the real time environment.
if anybody explains me with any simple example then it is great help to me....
Thanks
Suresh babu.Hi Suresh,
Component Controller and Custom Controller are more or less the same. Both are related to a particular component in the webdynpro application you create.
Component Controller:-
For each component of yours there will be a component controller, were in you can define context variables and methods, events etc.. This usefull while using models.
Simple example where we can see this is, when you create global context variable in this controller and map this variable to the view controller context variable of different view, which enables you to pass the value of the variable from one view to another.
Custome Controller:-
They also have the same the function but as the name suggest there function can be customised. That is we can have more than one custom controller for a component. This is usefull when we need to create seperate execute methods for inputs from model import( Both webservice and rfc call).So you can seperate each other. Example is there in the more sample codes and application section.
Interface Controller:
There is only one interface controller for a component. It is mainly used when we need to communicate between two components.There is sample application for communication between two components in the sample codes and application section.
Regards
Sreedhar. -
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
mmukeshHi
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 -
Method in custom controller not getting called from view
Hi experts,
I have a very strange problem. My web dynpro application works fine on the development portal. i am in the process of deploying to the production portal there is no issue it deploys perfectly without any problems. However i have noticed that some methods in my custom controlller which are called from the view do not run. there is no error message or anything data just doesnt get picked because the execute function which fills the context are in the custom controller methods.
For some reason the method in the custom controller does not get called even though i'm calling it for the view. I have this problem with two methods. the other methods work without any issue.
Now i overwrote what i have on production at the moment so am stuck and in need for a solution.
I have tried undeplying, restarting and re-deploying to no avail. what could be wrong?
thanks and regards,
dilankeDeal all
This is the code. basically im calling it from the plug on the detail screen.
This is the method that doesnt get called anymore.
wdThis.wdGetGetPurchaseOrderCustController().getPODetail();
The reportSuccess() works fine.
regards,
Dilanke
public void onPlugFromListView(com.sap.tc.webdynpro.progmodel.api.IWDCustomEvent wdEvent )
//@@begin onPlugFromListView(ServerEvent)
try
String po = wdThis.wdGetGetPurchaseOrderCustController().wdGetContext().currentContextElement().getPO_Id();
wdContext.currentZGETPODETAILS_INPUTElement().setI_Ebeln(po);
wdThis.wdGetGetPurchaseOrderCustController().getPODetail();
wdComponentAPI.getMessageManager().reportSuccess(po);
String fileName = "F://XML_Downloads//" + po + ".xml";
IWDResource resource = WDResourceFactory.createResource(new FileInputStream(new File(fileName)),fileName,WDWebResourceType.XML,true);
wdContext.currentContextElement().setXml_Resource(resource);
catch(Exception e)
e.printStackTrace();
//@@end -
Should i Map thecommon RFC Model to component contrl or custom controller?
In my webDynpro project , I have two modules one is DirectCustomer and InDirectCustomer. so i have set of RFS's in a single RFC model. In this RFS's some are common to both the modules. some are independent to each other. so i have created two controller component one for each module.Then i mapped the independent RFC'c to each controller seperately. But now the RFC's which are common to both modules to map, Better, should i map to existing Componentcontroller or should i create new customcontroller (like commoncontroller).
which i option is better, can u suggest me. I feel that, The common RFC's will be mapped to component controller, bcz it the Base controller for the both customcontroller , indrectly to the viewcontroller.
Can any body give me the suggestion on thisHi Vishal,
As far as I know it's recommended to use a custom controller for every RFC. This makes sense because if the RFC changes some day you only have to do changes in the specific custom controller. -
Entering into the method created in custome controller but no output
Hi Experts,
Please help me to get the data.I have followed the same process to access the database but no output i am getting.But the method created in custome controller is called and message is also displayed.But no error it is showing.Please tell me where i am wrong.
Regards
NutanHi Isaias,
Method is
public void ExecuteBapi( )
//@@begin ExecuteBapi()
IWDMessageManager manager = wdComponentAPI.getMessageManager();
manager.reportSuccess("entered");
try
{ wdContext.currentZbapi_Role_Getlist_InputElement ().modelObject().execute();
wdContext.nodeEt_Role().invalidate();
catch(Exception e)
e.printStackTrace();
And the action which is calling this method is:
public void onActionDisplayRole(com.sap.tc.webdynpro.progmodel.api.IWDCustomEvent wdEvent )
//@@begin onActionDisplayRole(ServerEvent)
wdThis.wdGetFetchDataCustController().ExecuteBapi();
//@@end
Please check it where am i wrong? Urgent need
Regards,
Nutan -
Should i Map thecommon bapi's to component controller or custom controller?
Hey Can any body give the clarification for this doubt
we have one web dynpro component , It contains some views. Created some BAPIs. Now we have two different applications in the same component. So we have created the two controllers for each application. the created BAPI's are mapped to o each controllers with respect to application. . Now we have a small doubt, the Bapis which common are common to both application not binding to any of that two controllers. so the common bapis should be map to the component controller or created one more controller like util Controller.
Once bapis mapped to any of this we can add this controllers to views. Please suggest which one is better, either mapping bapi's to component controller or custom controller.
vijayHi Raj, thks for the quick responce again. I made small mistake in the sentence.Plz look at now again
In my webDynpro project , under that i have created only single WebDynpro component with two applications .I have two modules(applications) one is DirectCustomer and another one is InDirectCustomer. so i have set of RFS's in a single RFC model. In this RFS's some are common to both the views. some are independent to each other. so i have created two custom controllers one for directCustomer another for Indirectcustomer.Then i mapped the RFC' model objects to each custom controller seperately . But now the RFC's which are common to both views to map, Better, should i map common RFC model objects to existing Componentcontroller(which comes by default when create the webDynpro component) or should i create new customcontroller (like commoncontroller).
which i option is better, can u suggest me. I feel that, The common RFC's will be mapped to component controller, bcz, it the Base controller for the both customcontroller , indrectly to the viewcontroller.
Wht is your suggestion on this disign issue? -
Internal Error when trying to create a custom controller with execute comma
Hi,
I have got the following problem. I created a new web dynpro project and added an existing RFC model. But when I try to create a custom controller by applying a service controller including an execute command, I only get an internal error message. The message shows the following information:
Plugin name:
Web Dynpro Controller Editor Services
Plugin ID:
com.sap.ide.webdynpro.service.controllereditor
Class:
com.sap.ide.webdynpro.service.controllereditor.implementation.ImplementationService
Method:
getJDTMethod(Controller, String, IProgressMonitor)
Message:
Source controller implementation file is not accessible (Path to workspace folder: P:/.../gen_wdp/packages/com/clariant/ml5/types/ML5Cust.java)
Exception:
java.lang.Exception: 0
Maybe someone could help me to fix this problem.
Thanks Andy
Ok... I found a way to fix by myself. All I have to do is to create a controller first and after this I have to apply the service controller. I don´t know why but it works. Both steps together doesn´t.
Bye
Andy
Message was edited by: Andreas ChomaI e-mailed tech support and got my answer.
I should have been using /dev/rdsk and not /dev/dsk when specifying the disk slice to put the file system on. -
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,
RickyYou 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
YogeshHi 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 -
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.PHi 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
Maybe you are looking for
-
Hello All, I am trying to develop an XML form wherein Edit form i have an HTML editor and in Show form i want to display the message that in edited in Edit form. But when i run the Show form, i text is displayed like this: <FONT color=#242424><STRONG
-
Maybe not a Proper Fix for X-Fi sounds b
Well after this I'm applying to Creative to find a well payed job ***EDIT : I forgot to say that it was if you actually have already tried everything out (I mean all the fixes on the forum, the new drivers, change PCI slots, reinstalled windows+X-Fi
-
I currently am still using Snow Leopard because when I updated to Lion I did not like how it changed many of my apps., and or they would not work. I am thinking of getting a Apple laptop which would run on a newer OS, so I was wondering if my Pages a
-
Repeating Tables + CSS Borders On Cells
I'm having trouble getting borders to appear on cells in a repeating table. Is this a problem with templates in general, I can't seem to get it to work at all. Here's a snippet of code fwiw : <td width="233" align="center" valign="middle" class="3bor
-
Excel Macro "Memory exhausted"
I try to start an Excel Macro and everytime when i started it, comes a message like that: Solver: An unexspected internal error occurred, or available memory was exhausted" I try to start the Excel Solver Function with a macro from Labview. I use Exc