カスタムアクションの処理を実装するには、IActionHandler を実装するクラスを定義します。このクラスには、引数なしのコンストラクターが必要です。 package com.adobe.acm.solutions.authoring.domain.extensions
{
import com.adobe.icc.vo.CustomAction;
import flash.events.IEventDispatcher;
/**
* Interface for adding and handling custom actions in Extensible Toolbar.
* One instance of handler will be created for each action.
*/
public interface IActionHandler extends IEventDispatcher
{
/**
* Set action associated with this handler instance.
*/
function set action(value:CustomAction):void;
[Bindable(event="actionChange")]
/**
* Fetch action associated with this handler instance.
*/
function get action():CustomAction;
/**
* Set Flex Domain Model for on which the action is being taken
*/
function set model(value:*):void;
[Bindable(event="modelChange")]
/**
* Get Flex Domain Model for on which the action is being taken
*/
function get model():*;
/**
* Called when user user click an action
*/
function handleAction(extraParams:Object=null):void;
[Bindable(event="actionEnabledChange")]
/**
* Should the action be enabled in toolbar
*/
function actionEnabled(extraParams:Object=null):Boolean;
[Bindable(event="actionVisibleChange")]
/**
* Should the action be visible in toolbar
*/
function actionVisible(extraParams:Object=null):Boolean;
}
}
通信を作成は、[SDK]\riaservices\assetcomposer\10.0.0.0\flex フォルダーにある adobe-acm-ccr-domain-impl.swc の一部である IActionHandler com.adobe.acm.solutions.ccr.domain.extensions.CCRDefaultActionHandler のデフォルトの実装に付属しています。このクラスは、任意のカスタムアクションハンドラーによって拡張されます。実装を開始するには、Flash Builder で読み込まれた通信を作成ソリューションテンプレートの Flex プロジェクトを開き、必要なクラスをカスタムパッケージで作成します。
CCRDefaultActionHandler を拡張し、新しく追加されたアクションをサポートします。それには、次の 3 つが必要です。 新しく追加されたアクションを表示または非表示にするロジック。actionVisible(extraParams:Object=null):Boolean 関数をオーバーライドします。
新しく追加されたアクションを有効または無効にするロジック。actionEnabled(extraParams:Object=null):Boolean 関数をオーバーライドします。
ユーザーがボタンをクリックするときのアクションの処理。handleAction(extraParams:Object=null):void 関数の実装をオーバーライドします。
以下の com.adobe.solutions.cmg.ccr.custom.CCRCustomActionHandler のサンプル実装は、CCRDefaultActionHandler を拡張します。 package com.adobe.solutions.cmg.ccr.custom
{
import com.adobe.acm.solutions.ccr.domain.extensions.CCRDefaultActionHandler;
import com.adobe.icc.services.ServiceProvider;
import com.adobe.icc.services.submit.ISubmitService;
import com.adobe.icc.util.Debug;
import com.adobe.icc.util.UrlHelper;
import flash.display.DisplayObject;
import flash.events.Event;
import flash.net.URLRequest;
import flash.net.navigateToURL;
import mx.controls.Alert;
import mx.core.FlexGlobals;
import mx.managers.PopUpManager;
import mx.rpc.events.FaultEvent;
import mx.rpc.events.ResultEvent;
import mx.utils.ObjectUtil;
public class CCRCustomActionHandler extends CCRDefaultActionHandler
{
protected static const SEND_FOR_REVIEW:String = "sendForReview";
public var encodedString:String = "";
public var mailTo:String = "";
public function CCRCustomActionHandler()
{
super();
}
override public function handleAction(extraParams:Object=null):void
{
if(action.name == SEND_FOR_REVIEW)
{
//open the Send For Review Pop-up on click of newly added action
var addDocPopUp:SendForReviewPopUp = SendForReviewPopUp(PopUpManager.createPopUp(FlexGlobals.topLevelApplication as DisplayObject ,SendForReviewPopUp, true));
//sendforreview listens the 'onClose' event dispatched when user clicks on Send button in the Pop-up.
addDocPopUp.addEventListener('onClose',sendforreview);
//referencing to update the 'encodedString' and 'mailTo' variables when user clicks on Send button in the Pop-up.
addDocPopUp.ccrCustomObject = this;
}
}
override public function actionEnabled(extraParams:Object=null):Boolean
{
//can be customized as per user requirement
return true;
}
override public function actionVisible(extraParams:Object=null):Boolean
{
//Show the added button only when Letter is opened in Non-Preview mode.
return (invokeParams && !invokeParams.preview);
}
protected function sendforreview(ev:Event):void
{
var service:ISubmitService = ServiceProvider.getSubmitService();
var params:Object = new Object();
if(action.actionConfig)
params = ObjectUtil.copy(action.actionConfig);
//Add additional custom params here which will be available under <icc:meta> tag.
if(encodedString.length>0)
{
//the encodedString contains base64 encoded string of the supporting document attached
params["cm_supportDoc"] = encodedString;
}
params["cm_mailTo"] = mailTo;
var reload:Boolean = false;
if(!(invokeParams.letterId) && !(invokeParams.letterName))
{
//If Letter is loaded without letterName or letterId then it must be reload
reload = true;
}
//Invoke the default letter post process
service.submitLetterWithParams(letterVO, letterData,
false, invokeParams.useLatest, reload, null, params).addHandlers
(
// result handler
function(event:ResultEvent):void
{
var response:Object = event.result as Object;
//Redirect to success page if mentioned
if (response.redirect)
{
// redirect via new window or else the user will be prompted to close the DC window before proceeding
if (UrlHelper.isValid(response.redirect))
navigateToURL((new URLRequest(response.redirect)), "_blank");
else
Debug.error("server returned invalid redirect URL: " + response.redirect);
}
Alert.show('Letter Sent for Review - Successful');
},
// fault handler
function(event:FaultEvent):void
{
Debug.error("failed to send " + letterVO + ":\n\t", event);
Alert.show('Letter Sent for Review - Failed');
}
);
}
}
}
|
|
|