Example: Inline data-based invocation

This approach needs the following customizations to the Solution Template, so that the Create Correspondence application can accept these parameters via a POST request:
  1. Modify the Create Correspondence JSP template. The Create Correspondence JSP File (@ CorrespondenceManagementSolutionTemplate/CreateCorrespondence/html-template/ccr.jsp) can be modified to accept these parameters and encode them as Flash variables that can then be read from within the Create Correspondence application. For example:
    // used from InvokeParams.as 
    String _PREFIX = "cm"; 
    String URLPARAM_LETTERID = _PREFIX + "LetterId"; 
    String URLPARAM_LETTERNAME = _PREFIX + "LetterName"; 
    String URLPARAM_LETTERVERSION = _PREFIX + "LetterVersion"; 
    String URLPARAM_USELATEST = _PREFIX + "UseLatest"; 
    String URLPARAM_USETESTDATA = _PREFIX + "UseTestData"; 
    String URLPARAM_DATA = _PREFIX + "Data"; 
    String URLPARAM_DATAURL = _PREFIX + "DataUrl"; 
    String URLPARAM_PREVIEW = _PREFIX + "Preview"; 
    // used from InvokeParams.as 
     
    String encodedFlashVars = "localeChain=" + localeChain; 
     
    String letterId = (String) request.getParameter(URLPARAM_LETTERID); 
    if (letterId != null && !"".equals(letterId)) 
        encodedFlashVars += "&" + URLPARAM_LETTERID + "=" + URLEncoder.encode(letterId); 
     
    String letterName = (String) request.getParameter(URLPARAM_LETTERNAME); 
    if (letterName != null && !"".equals(letterName)) 
        encodedFlashVars += "&" + URLPARAM_LETTERNAME + "=" + letterName; 
     
    String letterVersion = (String) request.getParameter(URLPARAM_LETTERVERSION); 
    if (letterVersion != null && !"".equals(letterVersion)) 
        encodedFlashVars += "&" + URLPARAM_LETTERVERSION + "=" + letterVersion; 
     
    String useLatest = (String) request.getParameter(URLPARAM_USELATEST); 
    if (useLatest != null && !"".equals(useLatest)) 
        encodedFlashVars += "&" + URLPARAM_USELATEST + "=" + useLatest; 
     
    String useTestData = (String) request.getParameter(URLPARAM_USETESTDATA); 
    if (useTestData != null && !"".equals(useTestData)) 
        encodedFlashVars += "&" + URLPARAM_USETESTDATA + "=" + useTestData; 
     
    String data = (String) request.getParameter(URLPARAM_DATA); 
    if (data != null && !"".equals(data)) 
        encodedFlashVars += "&" + URLPARAM_DATA + "=" + URLEncoder.encode(data); 
     
    String dataUrl = (String) request.getParameter(URLPARAM_DATAURL); 
    if (dataUrl != null && !"".equals(dataUrl)) 
        encodedFlashVars += "&" + URLPARAM_DATAURL + "=" + URLEncoder.encode(dataUrl); 
     
    String preview = (String) request.getParameter(URLPARAM_PREVIEW); 
    if (preview != null && !"".equals(preview)) 
        encodedFlashVars += "&" + URLPARAM_PREVIEW + "=" + preview;
  2. You can then capture the above encoded flash variables (string) in a JavaScript variable within the ccr jsp and pass it along as the flash variables to your application (SWF file):
    • JavaScript
      <script language="JavaScript" type="text/javascript"> 
      .... 
       
      var flashVarsStr = "<%= encodedFlashVars %>"; 
       
      ....
    • SWF loader
      .... 
          AC_FL_RunContent( 
                  "id",                     "ccrSwf", 
                  "name",                 "ccrSwf", 
                  "src",                     "${swf}", 
                  "flashVars",                             flashVarsStr, 
                  "width",                 "${width}", 
                  "height",                 "${height}", 
                  "align",                 "middle", 
                  "quality",                 "high", 
                  "bgcolor",                 "${bgcolor}", 
                  "wmode",                 dcWMode, 
                  "allowScriptAccess",    "sameDomain", 
                  "type",                 "application/x-shockwave-flash", 
                  "pluginspage",             "http://www.adobe.com/go/getflashplayer" 
          );
    • The ccr.jsp:
      <!-- saved from url=(0014)about:internet --> 
      <%@page import="java.util.*"%> 
      <%@page import="java.net.*"%> 
      <html lang="en"> 
      <!-- 
       * ADOBE SYSTEMS INCORPORATED 
       * ___________________________ 
       * 
       *  Copyright 2010 Adobe Systems Incorporated 
       *  All Rights Reserved. 
       * 
       * NOTICE:  All information contained herein is, and remains the property of Adobe Systems 
       * Incorporated and its suppliers, if any. The intellectual and technical concepts contained 
       * herein are proprietary to Adobe Systems Incorporated and its suppliers and may be covered 
       * by U.S. and Foreign Patents, patents in process, and are protected by trade secret or copyright 
       * law. Dissemination of this information or reproduction of this material is strictly forbidden 
       * unless prior written permission is obtained from Adobe Systems Incorporated. 
       // --> 
       
      <!-- 
      Smart developers always View Source. 
       
      This application was built using Adobe Flex, an open source framework 
      for building rich Internet applications that get delivered via the 
      Flash Player or to desktops via Adobe AIR. 
       
      Learn more about Flex at http://flex.org 
      // --> 
       
      <head> 
      <meta http-equiv="Content-Type" content="text/html; charset=utf-8" /> 
       
      <!--  BEGIN Browser History required section --> 
      <link rel="stylesheet" type="text/css" href="${history_css}" /> 
      <!--  END Browser History required section --> 
       
      <title>Create Correspondence</title> 
      <script src="/apps/solutions/cm/ccr/AC_OETags.js" language="javascript"></script> 
      <script src="/apps/solutions/cm/ccr/dcScript.js"  language="javascript"></script> 
      <!--  BEGIN Browser History required section --> 
      <script src="/apps/solutions/cm/ccr/history/history.js" language="javascript"></script> 
      <!--  END Browser History required section --> 
       
      <style> 
      body { 
          margin: 0px; 
          overflow: hidden 
      } 
      </style> 
      <script language="JavaScript" type="text/javascript"> 
       
      //CM specific params 
      var helpUrl="http://www.adobe.com/go/learn_dep_correspondence_management_10"; 
      var reconnectWaitDuration = "20"; 
       
      <!-- 
      // ----------------------------------------------------------------------------- 
      // Globals 
      // Major version of Flash required 
      var requiredMajorVersion = 10; 
      // Minor version of Flash required 
      var requiredMinorVersion = 2; 
      // Minor version of Flash required 
      var requiredRevision = 0; 
      // ----------------------------------------------------------------------------- 
      // --> 
       
      </script> 
      </head> 
       
      <body scroll="no" onresize="doOnResize()"> 
      <% 
          String acceptLang = request.getHeader("accept-language"); 
          if(acceptLang == null || "".equals(acceptLang.trim())) 
              acceptLang = "en-US"; 
          acceptLang = acceptLang.trim(); 
       
          String[] locales = acceptLang.split(","); 
          List localeChainList = new ArrayList(); 
          for(int i=0; i<locales.length; i++) 
          { 
              String locale =locales[i]; 
              if(locale.trim().startsWith("en") && !localeChainList.contains("en_US")) 
                  localeChainList.add("en_US"); 
              if(locale.trim().startsWith("de") && !localeChainList.contains("de_DE")) 
                  localeChainList.add("de_DE"); 
              if(locale.trim().startsWith("ja") && !localeChainList.contains("ja_JP")) 
                  localeChainList.add("ja_JP"); 
              if(locale.trim().startsWith("fr") && !localeChainList.contains("fr_FR")) 
                  localeChainList.add("fr_FR"); 
          } 
       
          String localeChain = ""; 
          if (localeChainList.isEmpty()) 
              localeChain = "en_US"; 
          else 
          { 
              StringBuilder sb = new StringBuilder(); 
              String delimiter =","; 
              for (int j=0; j<localeChainList.size(); j++) 
              { 
                  String x = (String)localeChainList.get(j); 
                  sb.append(x + delimiter); 
              } 
              sb.delete(sb.length()-delimiter.length(), sb.length()); 
           
              localeChain = sb.toString(); 
          } 
           
           
           // used from InvokeParams.as 
              String _PREFIX = "cm"; 
              String URLPARAM_LETTERID = _PREFIX + "LetterId"; 
              String URLPARAM_LETTERNAME = _PREFIX + "LetterName"; 
              String URLPARAM_LETTERVERSION = _PREFIX + "LetterVersion"; 
              String URLPARAM_USELATEST = _PREFIX + "UseLatest"; 
              String URLPARAM_USETESTDATA = _PREFIX + "UseTestData"; 
              String URLPARAM_DATA = _PREFIX + "Data"; 
              String URLPARAM_DATAURL = _PREFIX + "DataUrl"; 
              String URLPARAM_PREVIEW = _PREFIX + "Preview"; 
              // used from InvokeParams.as 
               
              String encodedFlashVars = "localeChain=" + localeChain; 
               
              String letterId = (String) request.getParameter(URLPARAM_LETTERID); 
              if (letterId != null && !"".equals(letterId)) 
                  encodedFlashVars += "&" + URLPARAM_LETTERID + "=" + URLEncoder.encode(letterId); 
               
              String letterName = (String) request.getParameter(URLPARAM_LETTERNAME); 
              if (letterName != null && !"".equals(letterName)) 
                  encodedFlashVars += "&" + URLPARAM_LETTERNAME + "=" + letterName; 
                   
              String letterVersion = (String) request.getParameter(URLPARAM_LETTERVERSION); 
              if (letterVersion != null && !"".equals(letterVersion)) 
                  encodedFlashVars += "&" + URLPARAM_LETTERVERSION + "=" + letterVersion; 
                   
              String useLatest = (String) request.getParameter(URLPARAM_USELATEST); 
              if (useLatest != null && !"".equals(useLatest)) 
                  encodedFlashVars += "&" + URLPARAM_USELATEST + "=" + useLatest; 
                   
              String useTestData = (String) request.getParameter(URLPARAM_USETESTDATA); 
              if (useTestData != null && !"".equals(useTestData)) 
                  encodedFlashVars += "&" + URLPARAM_USETESTDATA + "=" + useTestData; 
                   
              String data = (String) request.getParameter(URLPARAM_DATA); 
              if (data != null && !"".equals(data)) 
                  encodedFlashVars += "&" + URLPARAM_DATA + "=" + URLEncoder.encode(data); 
                   
              String dataUrl = (String) request.getParameter(URLPARAM_DATAURL); 
              if (dataUrl != null && !"".equals(dataUrl)) 
                  encodedFlashVars += "&" + URLPARAM_DATAURL + "=" + URLEncoder.encode(dataUrl); 
                   
              String preview = (String) request.getParameter(URLPARAM_PREVIEW); 
              if (preview != null && !"".equals(preview)) 
              encodedFlashVars += "&" + URLPARAM_PREVIEW + "=" + preview; 
           
           
           
           
      %> 
       
      <script language="JavaScript" type="text/javascript"> 
      <!-- 
      var flashVarsStr = "<%= encodedFlashVars %>"; 
       
       
      // the windowPreExitHandler() function, defined in dcScript.js, is called when the Browser window is closed 
      window.onbeforeunload = windowPreExitHandler; 
       
      // fix-up for Safari PDF display that still allows accessibility under IE 
      var dcWMode = "window"; 
      if (navigator.userAgent.indexOf("IE") >= 0 || 
          navigator.userAgent.indexOf("Safari")  >= 0) 
          dcWMode = "transparent"; 
       
       
       
      // Version check for the Flash Player that has the ability to start Player Product Install (6.0r65) 
      var hasProductInstall = DetectFlashVer(6, 0, 65); 
       
      // Version check based upon the values defined in globals 
      var hasRequestedVersion = DetectFlashVer(requiredMajorVersion, requiredMinorVersion, requiredRevision); 
       
       
      if ( hasProductInstall && !hasRequestedVersion ) 
      { 
          // DO NOT MODIFY THE FOLLOWING FOUR LINES 
          // Location visited after installation is complete if installation is required 
          var MMPlayerType = (isIE == true) ? "ActiveX" : "PlugIn"; 
          var MMredirectURL = window.location; 
          document.title = document.title.slice(0, 47) + " - Flash Player Installation"; 
          var MMdoctitle = document.title; 
       
          AC_FL_RunContent( 
              "id",                     "ccrSwf", 
              "name",                 "ccrSwf", 
              "src",                     "playerProductInstall", 
              "FlashVars",             "MMredirectURL="+MMredirectURL+'&MMplayerType='+MMPlayerType+'&MMdoctitle='+MMdoctitle+"", 
              "width",                 "100%", 
              "height",                 "100%", 
              "align",                 "middle", 
              "quality",                 "high", 
              "bgcolor",                 "#869ca7", 
              "wmode",                 dcWMode, 
              "allowScriptAccess",    "sameDomain", 
              "type",                 "application/x-shockwave-flash", 
              "pluginspage",             "http://www.adobe.com/go/getflashplayer" 
          ); 
      } 
      else if (hasRequestedVersion) 
      { 
          AC_FL_RunContent( 
                  "id",                     "ccrSwf", 
                  "name",                 "ccrSwf", 
                  "src",                     "/apps/solutions/cm/ccr/index", 
                  "flashVars",                 flashVarsStr, 
                  "width",                 "100%", 
                  "height",                 "100%", 
                  "align",                 "middle", 
                  "quality",                 "high", 
                  "bgcolor",                 "#869ca7", 
                  "wmode",                 dcWMode, 
                  "allowScriptAccess",    "sameDomain", 
                  "type",                 "application/x-shockwave-flash", 
                  "pluginspage",             "http://www.adobe.com/go/getflashplayer" 
          ); 
      } 
      else        // Flash Player version is too old or we can't detect the plug-in 
      { 
          var alternateContent = '' 
                + 'This content requires the Adobe Flash Player. ' 
                 + '<a href=http://www.adobe.com/go/getflash/>Get Flash</a>'; 
          document.write(alternateContent);  // insert non-Flash content 
      } 
       
      <!-- Add the division that will contain the PDF --> 
      document.write("<div id='divContainingIFrame' style='position: absolute; border: 2px; visibility: visible;'><object width='1' height='1' type='application/pdf' data='/apps/solutions/cm/ccr.pdf' /></div>"); 
      // --> 
      </script> 
       
      <noscript> 
          <br/><br/><br/><br/> 
          <p>This web page requires that your browser have scripting enabled.</p> 
          <p>Please enable scripting, and/or contact your system administrator.</p> 
      </noscript> 
       
      </body> 
      </html>
  3. Modify the Create Correspondence main application ActionScript. Modify the Create Correspondence application ActionScript class (@ CorrespondenceManagementSolutionTemplate/CreateCorrespondence/src/main/flex/com/adobe/solutions/cmg/ccr/presentation/CCRApplication.as) to accept the Flash variables and populate/initialize the InvokeParams for the Create Correspondence application. After the InvokeParams has been instantiated, you could load/override the parameters from what's passed in the Flash variables
    .... 
    invocationParams = new InvokeParams(htmlUrl); // load the params from what's in the URL 
                 
    // now load the params from what's been POSTed - perference is given to the POST data (if present), so as to reject anything that the user tries to override from the URL  
    buildInvocationParamsFromRequest(invocationParams); 
    ....             
     
    } 
     
    private function _buildInvocationParamsFromRequest(invocationParams:InvokeParams):void 
            { 
                var letterId:String = FlexGlobals.topLevelApplication.parameters[InvokeParams.URLPARAM_LETTERID]; 
                if (letterId && letterId.length > 0) 
                    invocationParams.letterId = letterId; 
                 
                var letterName:String = FlexGlobals.topLevelApplication.parameters[InvokeParams.URLPARAM_LETTERNAME]; 
                if (letterName && letterName.length > 0) 
                    invocationParams.letterName = letterName; 
                 
                var letterVersion:String = FlexGlobals.topLevelApplication.parameters[InvokeParams.URLPARAM_LETTERVERSION]; 
                if (letterVersion && letterVersion.length > 0) 
                    invocationParams.letterVersion = parseInt(letterVersion); 
                 
                var useLatest:String = FlexGlobals.topLevelApplication.parameters[InvokeParams.URLPARAM_USELATEST]; 
                if (useLatest && useLatest.length > 0) 
                    invocationParams.useLatest = (parseInt(useLatest) != 0); 
                 
                var useTestData:String = FlexGlobals.topLevelApplication.parameters[InvokeParams.URLPARAM_USETESTDATA]; 
                if (useTestData && useTestData.length > 0) 
                    invocationParams.useTestData = (parseInt(useTestData) != 0); 
                 
                var data:String = FlexGlobals.topLevelApplication.parameters[InvokeParams.URLPARAM_DATA]; 
                if (data && data.length > 0) 
                    invocationParams.xmlData = XML(data); 
                 
                var dataUrl:String = FlexGlobals.topLevelApplication.parameters[InvokeParams.URLPARAM_DATAURL]; 
                if (dataUrl && dataUrl.length > 0) 
                    invocationParams.dataUrl = dataUrl; 
                 
                var preview:String = FlexGlobals.topLevelApplication.parameters[InvokeParams.URLPARAM_PREVIEW]; 
                if (preview && preview.length > 0) 
                    invocationParams.preview = (parseInt(preview) != 0); 
                 
            }
  4. Copy the ccr.jsp to ccr.POST.jsp. To allow POST method-based URL resolution, create a copy of the file CorrespondenceManagementSolutionTemplate\CreateCorrespondence\html-template\ccr.jsp as ccr.POST.jsp at the same location.

  5. Rebuild and redeploy the Solution template to view the changes. For information on rebuilding and redeploying, see Building and deploying the Solution Template.

With these changes, your application can handle a POST-based data submission.

Note: For POST-based data submission, authenticate the session with CRX before initiating the Post invocation request. To do so, deploy/create the custom portal page in CRX and deny jcr:read permission to anonymous users for this node.

// Ethnio survey code removed