Implementation overview

Extend the Action Handler:
  1. In Flash Builder, open the CreateCorrespondence project in the Package Explorer view.

  2. Navigate to CreateCorrespondence > src > com.adobe.solutions.cmg.Create Correspondence > presentation

  3. Create ActionScript class, such as SaveAsDraftActionHandler, which extends the com.adobe.acm.solutions.ccr.domain.extensions.CCRDefaultActionHandler class. To support the newly added action, two things are required:

    1. The logic for enabling/disabling newly added action, by overriding the function actionEnabled(extraParams:Object=null):Boolean.

    2. The handling of action when user clicks the button when overriding the implementation for function handleAction(extraParams:Object=null):void

      The following example is a sample Implementation of com.adobe.solutions.cmg.ccr.presentation.SaveAsDraftActionHandler that extends CCRDefaultActionHandler. :
      package com.adobe.solutions.cmg.ccr.presentation 
      { 
          import com.adobe.acm.solutions.ccr.domain.extensions.CCRDefaultActionHandler; 
          import com.adobe.icc.external.dc.ExternalApi; 
          import com.adobe.icc.external.dc.InvokeParams; 
          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.net.URLRequest; 
          import flash.net.navigateToURL; 
           
              import mx.controls.Alert; 
          import mx.rpc.events.FaultEvent; 
          import mx.rpc.events.ResultEvent; 
          import mx.utils.ObjectUtil; 
           
          public class SaveAsDraftActionHandler extends CCRDefaultActionHandler 
          { 
              public static const SAVE_AS_DRAFT_ACTION:String = "SaveAsDraft"; 
               
              public function SaveAsDraftActionHandler() 
              { 
                  super(); 
                  var htmlUrl:String = ExternalApi.getInstance().htmlGetUrl(); 
                  Debug.info("invoke url: " + htmlUrl); 
                  invokeParams = new InvokeParams(htmlUrl); 
                   
              } 
               
              /** 
               * Called when the user clicks an action 
               * @param extraParams additional arguments that may be passed to handler (For future use) 
               * 
               */ 
              override public function handleAction(extraParams:Object=null):void 
              { 
                  if(action && action.name == SAVE_AS_DRAFT_ACTION) 
                  { 
                      //Additional logic to show popup to ask file save name goes here. 
                      var saveName:String = letterVO.name; 
                      submitLetter(saveName); 
                  } 
              } 
               
              [Bindable(event="actionEnabledChange")] 
              /** 
               * Should the action be enabled in toolbar 
               * @param extraParams 
               * @return flag indicating whether the action should be enabled 
               * 
               */ 
              override public function actionEnabled(extraParams:Object=null):Boolean 
              { 
                  //Always enable the Action. 
                  return true; 
              } 
               
              private function submitLetter(saveName: String):void 
              { 
                  var service:ISubmitService = ServiceProvider.getSubmitService(); 
                   
                  var params:Object = new Object(); 
                  if(action.actionConfig) 
                      params = ObjectUtil.copy(action.actionConfig); 
                  params["cm_actionName"] = action.name; 
                  //Add additional custom params here which is available under <icc:meta> tag. 
                  params["cm_saveName"] = saveName; 
                   
                  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 is 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("Save Successful"); 
                          }, 
                          // fault handler 
                          function(event:FaultEvent):void 
                          { 
                              Debug.error("failed to submit " + letterVO + ":\n\t", event); 
                                                      Alert.show("Save Failed"); 
       
                          } 
                      ); 
                   
              } 
          } 
      }
  4. Declare a private variable of type SaveAsDraftActionHandler in the file CreateCorrespondence > src > com.adobe.solutions.cmg.Create Correspondence > presentation > CCRApplication.as. This variable is to ensure that the new class gets compiled in FlashBuilder.

    private var saveActionHandler:SaveAsDraftActionHandler;
  5. Modifying the acmExtensionsConfig.xml to add the custom action button. The modelExtension tag in the CorrespondenceManagementSolutionTemplate\package-resources\etc\aep\config\assetcomposer\apps\cm\acmExtensions\acmExtensionsConfig.xmlcan have a set of customAction child tags associated with it. Each customAction element represents an Action that would show up in the Create Correspondence user interface toolbar depending upon the permissions associated with it. Each can have attributes to allow configuration for that action. The attributes are listed below:

    Name

    Description

    name

    The alphanumeric name for the action that must start with a character. Name is required param and must be unique within the modelExtensions tag.

    label

    The label to display on the action button. This property can be localized.

    tooltip

    The tool tip for the action. This property can be localized.

    styleName

    The name of the custom style that is applied to the action button that is packaged as part of Solution Template application.

    permissionName

    The corresponding action is shown only if user has the permission specified by permissionName.

    actionHandler

    Fully qualified name of the ActionHandler class which is called when user clicks the action. This class must implement IActionHandler interface. The class must have a no-argument constructor.

  6. Add the Special Additional Configuration Parameters in Extensions Config:
    • serviceName: If a customAction contains a child tag with name serviceName. On click of that action a process is called with the name represented by serviceName tag. This process has same signature that of Letter PostProcess.

    • Parameters containing cm_ prefix in tag name: If a customAction contains child tags starting with name cm_, then in post process these parameters are available in the input xml under <icc:meta> tag with cm_ prefix removed.

    • actionName: Whenever a post process is called as a result of action click, the submitted xml contains a special tag with name <actionName> under <icc:meta> tag containing the name of the action taken by user.

  7. In this example to add the SaveAsDraft button, modify the CorrespondenceManagementSolutionTemplate\package-resources\etc\aep\config\assetcomposer\apps\cm\acmExtensions\acmExtensionsConfig.xml and add customAction element corresponding to SaveAsDraft. The name of the called LiveCycle process can be mentioned in the <servicename> tag. For example, in this case clicking the SaveAsDraft button calls the LiveCycle process with the name SaveLetterDraft/SaveLetterDraftProcess. The path where the correspondence is saved can be mentioned in the <cm_path> tag. The following code snippet is an example of the new action element:
    <?xml version="1.0" encoding="utf-8"?> 
    <extensionsConfig> 
        <modelExtensions> 
            <modelExtension type="LetterInstance"> 
                <customAction name="Submit" label="loc.letterInstance.submit.label" tooltip="loc.letterInstance.submit.tooltip" styleName="submitButton" permissionName="CM Letter Template Submit"/> 
                <customAction name="Close" label="loc.letterInstance.close.label" tooltip="loc.letterInstance.close.tooltip" styleName="closeButton"/> 
                <customAction name="SaveAsDraft" label="SaveAsDraft" tooltip="SaveAsDraft"  styleName="closeButton" actionHandler="com.adobe.solutions.cmg.ccr.presentation.SaveAsDraftActionHandler"> 
                    <serviceName>SaveLetterDraft/SaveLetterDraftProcess</serviceName> 
                        <cm_path>d:\savedCorrespondence\</cm_path> 
                </customAction>    
            </modelExtension> 
        </modelExtensions> 
    </extensionsConfig>
  8. Rebuild and redeploy the Solution template to view the changes. For information on rebuilding and redeploying, see Building and deploying the Solution Template

The bottom toolbar in the Create Correspondence user interface now includes a new SaveAsDraft button. Clicking this button saves the correspondence in XML format. The name of the saved file is the letter name with the xml extension. You can enhance it to show a pop-up to capture the save filename by adding the functionality in handleAction function in the SaveAsDraftActionHandler.as.

To reload the saved correspondence type the following URL to the published instance in the browser: http://<hostname>:<port>/content/cm/createcorrespondence.html?cmDataUrl=file:///<filepath>/ClaimSubrogation.xml&cmUseLatest=1.

The SaveAsDraft is only applicable on published instances.

// Ethnio survey code removed