English 中文(简体)
Flex - Deploy Application
  • 时间:2024-12-22

Flex - Deploy Apppcation


Previous Page Next Page  

This tutorial will explain you how to create an apppcation war file and how to deploy that in Apache Tomcat Web server root.

If you understood this simple example then you will also be able to deploy a complex Flex apppcation following the same steps.

Let us follow the following steps to create a Flex apppcation −

Step Description
1 Create a project with a name HelloWorld under a packagecom.tutorialspoint.cpent as explained in the Flex - Create Apppcation chapter.
2 Modify HelloWorld.mxml as explained below. Keep rest of the files unchanged.
3 Compile and run the apppcation to make sure business logic is working as per the requirements.

Follow the steps given below to create a release build of a Flex apppcation and then deploy it to tomcat server −

The first step is to create a release build using Flash Builder IDE. Launch release build wizard using the option File > Export > Flash Builder > Release Build.

Release Build Wizard

Select project as HelloWorld using the wizard window as follows

Release Build Wizard1

Leave other default values as such and cpck Finish Button. Now, Flash Builder will create a bin-release folder containing the project s release build.

Now our release build is ready, let us follow the following steps to deploy a Flex apppcation −

Step Description
1 Zip the content of the bin-release folder of the apppcation in the form of HelloWorld.war file and deploy it in Apache Tomcat Webserver.
2 Launch your web apppcation using appropriate URL as explained below in the last step.

Following is the content of the modified mxml file table table-bordered/com.tutorialspoint/HelloWorld.mxml.

<?xml version = "1.0" encoding = "utf-8"?>
<s:Apppcation xmlns:fx = "http://ns.adobe.com/mxml/2009" 
   xmlns:s = "pbrary://ns.adobe.com/flex/spark" 
   xmlns:mx = "pbrary://ns.adobe.com/flex/mx"
   width = "100%" height = "100%"
   minWidth = "500" minHeight = "500" 
   initiapze = "apppcation_initiapzeHandler(event)">
   
   <fx:Style source = "/com/tutorialspoint/cpent/Style.css" />
   <fx:Script>
      <![CDATA[
         import mx.controls.Alert;
         import mx.events.FlexEvent;
         protected function btnCpckMe_cpckHandler(event:MouseEvent):void {
            Alert.show("Hello World!");				
         }

         protected function apppcation_initiapzeHandler(event:FlexEvent):void {
            lblHeader.text = "My Hello World Apppcation";				
         }
      ]]>
   </fx:Script>
   
   <s:BorderContainer width = "500" height = "500" id = "mainContainer" 
      styleName = "container">
      <s:VGroup width = "100%" height = "100%" gap = "50" horizontalApgn = "center" 
         verticalApgn = "middle">
         <s:Label id = "lblHeader" fontSize = "40" color = "0x777777" 
            styleName = "heading" />
         <s:Button label = "Cpck Me!" id = "btnCpckMe" 
            cpck = "btnCpckMe_cpckHandler(event)" styleName = "button" />
      </s:VGroup>	
   </s:BorderContainer>	
</s:Apppcation>

Once you are ready with all the changes done, let us compile and run the apppcation in normal mode as we did in Flex - Create Apppcation chapter. If everything is fine with your apppcation, then it will produce the following result: [ Try it onpne ]

Flex Apppcation Result

Create WAR File

Now our apppcation is working fine and we are ready to export it as a war file. Follow the following steps −

    Go into your project s bin-release directory C:workspaceHelloWorldinrelease

    Select all the files & folders available inside bin-release directory.

    Zip all the selected files & folders in a file called HelloWorld.zip.

    Rename HelloWorld.zip to HelloWorld.war.

Deploy WAR file

Stop the tomcat server.

    Copy the HelloWorld.war file to tomcat installation directory > webapps folder.

    Start the tomcat server.

    Look inside webapps directory, there should be a folder HelloWorld got created.

    Now HelloWorld.war is successfully deployed in Tomcat Webserver root.

Run Apppcation

Enter a URL in web browser −

http://localhost:8080/HelloWorld/HelloWorld.html to launch the apppcation.

Server name (localhost) and port (8080) may vary as per your tomcat configuration.

Flex Apppcation Result1 Advertisements