Legacy platform

Add mashups to the application-provided controllers

You can add mashups to the application-provided controllers.

Adding a mashup to the application-provided controllers is same as replacing a mashup for both InitController and BehaviorController.

For example, to add a mashup in InitController, the server-side XML for the InitController extension is as follows:
<?xml version="1.0" encoding="UTF-8"?>
<Controller controllerId="extn.home.portlets.OrderPortletExtnInitController"
	screenId="extn.home.portlets.OrderPortletExtn">
    <MashupRefs>
        <MashupRef mashupId="extn_orderPortlet_getOrganizationList"
            mashupRefId="extn_getOrganizationList" permissionId="" extnType="ADD"/>
    </MashupRefs>
</Controller>
The client-side definition of the InitController extension is as follows:
scDefine([
	"scbase/loader!dojo/_base/declare", 
	"scbase/loader!dojo/_base/kernel", 
	"scbase/loader!extn/home/portlets/OrderPortletExtn",
	"scbase/loader!sc/plat/dojo/controller/ExtnScreenController"
], function(
	_dojodeclare, 
	_dojokernel, 
	_extnOrderPortletExtn,
	_scExtnScreenController
) {
    return _dojodeclare("extn.home.portlets.OrderPortletExtnInitController", 
    [_scExtnScreenController], {
        screenId: 'extn.home.portlets.OrderPortletExtn',
        mashupRefs: [{
            sourceNamespace: 'extn_getOrganizationList_output',
            mashupRefId: 'extn_getOrganizationList',
            sequence: '',
            mashupId: 'extn_orderPortlet_getOrganizationList',
            sourceBindingOptions: '',
            extnType: 'ADD'
        }]
    });
});
The main differences between replacing an existing mashup and adding a mashup are as follows:
  • The value of the extnType attribute in server-side XML and client-side definition is set to ADD.

  • All the attributes for a mashup are defined.

  • The mashupRefId attribute starts with extn_ that does not match with any value in the application-provided screen

  • The mashupId attribute contains an application-provided mashup.

Whenever the mashup calls present in BehaviorController completes, the onExtnMashupCompletion event is raised in a screen extension. To get the handle after the completion of mashup call present in BehaviorController, define a local subscriber in the onExtnMashupCompletion event.

The following example illustrates how to define as local subscriber in the onExtnMashupCompletion event:
subscribers : {
local : [
	       {
	  				eventId: 'onExtnMashupCompletion',
					sequence: '51', 
					description: '',
					listeningControlUId: '',
					handler : {
							methodName : "handleOnExtnMashupCompletion" // name of the handler method
						}
			   }
			  ]
Add implementation for the handleOnExtnMashupCompletion hanlder handler method as follows:
handleOnExtnMashupCompletion: function(event, bEvent, ctrl, args)
{
	// add custom logic
}

The following table describes the data of the last argument (args):

Table 1. Data of the last argument (args)
Data of the last argument (args) Description
mashupContext Context of the mashup call.
mashupObject Mashup reference object when only one mashup is called.
mashupArray The list of mashup references when multiple mashups are called.
inputData The input data for the mashup call.
hasError If an error occurs on calling the mashup, the value is set to True.
errorData Contains the error-related data when an error occurs on calling the mashup.