LCDS2.6不再集成webtier方式的集成(动态访问mxml和jsp嵌入mxml的tag)。需要通过集成webtier.war来处理

来源:互联网 发布:阿sa和郑中基 知乎 编辑:程序博客网 时间:2024/04/27 11:15
下文是webtier.war的使用方法。
下载地址 http://flexorg.wip3.adobe.com/modules/latest/FlexModule_j2ee.zip
  1. This readme.txt file describes the Flex 3 compiler module for J2EE application servers.
  2. *******************************
  3. *   Introduction              *
  4. *******************************
  5. The Flex compiler module for J2EE application servers is a Web Application aRchive (WAR) file that you can deploy 
  6. to most J2EE application servers that support servlets. This lets you rapidly compile, 
  7. test, and deploy an application: Instead of compiling your MXML file into a SWF file and 
  8. then deploying it and its wrapper files on a web server, you can just refresh the MXML 
  9. file in your browser.
  10. The Flex compiler module for J2EE application servers also provides a JSP tag library 
  11. that lets you write Flex applications in JSPs.
  12. The Flex compiler module for J2EE application is not for production use. The Flex compiler 
  13. module web application should not be made available on a public-facing web server.
  14. *******************************
  15. *   Requirements              *
  16. *******************************
  17. The Flex compiler module for J2EE application servers comes as a WAR file. You can deploy 
  18. it to any of the following J2EE web application servers:
  19.  * Adobe JRun 4 Updater 7
  20.  * Apache Tomcat 6.0.x
  21.  * IBM WebSphere 6.1.x € IBM 1.5
  22.  * BEA WebLogic 10 € Sun 1.5
  23.  * JBoss 4.2.x
  24.  
  25. *******************************
  26. *   Installation              *
  27. *******************************
  28. To install the Flex compiler module for J2EE application servers, create an application root 
  29. directory and extract the contents of the WAR file into that directory. Your application server
  30. might have a facility for deploying WAR files that you should use. After you deploy the WAR file,
  31. restart your application server.
  32. For example, on Tomcat, create a new directory under the {tomcat_install_dir}/webapps directory 
  33. and expand the WAR file into that new directory. Save your MXML and JSP files in that directory.
  34. *******************************
  35. *   Configuration             *
  36. *******************************
  37. The Flex compiler module for J2EE application servers uses the following configuration files:
  38. WEB-INF/flex-config.xml 
  39. Defines the default settings for the Flex compiler.
  40. WEB-INF/flex-webtier-config.xml 
  41. Defines settings specific to the web tier, such as logging, caching, and debugging.
  42. WEB-INF/web.xml 
  43. Defines the web component settings for the Flex web application, such as servlet definitions 
  44. and mappings, and tag library definitions.
  45. To use custom SWC files or ActionScript classes in your applications, add them to the 
  46. WEB-INF/flex/user-classes directory. 
  47. If you want to use data visualization components in your Flex applications, add the appropriate 
  48. SWC files to the WEB-INF/flex/libs directory.
  49. ****************************************************************
  50. *   Integrating with LiveCycle Data Services ES 2.6 or BlazeDS *
  51. ****************************************************************
  52. LiveCycle Data Services ES 2.6 and BlazeDS do not include an integrated web tier compiler, but you can easily integrate the Flex compiler module for J2EE into a LiveCycle Data Services ES or BlazeDS web application.
  53.    1. Unzip the webtier.war file to a directory called webtier.
  54.    2. Copy all of the files in the webtier/WEB-INF/lib to to the corresponding WEB-INF/lib directory of your LiveCycle Data Service ES web application. Do not overwrite any existing files.
  55.    3. Make a backup copy of the services-config.xml file WEB-INF/flex directory of your LiveCycle Data Service ES web application.
  56.    3. With the exception of the services-config.xml file, copy all of the files and directories in the webtier/WEB-INF/flex directory to the corresponding WEB-INF/flex directory of your LiveCycle Data Service ES web application. Do not overwrite any existing files. In the event that you accidentally overwrite the services-config.xml file in your web application, restore it using the backup copy you created.
  57.    4. Copy the player and locale directories as well as the datavisualization.swc file from the LiveCycle Data Services ES or BlazeDS install_root/resources/frameworks/libs directory to the WEB-INF/flex/libs directory of your LiveCycle Data Service ES web application.
  58.    5. From the following web.xml sample content, add the text contained between
  59.    <!-- start from webtier web.xml -->
  60.    and
  61.    <!-- end from webtier web.xml -->
  62.    to the web.xml file in the WEB-INF directory of your LiveCycle Data Service ES or BlazeDS web application:
  63. <?xml version="1.0" encoding="UTF-8"?>
  64.  <!DOCTYPE web-app PUBLIC "-//Sun Microsystems, Inc.//DTD Web Application 2.3//EN" "http://java.sun.com/dtd/web-app_2_3.dtd">
  65. <web-app>
  66.    <display-name>LiveCycle Data Services Samples</display-name>
  67.    <description>LiveCycle Data Services Application with Samples</description>
  68.    
  69.    <!-- start from webtier web.xml -->
  70.  <context-param>
  71.  <param-name>flex.class.path</param-name>
  72.  <param-value>/WEB-INF/flex/hotfixes,/WEB-INF/flex/jars</param-value>
  73.  </context-param>
  74.  <!-- end from webtier web.xml --> 
  75.  <!-- Http Flex Session attribute and binding listener support -->
  76.    <listener>
  77.    <listener-class>flex.messaging.HttpFlexSession</listener-class>
  78.    </listener>
  79.  <!-- MessageBroker Servlet -->
  80.    <servlet>
  81.    <servlet-name>MessageBrokerServlet</servlet-name>
  82.    <display-name>MessageBrokerServlet</display-name>
  83.    <servlet-class>flex.messaging.MessageBrokerServlet</servlet-class>
  84.    <init-param>
  85.    <param-name>services.configuration.file</param-name>
  86.    <param-value>/WEB-INF/flex/services-config.xml</param-value>
  87.    </init-param>
  88.    <load-on-startup>1</load-on-startup>
  89.    </servlet>
  90.    
  91.    <servlet>
  92.    <servlet-name>PDFResourceServlet</servlet-name>
  93.    <display-name>Helper for retrieving dynamically generated PDF documents.</display-name>
  94.    <servlet-class>flex.samples.pdfgen.PDFResourceServlet</servlet-class>
  95.    </servlet>
  96.    
  97.    <!-- start from webtier web.xml -->
  98.  <servlet>
  99.  <servlet-name>FlexMxmlServlet</servlet-name>
  100.  <display-name>MXML Processor</display-name>
  101.  <description>Servlet wrapper for the Mxml Compiler</description>
  102.  <servlet-class>flex.bootstrap.BootstrapServlet</servlet-class>
  103.  <init-param>
  104.  <param-name>servlet.class</param-name>
  105.  <param-value>flex.webtier.server.j2ee.MxmlServlet</param-value>
  106.  </init-param>
  107.  <init-param>
  108.  <param-name>webtier.configuration.file</param-name>
  109.  <param-value>/WEB-INF/flex/flex-webtier-config.xml</param-value>
  110.  </init-param>
  111.  <load-on-startup>1</load-on-startup>
  112.  </servlet>
  113.  <servlet>
  114.  <servlet-name>FlexSwfServlet</servlet-name>
  115.  <display-name>SWF Retriever</display-name>
  116.  <servlet-class>flex.bootstrap.BootstrapServlet</servlet-class>
  117.  <init-param>
  118.  <param-name>servlet.class</param-name>
  119.  <param-value>flex.webtier.server.j2ee.SwfServlet</param-value>
  120.  </init-param>
  121.  <!-- SwfServlet must be initialized after MxmlServlet -->
  122.  <load-on-startup>2</load-on-startup>
  123.  </servlet>
  124.  <servlet>
  125.  <servlet-name>FlexForbiddenServlet</servlet-name>
  126.  <display-name>Prevents access to *.as/*.swc files</display-name>
  127.  <servlet-class>flex.bootstrap.BootstrapServlet</servlet-class>
  128.  <init-param>
  129.  <param-name>servlet.class</param-name>
  130.  <param-value>flex.webtier.server.j2ee.ForbiddenServlet</param-value>
  131.  </init-param>
  132.  </servlet>
  133.  <servlet>
  134.  <servlet-name>FlexInternalServlet</servlet-name>
  135.  <servlet-class>flex.bootstrap.BootstrapServlet</servlet-class>
  136.  <init-param>
  137.  <param-name>servlet.class</param-name>
  138.  <param-value>flex.webtier.server.j2ee.filemanager.FileManagerServlet</param-value>
  139.  </init-param>
  140.  <load-on-startup>10</load-on-startup>
  141.  </servlet>
  142.  <!-- end from webtier web.xml --> 
  143.    
  144.    <servlet-mapping>
  145.    <servlet-name>MessageBrokerServlet</servlet-name>
  146.    <url-pattern>/messagebroker/*</url-pattern>
  147.    </servlet-mapping>
  148.  <servlet-mapping>
  149.    <servlet-name>PDFResourceServlet</servlet-name>
  150.    <url-pattern>/dynamic-pdf/*</url-pattern>
  151.    </servlet-mapping>
  152. <!-- start from webtier web.xml --> 
  153.  <servlet-mapping>
  154.  <servlet-name>FlexMxmlServlet</servlet-name>
  155.  <url-pattern>*.mxml</url-pattern>
  156.  </servlet-mapping>
  157.  <servlet-mapping>
  158.  <servlet-name>FlexSwfServlet</servlet-name>
  159.  <url-pattern>*.swf</url-pattern>
  160.  </servlet-mapping>
  161.  <servlet-mapping>
  162.  <servlet-name>FlexForbiddenServlet</servlet-name>
  163.  <url-pattern>*.as</url-pattern>
  164.  </servlet-mapping>
  165.  <servlet-mapping>
  166.  <servlet-name>FlexForbiddenServlet</servlet-name>
  167.  <url-pattern>*.swc</url-pattern>
  168.  </servlet-mapping>
  169.  <servlet-mapping>
  170.  <servlet-name>FlexInternalServlet</servlet-name>
  171.  <url-pattern>/flex-internal/*</url-pattern>
  172.  </servlet-mapping>   
  173.  <!-- end from webtier web.xml --> 
  174. <welcome-file-list>
  175.    <welcome-file>index.html</welcome-file>
  176.    <welcome-file>index.htm</welcome-file>
  177.    </welcome-file-list>
  178. <!-- for WebSphere deployment, please uncomment -->
  179.    <!--
  180.    <resource-ref>
  181.    <description>Flex Messaging WorkManager</description>
  182.    <res-ref-name>wm/MessagingWorkManager</res-ref-name>
  183.    <res-type>com.ibm.websphere.asynchbeans.WorkManager</res-type>
  184.    <res-auth>Container</res-auth>
  185.    <res-sharing-scope>Shareable</res-sharing-scope>
  186.    </resource-ref>
  187.    -->
  188.  <!--
  189.    <security-constraint>
  190.    <web-resource-collection>
  191.    <web-resource-name>Protected Sample</web-resource-name>
  192.  <url-pattern>/messagebroker/amf/SampleSalaryRO</url-pattern>
  193.    <http-method>GET</http-method>
  194.    <http-method>POST</http-method>
  195.    </web-resource-collection>
  196.  <auth-constraint>
  197.    <role-name>sampleusers</role-name>
  198.    </auth-constraint>
  199.    </security-constraint>
  200.    -->
  201.  <login-config>
  202.    <auth-method>BASIC</auth-method>
  203.    </login-config>
  204.  <!--
  205.    <security-role>
  206.    <role-name>sampleusers</role-name>
  207.    </security-role>
  208.    -->
  209.    
  210.    <!-- start from webtier web.xml --> 
  211.  <taglib>
  212.  <taglib-uri>FlexTagLib</taglib-uri>
  213.  <taglib-location>/WEB-INF/lib/flex-bootstrap-jsp.jar</taglib-location>
  214.  </taglib>
  215.  <!-- end from webtier web.xml -->
  216. </web-app>
  217. *******************************
  218. *   About the JSP Tag Library *
  219. *******************************
  220. The Flex 3 Tag Library for JSP is a set of JSP tags that you use to embed Flex applications 
  221. in a JSP page. You should use the Flex 3 Tag Library for JSP to do any of the following:
  222.  * Include an MXML (Flex) application in an existing HTML/JSP page.
  223.  * Include history management, player detection, or Express Install for one application but 
  224.  not another application.
  225.  * Present an MXML application if the correct version of the Adobe Flash Player is installed, 
  226.  or an HTML version otherwise.
  227.  * Present one of a few versions of the same basic application determined through logic in a 
  228.  JSP page. 
  229. The <mxml> tag compiles the MXML code, if required, and then generates the HTML fragment to 
  230. load Adobe Flash Player and the resulting SWF file in your JSP page. You can do this in two 
  231. ways. The source tag attribute lets you specify the source file to compile. This is useful 
  232. because the JSP tag writes the HTML fragment for you. The other approach is to specify the 
  233. source as the body content of the tag. Then, you use JSP scriptlets to generate the MXML source.
  234. The <flashvar> tag lets you pass variables to a Flex application. You access these variables 
  235. by using the Application.application.parameters object.
  236. Although the Flex 3 Tag Library for JSP is similar to the tag library in earlier versions of 
  237. Flex, there are some differences. The tag attributes of the <mxml> tag are simpler; full 
  238. control of all the HTML wrapper attributes is no longer available. However, the tag library 
  239. includes attributes that enable history management and Flash Player detection on a per-tag basis. 
  240. The <param> and <flash> tags were eliminated to simplify tag usage. 
  241. *******************************
  242. *  Using the JSP Tag Library  *
  243. *******************************
  244. To use the Flex 3 Tag Library in a JSP page, add the following tag library declaration 
  245. to your JSP page:
  246. <%@ taglib uri="FlexTagLib" prefix="mm" %>
  247. As with any JSP taglib directive, this line must appear before you use any tags in the 
  248. Flex JSP tag library.
  249. You can then use the <mxml> tag to insert a Flex application in the JSP page. You can 
  250. either reference a separate MXML file to be included in the JSP page, or you can add the MXML 
  251. syntax directly in the JSP page.
  252. The following example shows the <mxml> tag with the source attribute to include an external 
  253. MXML file:
  254. <mm:mxml source="CustomerServiceChat.mxml"/>
  255. Alternatively, you can use the <mxml> tag with inline MXML source code, as the following 
  256. example shows:
  257. <mm:mxml>
  258.     <mx:Application xmlns:mx="http://www.adobe.com/2006/mxml" xmlns="*">
  259.         <mx:Text label="Hello World">
  260.     </mx:Application>
  261. </mm:mxml>
  262. Use the <mxml> tag carefully, as any JSP execution that results in different MXML source 
  263. code causes recompilation. Each distinct instance of MXML source code is cached separately 
  264. and checked for recompilation separately.
  265. For example, the following JSP code results in two sets of MXML source code; one is 
  266. created when request.isUserInRole("admin") is true, and another is created when 
  267. request.isUserInRole("admin") is false:
  268. <mm:mxml>
  269.     <mx:Application xmlns:mx="http://www.adobe.com/2006/mxml" xmlns="*">
  270.         <% if (request.isUserInRole("admin")) { %>
  271.             <AdminConsole/>
  272.         <% } else { %>
  273.             <UserConsole/>
  274.         <% } %>
  275.     </mx:Application>
  276. </mm:mxml>
  277. Updating the <flashvar> tag does not cause a recompilation. 
  278. You can mix JSP scriptlets with MXML to create a dynamic application. The following example 
  279. uses <mxml> and <flashvar> tags with inline MXML code to get the Java version and current date:
  280. <%@ taglib uri="FlexTagLib" prefix="mm" %>
  281. <mm:mxml height="300" width="600" usePlayerDetection="true" useExpressInstall="false">
  282.     <mm:flashvar name="javaVersion" value='<%= System.getProperty("java.version") %>'/>
  283.     <mm:flashvar name="currentDate" value="<%= new java.util.Date().toString() %>"/>
  284.     <mx:Application xmlns:mx="http://www.adobe.com/2006/mxml" width="400" height="300">
  285.         <mx:VBox>
  286.             <mx:HBox>
  287.                 <mx:Label text="Java version: "/>
  288.                 <mx:Label text="{Application.application.parameters.javaVersion}" fontWeight="bold"/>
  289.             </mx:HBox>
  290.             <mx:HBox>
  291.                 <mx:Label text="Current Time: "/>
  292.                 <mx:Label text="{Application.application.parameters.currentDate}" fontWeight="bold"/>
  293.             </mx:HBox>
  294.         </mx:VBox>
  295.     </mx:Application>
  296. </mm:mxml>
  297. The following example shows how to invoke an external MXML file while passing dynamic 
  298. flashvar variables to it:
  299. <%@ taglib uri="FlexTagLib" prefix="mm" %>
  300. <mm:mxml source="flashvarTest.mxml" width="400" height="200">
  301.     <mm:flashvar name="javaVersion" value='<%= System.getProperty("java.version") %>'/>
  302.     <mm:flashvar name="currentDate" value="<%= new java.util.Date().toString() %>"/>
  303. </mm:mxml>
  304. You can use the <mxml> tag attributes to enforce the use of a minimum Flash Player version. 
  305. You can return one version of a Flex application when the required version of Flash Player 
  306. is available, or an alternate version of the application when the required Player is unavailable. 
  307. You can also use the <mxml> tag to set up Express Install so that clients that do not have 
  308. the minimum required Player are prompted to install it.
  309. You set the minimum required version in the <flash-player> in the flex-webtier-config.xml 
  310. file.
  311. The following example enables Flash Player Detection but disables Express Install. With this 
  312. configuration, the server returns the alternateContentPage instead of proceeding to upgrade 
  313. Flash Player through Express Install if the client does not have the minimum required Player 
  314. version.
  315. <mm:mxml 
  316.     source="FlexApplication.mxml" 
  317.     usePlayerDetection="true" 
  318.     useExpressInstall="false" alternateContentPage="MyLegacyApplication.html"
  319. />
  320. *******************************
  321. *   Tag Descriptions          *
  322. *******************************
  323. <mxml>    
  324. Compiles the MXML code and generates the HTML wrapper. Includes MXML source as body content, 
  325. or specify an external source file with the source attribute.  
  326. The <mxml> tag has the following attributes:
  327.  
  328.  * source - Location of the MXML code to compile.
  329.  
  330.  * id  - Name used to expose the SWF file through the id or name attribute of the HTML object 
  331.  or embed tag.
  332.  
  333.  * height - Height of the MXML wrapper.
  334.  
  335.  * width -  Width of the MXML wrapper.
  336.  
  337.  * useHistoryManagement - Include history management for the Flex application.
  338.  
  339.  * usePlayerDetection - Include Flash Player version detection for the Flex application. The 
  340.  minimum required version is set in the flex-webtier-config.xml file.
  341.  
  342.  * useExpressInstall - Install Flash Player through Express Install; ignored if Flash Player 
  343.  version detection is disabled.
  344.  
  345.  * alternateContentPage - Present this alternate page when the Flash Player version is unavailable; 
  346.  ignored if Flash Player version detection is disabled.
  347. <flashvar>    
  348. Specifies a variable to pass to your Flex application.  
  349. The <flashvar> tag has the following attributes:
  350.  
  351.  * name -   Specifies the name of the flashvar variable.
  352.  
  353.  * value -  Specifies the value of the flashvar variable.