flash 궁금하니?

Using the Flex 2 Tag Library for JSP

deguls 2008. 8. 28. 13:07
출처: http://livedocs.adobe.com/livecycle/es/sdkHelp/programmer/lcds/wwhelp/wwhimpl/common/html/wwhelp.htm?context=LiveDocs_Parts&file=jsptaglib_1.html



Using the Flex 2 Tag Library for JSP

In an Adobe LiveCycle Data Services ES web application, complete the following steps to use the Flex 2 Tag Library for JSP in a JSP page:

  1. Add the following tag library declaration to your JSP page:
    <%@ taglib uri="FlexTagLib" prefix="mm" %>
    
  2. Use the <mxml> tag to insert a Flex application in an existing JSP page. The following example shows the <mxml> tag with the source attribute to include an external MXML file:
    <mm:mxml source="CustomerServiceChat.mxml"/>
    

    Alternatively, you can use the <mxml> tag with inline MXML source code, as the following example shows:

    <mm:mxml>
        <mx:Application xmlns:mx="http://www.adobe.com/2006/mxml" xmlns="*">
            <mx:Text label="Hello World">
        </mx:Application>
    </mm:mxml>
    

Use the <mxml> tag carefully, as any JSP execution that results in different MXML source code causes recompilation. Each distinct instance of MXML source code is cached separately and checked for recompilation separately. Two or three distinct versions of MXML source code might be acceptable, but different MXML source code on each compilation would not be.

For example, the following JSP code results in two sets of MXML source code; one is created when request.isUserInRole("admin") is true, and another is created when request.isUserInRole("admin") is false:

<mm:mxml>
    <mx:Application xmlns:mx="http://www.adobe.com/2006/mxml" xmlns="*">
        <% if (request.isUserInRole("admin")) { %>
        <AdminConsole/>
        <% } else { %>
        <UserConsole/>
        <% } %>
    </mx:Application>
</mm:mxml>

Use the <mxml> and <flashvar> tags to quickly create a dynamic application. Updating the <flashvar> tag does not cause a recompilation. Although the MXML code was specified inline, the source is static without JSP scriptlets.

The following example uses <mxml> and <flashvar> tags with inline MXML code to get the Java version and current date:

<%@ taglib uri="FlexTagLib" prefix="mm" %>
<mm:mxml height="300" width="600" usePlayerDetection="true" useExpressInstall="false" >
      <mm:flashvar name="javaVersion" value='<%= System.getProperty("java.version") %>' />
    <mm:flashvar name="currentDate" value="<%= new java.util.Date().toString() %>"/>
    <mx:Application xmlns:mx="http://www.adobe.com/2006/mxml" width="400" height="300" >
        <mx:VBox>
        <mx:HBox>
            <mx:Label text="Java version: "/>
            <mx:Label
                    text="{Application.application.parameters.javaVersion}" fontWeight="bold"/>
        </mx:HBox>
        <mx:HBox>
            <mx:Label text="Current Time: "/>
            <mx:Label text="{Application.application.parameters.currentDate}"
                    fontWeight="bold"/>
        </mx:HBox>
        </mx:VBox>
        </mx:Application>
</mm:mxml>

The following example shows how to invoke an external MXML file while passing dynamic flash variables to it:

<%@ taglib uri="FlexTagLib" prefix="mm" %>
<mm:mxml source="flashvarTest.mxml" width="400" height="200">
  <mm:flashvar name="javaVersion" value='<%= System.getProperty("java.version") %>' />
  <mm:flashvar name="currentDate" value="<%= new java.util.Date().toString() %>"/>
</mm:mxml>

Use the <mxml> tag attributes to present a Flex application when the correct version of Flash Player is available or an alternate version of the application when the player is unavailable.

In this example, you enable Flash Player Detection but disable the Express Install. With this configuration, the JSP drops directly to the alternateContentPage instead of proceeding to upgrade Flash Player through Express Install.

<mm:mxml source="FlexApplication.mxml" usePlayerDetection="true"
useExpressInstall="false" alternateContentPage="MyLegacyApplication.html"/>

Limitations

If you use the Flex 2 Tag Library for JSP incorrectly, overall application performance can suffer because of excessive recompilation. In general, there are no performance concerns if you use the <mxml> tag and compile MXML source code by using the source attribute.

The following alternative approaches do not modify the actual MXML code that a JSP page generates and do not cause excessive recompilations. Before deciding to use the tag library with your application with inline MXML source code, consider whether one of the following options would be more appropriate:

  • Separate the presentation from the data so that you can use LiveCycle Data Services to populate the data in the application.
  • Pass in the dynamic data by using the <flashvar> tag. You can safely use different name-value pairs on the <flashvar> tag for each JSP page execution, because the differences do not cause a modification and recompilation of the MXML source code.
  • Manipulate the presentation by using ActionScript.

Flex 2 Tag Library for JSP reference

Tag

Description

Attributes

mxml

Compiles the MXML code and generates the HTML wrapper. Includes MXML source as body content, or specify an external source file with the source attribute.

source  Location of the MXML code to compile.

id Name used to expose the SWF file through the id or name attribute of the HTML object or embed tag.

height Height of the MXML wrapper.

width Width of the MXML wrapper.

useHistoryManagement Include history management for the Flex application.

usePlayerDetection Include Flash Player detection for the Flex application.

useExpressInstall Install Flash Player through Express Install; ignored if Flash Player detection is disabled.

alternateContentPage Present this alternate page when the Flash Player version is unavailable; ignored if Flash Player detection is disabled.

flashvar

Specifies a variable to pass to your Flex application.

name Specifies the name of the flashvar variable.

value Specifies the value of the flashvar variable.