SlideShare uma empresa Scribd logo
1 de 32
Adobe Flex with Rails
                      Philip Sexton




• The Rails Way
• Flex Architecture
• Demonstration
• Code
• Finish
Other Flex/Rails
         Presentations
•   Flex on Rails; RailsConf 2007 BOF; Peter
    Armstrong

•   Using Adobe Flex with Rails; RailsConf 2007
    Berlin; Borre Wessel

•   Building Rich Internet Applications with Flex and
    Rails; RailsConf 2007 Berlin; Simon Bateman
Web Apps for Data
  Management
Web Apps for Data
      Management
•   Responsive
Web Apps for Data
      Management
•   Responsive
• html/css
Web Apps for Data
      Management
•   Responsive
• html/css
• + Ajax (Async Javascript and XML)
Web Apps for Data
      Management
•   Responsive
• html/css
• + Ajax (Async Javascript and XML)
•   Scaleable
Web Apps for Data
      Management
•   Responsive
• html/css
• + Ajax (Async Javascript and XML)
•   Scaleable
• REST architecture
Ajax and REST


•   IBM article: Ajax and REST, Part 1

•
Ajax Engine
The best answer to the
 client requirement???
• Single HTML Page
• Ajax
• CSS
• Stateful Client
• Cross-browser
Adobe Flex


• Technical overview
Flex runtime architecture
  - from Adobe: Flex 2, technical overview
             Flex runtime architecture
               e Flex runtime architecture is closely aligned with the just-in-time deployment model of web
             applications. e client portion of a Flex application is deployed as a binary le that contains the
             compiled bytecode for the application. Users then deploy this le to a web server just as they
             would an HTML le or an image. When the le is requested by a browser, it is downloaded and
             the bytecode is executed by the Flash Player runtime.

             As illustrated in Figure 3, once started, the application can request additional data or content over the
             network via standard HTTP calls (sometimes referred to as REST services) or through web services
             (SOAP). Flex clients are server agnostic and can be used in conjunction with any server environment,
             including standard web servers and common server scripting environments such as JavaServer
             Pages (JSP), Active Server Pages (ASP), ASP.NET, PHP, and ColdFusion®.

                                 Browser
                                  Browser
                           MXML and ActionScript
                                  Flash Player



                         Data                        Data


                                   Web Server
                                   Web Server

                   XML/HTTP
                   XML/HTTP                 Flex Data Services 2
                      REST
                      REST
                SOAP Web Services
                SOAP Web Services          Java EE Application Server
                                           J2EE Application Server

                    Existing Applications and Infrastructure
                    Existing Applications and Infrastructure


             Figure 3: Flex runtime architecture.


             If the Flex client application is used in conjunction with Flex Data Services, the application has
             access to additional services. Flex clients can make direct calls to Java objects as well as subscribe
             to real-time data feeds, send messages to other clients, and integrate with existing Java Message
             Service (JMS) messaging systems. e Flex Data Services application runs on the server within
             the Java web container.

             Flex development model and application framework
                e development process for Flex applications mirrors the process for Java, C#, C++, or other
             traditional client development languages. Developers write MXML and ActionScript source code
             using the Flex Builder IDE or a standard text editor. As shown in Figure 4, the source code is then
             compiled into bytecode by the Flex compiler, resulting in a binary le with the *.swf extension.
including standard web servers and common server scripting environments such as JavaServer
       Pages (JSP), Active Server Pages (ASP), ASP.NET, PHP, and ColdFusion®.

                           Browser
                            Browser
                     MXML and ActionScript
                            Flash Player



                   Data                          Data




Flex Framework
                             Web Server
                             Web Server

             XML/HTTP
             XML/HTTP                 Flex Data Services 2
                REST
                REST
          SOAP Web Services
          SOAP Web Services          Java EE Application Server
                                     J2EE Application Server




- from Adobe: Flex 2, technical overview
              Existing Applications and Infrastructure
              Existing Applications and Infrastructure


       Figure 3: Flex runtime architecture.


       If the Flex client application is used in conjunction with Flex Data Services, the application has
       access to additional services. Flex clients can make direct calls to Java objects as well as subscribe
       to real-time data feeds, send messages to other clients, and integrate with existing Java Message
       Service (JMS) messaging systems. e Flex Data Services application runs on the server within
       the Java web container.

       Flex development model and application framework
          e development process for Flex applications mirrors the process for Java, C#, C++, or other
       traditional client development languages. Developers write MXML and ActionScript source code
       using the Flex Builder IDE or a standard text editor. As shown in Figure 4, the source code is then
       compiled into bytecode by the Flex compiler, resulting in a binary le with the *.swf extension.

                                                     Flex Application Framework


                     MXML                            ActionScript
                                                                        Compile

                                Flex Class Library



       Figure 4: The Flex framework comprises MXML, ActionScript, and the Flex class library.


       As shown in Figure 4, the Flex application framework consists of MXML, ActionScript 3.0, and
       the Flex class library. Developers use MXML to declaratively de ne the application user interface
       elements and use ActionScript for client logic and procedural control.




                                                                                                Adobe Flex 2   7
Flex product line
- from Adobe, Flex 2, technical overview

         Flex product line overview
         As shown in Figure 2, the Flex product family comprises four separate products:

         • Flex So ware Development Kit (SDK)—            e core component library, development languages,
           and compiler for Flex applications

         • Flex Builder IDE—An Eclipse-based development environment that includes code editors,
           visual layout tools, project management tools, and an integrated debugger

         • Flex Data Services—A Java server-based application that enables high-performance data
           transfer, cross-tier data synchronization and con ict management, and real-time data
           messaging

         • Flex Charting—A library of extensible charting components that enables rapid construction of
           data visualization applications




         Figure 2: Members of the Flex product line.


         Flash Player
         No discussion of the Flex product would be complete without mentioning Flash Player. Flex
         applications are deployed as compiled bytecode that is executed within the Flash Player runtime.
         Installed on over 97% of Internet-connected PCs, Flash Player provides a consistent runtime
         environment that works across browsers and operating systems, enabling Flex applications to
         deliver much greater cross-platform compatibility than other RIA technologies.

         Flash Player provides a unique combination of capabilities that developers can use in their applications,
         including rich text rendering, powerful graphics APIs, an animation engine, and an integrated
         audio/video codec. ese capabilities not only contribute to the rich out-of-the-box look and feel
         displayed in Flex applications, but they are also available to developers who need to construct
Actionscript


• Wikipedia: ECMAScript
Demonstrate Sample
  User Interfaces
Flex and Rails
  - request / response

• code samples from Peter Armstrong: pages
  10..12
• other code samples
package com.anbawn.eile.trn.command {
  import com.adobe.cairngorm.commands.ICommand;
  import com.adobe.cairngorm.control.CairngormEvent;
  import mx.controls.Alert;
  import mx.rpc.IResponder;
  import mx.rpc.events.FaultEvent;
  import mx.rpc.events.ResultEvent;
  ...

    public class AccGjDocUpdate implements ICommand, IResponder {
      public function AccGjDocUpdate() {
      }

        public function execute(event : CairngormEvent) : void {
          var model : AccGjDocsModel = AppModelLocator.getInstance().accGjDocs;
          var delegate : AccGjDocsDelegate = new AccGjDocsDelegate(this);
          var doc :AccGjDoc = event.data as AccGjDoc;
          if (...) {
            delegate.update(event.data);
            ...
          }
        }

        public function result(event : Object) : void {
          var result:Object = event.result;
          var model : AccGjDocsModel = AppModelLocator.getInstance().accGjDocs;
          var doc :AccGjDoc;
          if (result is XML) {
            var x:XML = XML(result);
            if (x.name().localName == ...) {
              doc = AccGjDoc.fromXML(x);
              model.updateDoc(doc);
              ...
            }
            else if (...errors...) {
              var errors :ServerErrors;
              ...
                Alert.show(quot;Save Record FAILED - see errorsquot;);
              } else {
                Alert.show(quot;Save Record FAILED - But errors not available - Unexpected response from serverquot;);
              }
            }
            else {
              Alert.show(quot;Save Record - Unexpected response from serverquot;);
            }
          }
        }

        public function fault(event : Object) : void {
          Main.debug(quot;AccGjDocSave#fault, event = quot; + event);
          var faultEvent : FaultEvent = FaultEvent(event);
          Alert.show(quot;AccGjDoc could not be saved!quot;);
        }

    }
}
package com.anbawn.eile.trn.business {
  import mx.rpc.IResponder;
  import mx.controls.Alert;
  import com.anbawn.eile.util.ServiceUtils;
  import com.anbawn.eile.model.AccGjDoc;

    public class AccGjDocsDelegate {
      private var _responder : IResponder;

        public function AccGjDocsDelegate(responder : IResponder) {
          _responder = responder;
        }

        public function index() : void {
          ServiceUtils.send(quot;/acc_gj_docs.xmlquot;, _responder);
        }

        public function neww() : void {
          ServiceUtils.send(quot;/acc_gj_docs/new.xmlquot;, _responder);
        }

        public function create(rec : AccGjDoc) : void {
          ServiceUtils.send(quot;/acc_gj_docs.xmlquot;, _responder,
            quot;POSTquot;, rec.toXML(), true);
        }

        public function update(rec : AccGjDoc) : void {
          ServiceUtils.send(quot;/acc_gj_docs/quot; + rec.id + quot;.xmlquot;,
           _responder,
           quot;PUTquot;, rec.toUpdateObject(), false);
        }
        public function destroy(rec : AccGjDoc) : void {
           var params:Object = {};
           params[quot;acc_gj_doc[lock_version]quot;] = rec.lock_version;
           ServiceUtils.send(quot;/acc_gj_docs/quot; + rec.id + quot;.xmlquot;,
              _responder,
              quot;DELETEquot;, params, false);
        }

        public function show(rec : AccGjDoc) : void {
          ServiceUtils.send(quot;/acc_gj_docs/quot; + rec.id + quot;.xmlquot;,
           _responder);
        }

    }
}
package com.anbawn.eile.util {
  import mx.rpc.IResponder;
  import mx.rpc.AsyncToken;
  import mx.rpc.http.HTTPService;

    public class ServiceUtils {
      /**
       * Note: PUT and DELETE don't work with XML since the _method hack
       * workaround doesn't work.
       */
      public static function send(
          url:String,
          responder:IResponder = null,
          method:String = null,
          request:Object = null,
          sendXML:Boolean = false,
          resultFormat:String = quot;e4xquot;,
          useProxy:Boolean = false) : void
      {
          var service:HTTPService = new HTTPService();
          service.url = url;
          service.contentType = sendXML ? quot;application/xmlquot; :
             quot;application/x-www-form-urlencodedquot;;
          service.resultFormat = resultFormat;

            if (method == null) {//the method wasn't set, so default sensibly
                service.method = (request == null) ? quot;GETquot; : quot;POSTquot;;
            } else if ((method == quot;PUTquot;) || (method == quot;DELETEquot;)) {
                service.method = quot;POSTquot;;//PUT and DELETE don't work in Flash yet
                if (request == null) {
                    request = new Object();
                }
                request[quot;_methodquot;] = method;
            } else {
                service.method = method;
            }

            service.request = request;
            service.useProxy = useProxy;
            var call:AsyncToken = service.send();
            if (responder != null) {
                call.addResponder(responder);
            }
        }
    }
}
Flex - views and
       components


• code samples
<?xml version=quot;1.0quot; encoding=quot;utf-8quot;?>
<!-- ABCList.mxml -->
<mx:Panel
 xmlns:mx=quot;http://www.adobe.com/2006/mxmlquot;
 title=quot;Listquot;
 label=quot;AbcThingsquot;
 layout=quot;verticalquot;
 width=quot;100%quot;
 height=quot;100%quot;>

 <mx:Script>
  <![CDATA[
  import mx.controls.Alert;
  ...

  [Bindable]
  public var model:AbcThingsModel = AppModelLocator.getInstance().abcThings;

  private function onSelect() : void {
     ...
  }
  private function statusName(item:Object, column:DataGridColumn):String {
    return item.status.name;
  }
  private function currencyCode(item:Object, column:DataGridColumn):String {
    return item.currency.currency;
  }

  ]]>
 </mx:Script>

 <mx:DataGrid
  id=quot;dgquot;
  x=quot;0quot;
  y=quot;0quot;
  width=quot;100%quot;
  height=quot;100%quot;
  dataProvider=quot;{model.abcThings}quot;
  change=quot;onSelect()quot;>
  <mx:columns>
    <mx:DataGridColumn headerText=quot;Codequot; dataField=quot;codequot;/>
    <mx:DataGridColumn headerText=quot;Namequot; dataField=quot;namequot;/>
    <mx:DataGridColumn headerText=quot;Currencyquot;
     dataField=quot;currency_idquot; labelFunction=quot;currencyCodequot;/>
    <mx:DataGridColumn headerText=quot;Statusquot;
     dataField=quot;status_codequot; labelFunction=quot;statusNamequot;/>
  </mx:columns>
 </mx:DataGrid>

</mx:Panel>
<?xml version=quot;1.0quot; encoding=quot;utf-8quot;?>
<!-- ABCEdit.mxml -->
<mx:Panel
 xmlns:mx=quot;http://www.adobe.com/2006/mxmlquot;
 xmlns:anb=quot;com.anbawn.components.*quot;
 xmlns=quot;*quot;
 title=quot;Editquot;
 layout=quot;verticalquot;
 width=quot;100%quot;
 height=quot;100%quot;>

 <mx:Script>
  <![CDATA[
  import mx.controls.Alert;
  import mx.core.Application;
  import mx.events.ValidationResultEvent;
  import mx.events.CloseEvent;
  ...

  [Bindable]
  public var datarec:AbcThing;

  [Bindable]
  private var appModel : AppModelLocator = AppModelLocator.getInstance();
  [Bindable]
  private var model : AbcThingsModel = AppModelLocator.getInstance().abcThings;

  private function validateAndSubmit():void {
   var invalid:Boolean = false;
   var vResult:ValidationResultEvent = nameV.validate();
   if (vResult.type == ValidationResultEvent.INVALID) invalid = true;

      if (invalid) {
        Alert.show(quot;Validation errors, record not saved.quot;);
        return;
      }

      var rec:AbcThing = new AbcThing(
          dr_name.text,
          dr_code.text,
          0, //currency_id:int = 0;
          Currency(cb1.selectedItem),
          0, //status_code:int = 0;
          StatusOfMasterEntity(cb2.selectedItem),
          datarec.created_by,
          datarec.created_at,
          datarec.updated_by,
          datarec.updated_at,
          datarec.lock_version,
          datarec.id);
      CairngormUtils.dispatchEvent(EventNames.SAVE_ABC_THING, rec);
  }
private function resetForm():void {
      ...
 }
 private function confirmResetForm(event:CloseEvent):void {
   if (event.detail == Alert.YES)
      CairngormUtils.dispatchEvent(EventNames.RESET_NEW_THING);
 }
 private function doDelete():void {
   ...
 }
 private function confirmDelete(event:CloseEvent):void {
   if (event.detail == Alert.YES)
      CairngormUtils.dispatchEvent(EventNames.DELETE_THING, datarec);
 }
 ]]>
</mx:Script>

<mx:StringValidator
 id=quot;nameVquot;
 source=quot;{dr_name}quot;
 property=quot;textquot;
 required=quot;truequot;/>

<mx:HBox>

<mx:VBox>
<mx:Form id=quot;formH1quot;
 x=quot;0quot;
 y=quot;0quot;
 width=quot;100%quot;
 height=quot;100%quot;
 >
 <mx:FormItem label=quot;Code:quot; required=quot;truequot;>
  <mx:TextInput id=quot;dr_codequot; text=quot;{datarec.code}quot; />
 </mx:FormItem>

 <mx:FormItem label=quot;Name:quot; required=quot;truequot;>
  <mx:TextInput id=quot;dr_namequot; text=quot;{datarec.name}quot; />
 </mx:FormItem>

 <mx:FormItem label=quot;Currency:quot;>
  <mx:ComboBox id=quot;cb1quot;
  dataProvider=quot;{appModel.currencies}quot;
  selectedItem=quot;{datarec.currency}quot;
  labelField=quot;namequot;/>
 </mx:FormItem>

 <mx:FormItem label=quot;Status:quot;>
  <mx:ComboBox id=quot;cb2quot;
  dataProvider=quot;{appModel.statusesOfMasterEntity}quot;
  selectedItem=quot;{datarec.status}quot;
  labelField=quot;namequot;/>
 </mx:FormItem>
</mx:Form>
<mx:HBox>
   <mx:Button
   visible=quot;{datarec.deleting==false}quot;
   label=quot;Savequot;
   click=quot;validateAndSubmit()quot;/>

   <mx:Button
   visible=quot;{model.viewState == AppModelLocator.VIEW_STATE_NEW}quot;
   label=quot;Resetquot;
   click=quot;resetForm()quot;/>

   <mx:Button
   visible=
   quot;{model.viewState == AppModelLocator.VIEW_STATE_EDIT}quot;
   label=quot;Deletequot;
   click=quot;doDelete()quot;/>
 </mx:HBox>

 </mx:VBox>

 </mx:HBox>

</mx:Panel>
<?xml version=quot;1.0quot; encoding=quot;utf-8quot;?>
<!-- CheckBoxXYZ.mxml -->
<mx:HBox xmlns:mx=quot;http://www.adobe.com/2006/mxmlquot;
	         horizontalAlign=quot;centerquot;>
	         	         <mx:Script>
	         	         	         <![CDATA[
	         	         	         	        import mx.controls.DataGrid;

	        	         	         	          public var dataGrid:DataGrid;

	       	          	         	          private function selectRow(event:Event) :void {
	       	          	         	          	          if ( ... ) {
	       	          	         	          	          	            data.selected = !data.selected;
	       	          	         	          	          	            if (dataGrid != null)
	       	          	         	          	          	            	          dataGrid.dispatchEvent(new Event(quot;rowSelectEventquot;));
	       	          	         	          	          }
	       	          	         	          	          else //discard the user action by resetting the box
	       	          	         	          	          	            cb1.selected = data.selected;
	       	          	         	          }
	       	          	         ]]>
	       	          </mx:Script>
	       	          <mx:CheckBox id=quot;cb1quot; selected=quot;{data.selected}quot;
	       	          	         click=quot;selectRow(event)quot; />
</mx:HBox>
package com.anbawn.components {
 import mx.controls.DataGrid;
 import mx.collections.ArrayCollection;
 import flash.display.Sprite;

    [Event(quot;rowSelectEventquot;)]
    public class DataGridPlus extends DataGrid {

        override protected function drawRowBackground(s:Sprite, rowIndex:int,
        y:Number, height:Number, color:uint, dataIndex:int):void {
          var dp:ArrayCollection = dataProvider as ArrayCollection;
          var item:Object;
          if (dp != null) {
            if( dataIndex < dp.length ) item = dp.getItemAt(dataIndex);
            if (item != null && item.selected) color = 0xFFFF00; //yellow
            //0xFF8800;//orange
          }
          super.drawRowBackground(s,rowIndex,y,height,color,dataIndex);
        }

        public function myDrawRowBackgrounds() :void {
          super.drawRowBackgrounds();
        }
    }
}
Flash Player?

• Adobe says...
   • on more than 97% of internet-enabled
      PCs
   • Flash Player 9:   90.3% (June 2007)
Flex?


• see Peter Armstrong’s Presentation: pages
  15..18
Flex, Be Aware

• not html, hence search engines !
• printing !
• no back button
Flex / Rails
• Cairngorm
• RubyAMF (Aaron Smith)
• Resources
   • www.adobe.com/products/flex
   • www.flexiblerails.com (see links and
      resources there)

Mais conteúdo relacionado

Mais procurados

Chapter10 web
Chapter10 webChapter10 web
Chapter10 webREADIFY
 
Web Service Presentation
Web Service PresentationWeb Service Presentation
Web Service Presentationguest0df6b0
 
Web Center Services and Framework
Web Center Services and  FrameworkWeb Center Services and  Framework
Web Center Services and FrameworkJaime Cid
 
Flex And Java Integration
Flex And Java IntegrationFlex And Java Integration
Flex And Java Integrationrssharma
 
Visual Studio 2010 IDE Enhancements - Alex Mackey, Readify
Visual Studio 2010 IDE Enhancements - Alex Mackey, ReadifyVisual Studio 2010 IDE Enhancements - Alex Mackey, Readify
Visual Studio 2010 IDE Enhancements - Alex Mackey, ReadifyREADIFY
 
Asp.net presentation by gajanand bohra
Asp.net presentation by gajanand bohraAsp.net presentation by gajanand bohra
Asp.net presentation by gajanand bohraGajanand Bohra
 
Web changesandasp4 upload
Web changesandasp4 uploadWeb changesandasp4 upload
Web changesandasp4 uploadREADIFY
 
ASP.NET 4 & Web Dev in Visual Studio 2010 - Alex Mackey, Readify
ASP.NET 4 & Web Dev in Visual Studio 2010 - Alex Mackey, ReadifyASP.NET 4 & Web Dev in Visual Studio 2010 - Alex Mackey, Readify
ASP.NET 4 & Web Dev in Visual Studio 2010 - Alex Mackey, ReadifyREADIFY
 
Flex for enterprise applications
Flex for enterprise applicationsFlex for enterprise applications
Flex for enterprise applicationsdarshanvartak
 
Web Service Implementation Using ASP.NET
Web Service Implementation Using ASP.NETWeb Service Implementation Using ASP.NET
Web Service Implementation Using ASP.NETPonraj
 
web service technologies
web service technologiesweb service technologies
web service technologiesYash Darak
 
Web development with ASP.NET Web API
Web development with ASP.NET Web APIWeb development with ASP.NET Web API
Web development with ASP.NET Web APIDamir Dobric
 

Mais procurados (20)

Chapter10 web
Chapter10 webChapter10 web
Chapter10 web
 
Web Service Presentation
Web Service PresentationWeb Service Presentation
Web Service Presentation
 
Unit 02: Web Technologies (2/2)
Unit 02: Web Technologies (2/2)Unit 02: Web Technologies (2/2)
Unit 02: Web Technologies (2/2)
 
Web Center Services and Framework
Web Center Services and  FrameworkWeb Center Services and  Framework
Web Center Services and Framework
 
Aws
AwsAws
Aws
 
Flex And Java Integration
Flex And Java IntegrationFlex And Java Integration
Flex And Java Integration
 
Visual Studio 2010 IDE Enhancements - Alex Mackey, Readify
Visual Studio 2010 IDE Enhancements - Alex Mackey, ReadifyVisual Studio 2010 IDE Enhancements - Alex Mackey, Readify
Visual Studio 2010 IDE Enhancements - Alex Mackey, Readify
 
Asp.net presentation by gajanand bohra
Asp.net presentation by gajanand bohraAsp.net presentation by gajanand bohra
Asp.net presentation by gajanand bohra
 
Introduction to Web Services
Introduction to Web ServicesIntroduction to Web Services
Introduction to Web Services
 
Web changesandasp4 upload
Web changesandasp4 uploadWeb changesandasp4 upload
Web changesandasp4 upload
 
ASP.NET 4 & Web Dev in Visual Studio 2010 - Alex Mackey, Readify
ASP.NET 4 & Web Dev in Visual Studio 2010 - Alex Mackey, ReadifyASP.NET 4 & Web Dev in Visual Studio 2010 - Alex Mackey, Readify
ASP.NET 4 & Web Dev in Visual Studio 2010 - Alex Mackey, Readify
 
Flex for enterprise applications
Flex for enterprise applicationsFlex for enterprise applications
Flex for enterprise applications
 
dot NET Framework
dot NET Frameworkdot NET Framework
dot NET Framework
 
Unit 06: The Web Application Extension for UML
Unit 06: The Web Application Extension for UMLUnit 06: The Web Application Extension for UML
Unit 06: The Web Application Extension for UML
 
Ashish tripath
Ashish tripathAshish tripath
Ashish tripath
 
Web Service Implementation Using ASP.NET
Web Service Implementation Using ASP.NETWeb Service Implementation Using ASP.NET
Web Service Implementation Using ASP.NET
 
Java web services
Java web servicesJava web services
Java web services
 
web service technologies
web service technologiesweb service technologies
web service technologies
 
.NET Tutorial
.NET Tutorial.NET Tutorial
.NET Tutorial
 
Web development with ASP.NET Web API
Web development with ASP.NET Web APIWeb development with ASP.NET Web API
Web development with ASP.NET Web API
 

Semelhante a Flex Rails Pres

Flex And Ria
Flex And RiaFlex And Ria
Flex And Riaravinxg
 
Introduction to Adobe Flex - Zaloni
Introduction to Adobe Flex - ZaloniIntroduction to Adobe Flex - Zaloni
Introduction to Adobe Flex - ZaloniJoseph Khan
 
Developing RIAs... 10 reasons to use Adobe Flex
Developing RIAs... 10 reasons to use Adobe FlexDeveloping RIAs... 10 reasons to use Adobe Flex
Developing RIAs... 10 reasons to use Adobe FlexMatthias Zeller
 
Flex Remoting With WebORB v1.0
Flex Remoting With WebORB v1.0Flex Remoting With WebORB v1.0
Flex Remoting With WebORB v1.0guest642dd3
 
Flex presentation1
Flex presentation1Flex presentation1
Flex presentation1Nguyen Tran
 
Introduction To Adobe Flex And Semantic Resources
Introduction To Adobe Flex And Semantic ResourcesIntroduction To Adobe Flex And Semantic Resources
Introduction To Adobe Flex And Semantic Resourceskeith_sutton100
 
RIA Development via Adobe Flex + JRuby on Rails
RIA Development via Adobe Flex + JRuby on RailsRIA Development via Adobe Flex + JRuby on Rails
RIA Development via Adobe Flex + JRuby on Railskamal.fariz
 
Flex Introduction
Flex Introduction Flex Introduction
Flex Introduction senthil0809
 
Flex and .NET Integration
Flex and .NET IntegrationFlex and .NET Integration
Flex and .NET Integrationicaraion
 
Bn1001 demo ppt advance dot net
Bn1001 demo ppt advance dot netBn1001 demo ppt advance dot net
Bn1001 demo ppt advance dot netconline training
 
Introduction to Adobe Flex
Introduction to Adobe FlexIntroduction to Adobe Flex
Introduction to Adobe FlexAngelin R
 
Introduction to the Client OM in SharePoint 2010
Introduction to the Client OM in SharePoint 2010Introduction to the Client OM in SharePoint 2010
Introduction to the Client OM in SharePoint 2010Ben Robb
 
RICH INTERNET APPLICATIONS - RIA Tools
RICH INTERNET APPLICATIONS - RIA ToolsRICH INTERNET APPLICATIONS - RIA Tools
RICH INTERNET APPLICATIONS - RIA ToolsMeghana Chandrashekar
 

Semelhante a Flex Rails Pres (20)

Flex And Ria
Flex And RiaFlex And Ria
Flex And Ria
 
Flex RIA
Flex RIAFlex RIA
Flex RIA
 
Introduction to Adobe Flex - Zaloni
Introduction to Adobe Flex - ZaloniIntroduction to Adobe Flex - Zaloni
Introduction to Adobe Flex - Zaloni
 
Developing RIAs... 10 reasons to use Adobe Flex
Developing RIAs... 10 reasons to use Adobe FlexDeveloping RIAs... 10 reasons to use Adobe Flex
Developing RIAs... 10 reasons to use Adobe Flex
 
Flex Remoting With WebORB v1.0
Flex Remoting With WebORB v1.0Flex Remoting With WebORB v1.0
Flex Remoting With WebORB v1.0
 
Flex presentation1
Flex presentation1Flex presentation1
Flex presentation1
 
Introduction To Adobe Flex And Semantic Resources
Introduction To Adobe Flex And Semantic ResourcesIntroduction To Adobe Flex And Semantic Resources
Introduction To Adobe Flex And Semantic Resources
 
RIA Development via Adobe Flex + JRuby on Rails
RIA Development via Adobe Flex + JRuby on RailsRIA Development via Adobe Flex + JRuby on Rails
RIA Development via Adobe Flex + JRuby on Rails
 
Flex in portal
Flex in portalFlex in portal
Flex in portal
 
Flex Introduction
Flex Introduction Flex Introduction
Flex Introduction
 
Silverlight Training
Silverlight TrainingSilverlight Training
Silverlight Training
 
Flex and .NET Integration
Flex and .NET IntegrationFlex and .NET Integration
Flex and .NET Integration
 
Bn1001 demo ppt advance dot net
Bn1001 demo ppt advance dot netBn1001 demo ppt advance dot net
Bn1001 demo ppt advance dot net
 
Introduction to Adobe Flex
Introduction to Adobe FlexIntroduction to Adobe Flex
Introduction to Adobe Flex
 
Introduction to the Client OM in SharePoint 2010
Introduction to the Client OM in SharePoint 2010Introduction to the Client OM in SharePoint 2010
Introduction to the Client OM in SharePoint 2010
 
RICH INTERNET APPLICATIONS - RIA Tools
RICH INTERNET APPLICATIONS - RIA ToolsRICH INTERNET APPLICATIONS - RIA Tools
RICH INTERNET APPLICATIONS - RIA Tools
 
Adobe® Flex™
Adobe® Flex™Adobe® Flex™
Adobe® Flex™
 
What is Adobe Flex ?
What is Adobe Flex  ?What is Adobe Flex  ?
What is Adobe Flex ?
 
Chapter 1
Chapter 1Chapter 1
Chapter 1
 
Adobe Flex Resources 6439
Adobe Flex Resources 6439Adobe Flex Resources 6439
Adobe Flex Resources 6439
 

Último

Swan(sea) Song – personal research during my six years at Swansea ... and bey...
Swan(sea) Song – personal research during my six years at Swansea ... and bey...Swan(sea) Song – personal research during my six years at Swansea ... and bey...
Swan(sea) Song – personal research during my six years at Swansea ... and bey...Alan Dix
 
SQL Database Design For Developers at php[tek] 2024
SQL Database Design For Developers at php[tek] 2024SQL Database Design For Developers at php[tek] 2024
SQL Database Design For Developers at php[tek] 2024Scott Keck-Warren
 
FULL ENJOY 🔝 8264348440 🔝 Call Girls in Diplomatic Enclave | Delhi
FULL ENJOY 🔝 8264348440 🔝 Call Girls in Diplomatic Enclave | DelhiFULL ENJOY 🔝 8264348440 🔝 Call Girls in Diplomatic Enclave | Delhi
FULL ENJOY 🔝 8264348440 🔝 Call Girls in Diplomatic Enclave | Delhisoniya singh
 
From Event to Action: Accelerate Your Decision Making with Real-Time Automation
From Event to Action: Accelerate Your Decision Making with Real-Time AutomationFrom Event to Action: Accelerate Your Decision Making with Real-Time Automation
From Event to Action: Accelerate Your Decision Making with Real-Time AutomationSafe Software
 
Tech-Forward - Achieving Business Readiness For Copilot in Microsoft 365
Tech-Forward - Achieving Business Readiness For Copilot in Microsoft 365Tech-Forward - Achieving Business Readiness For Copilot in Microsoft 365
Tech-Forward - Achieving Business Readiness For Copilot in Microsoft 3652toLead Limited
 
Automating Business Process via MuleSoft Composer | Bangalore MuleSoft Meetup...
Automating Business Process via MuleSoft Composer | Bangalore MuleSoft Meetup...Automating Business Process via MuleSoft Composer | Bangalore MuleSoft Meetup...
Automating Business Process via MuleSoft Composer | Bangalore MuleSoft Meetup...shyamraj55
 
How to Remove Document Management Hurdles with X-Docs?
How to Remove Document Management Hurdles with X-Docs?How to Remove Document Management Hurdles with X-Docs?
How to Remove Document Management Hurdles with X-Docs?XfilesPro
 
The 7 Things I Know About Cyber Security After 25 Years | April 2024
The 7 Things I Know About Cyber Security After 25 Years | April 2024The 7 Things I Know About Cyber Security After 25 Years | April 2024
The 7 Things I Know About Cyber Security After 25 Years | April 2024Rafal Los
 
Transcript: #StandardsGoals for 2024: What’s new for BISAC - Tech Forum 2024
Transcript: #StandardsGoals for 2024: What’s new for BISAC - Tech Forum 2024Transcript: #StandardsGoals for 2024: What’s new for BISAC - Tech Forum 2024
Transcript: #StandardsGoals for 2024: What’s new for BISAC - Tech Forum 2024BookNet Canada
 
My Hashitalk Indonesia April 2024 Presentation
My Hashitalk Indonesia April 2024 PresentationMy Hashitalk Indonesia April 2024 Presentation
My Hashitalk Indonesia April 2024 PresentationRidwan Fadjar
 
#StandardsGoals for 2024: What’s new for BISAC - Tech Forum 2024
#StandardsGoals for 2024: What’s new for BISAC - Tech Forum 2024#StandardsGoals for 2024: What’s new for BISAC - Tech Forum 2024
#StandardsGoals for 2024: What’s new for BISAC - Tech Forum 2024BookNet Canada
 
Maximizing Board Effectiveness 2024 Webinar.pptx
Maximizing Board Effectiveness 2024 Webinar.pptxMaximizing Board Effectiveness 2024 Webinar.pptx
Maximizing Board Effectiveness 2024 Webinar.pptxOnBoard
 
[2024]Digital Global Overview Report 2024 Meltwater.pdf
[2024]Digital Global Overview Report 2024 Meltwater.pdf[2024]Digital Global Overview Report 2024 Meltwater.pdf
[2024]Digital Global Overview Report 2024 Meltwater.pdfhans926745
 
Kotlin Multiplatform & Compose Multiplatform - Starter kit for pragmatics
Kotlin Multiplatform & Compose Multiplatform - Starter kit for pragmaticsKotlin Multiplatform & Compose Multiplatform - Starter kit for pragmatics
Kotlin Multiplatform & Compose Multiplatform - Starter kit for pragmaticscarlostorres15106
 
Human Factors of XR: Using Human Factors to Design XR Systems
Human Factors of XR: Using Human Factors to Design XR SystemsHuman Factors of XR: Using Human Factors to Design XR Systems
Human Factors of XR: Using Human Factors to Design XR SystemsMark Billinghurst
 
Install Stable Diffusion in windows machine
Install Stable Diffusion in windows machineInstall Stable Diffusion in windows machine
Install Stable Diffusion in windows machinePadma Pradeep
 
Understanding the Laravel MVC Architecture
Understanding the Laravel MVC ArchitectureUnderstanding the Laravel MVC Architecture
Understanding the Laravel MVC ArchitecturePixlogix Infotech
 
Beyond Boundaries: Leveraging No-Code Solutions for Industry Innovation
Beyond Boundaries: Leveraging No-Code Solutions for Industry InnovationBeyond Boundaries: Leveraging No-Code Solutions for Industry Innovation
Beyond Boundaries: Leveraging No-Code Solutions for Industry InnovationSafe Software
 
How to Troubleshoot Apps for the Modern Connected Worker
How to Troubleshoot Apps for the Modern Connected WorkerHow to Troubleshoot Apps for the Modern Connected Worker
How to Troubleshoot Apps for the Modern Connected WorkerThousandEyes
 
Scaling API-first – The story of a global engineering organization
Scaling API-first – The story of a global engineering organizationScaling API-first – The story of a global engineering organization
Scaling API-first – The story of a global engineering organizationRadu Cotescu
 

Último (20)

Swan(sea) Song – personal research during my six years at Swansea ... and bey...
Swan(sea) Song – personal research during my six years at Swansea ... and bey...Swan(sea) Song – personal research during my six years at Swansea ... and bey...
Swan(sea) Song – personal research during my six years at Swansea ... and bey...
 
SQL Database Design For Developers at php[tek] 2024
SQL Database Design For Developers at php[tek] 2024SQL Database Design For Developers at php[tek] 2024
SQL Database Design For Developers at php[tek] 2024
 
FULL ENJOY 🔝 8264348440 🔝 Call Girls in Diplomatic Enclave | Delhi
FULL ENJOY 🔝 8264348440 🔝 Call Girls in Diplomatic Enclave | DelhiFULL ENJOY 🔝 8264348440 🔝 Call Girls in Diplomatic Enclave | Delhi
FULL ENJOY 🔝 8264348440 🔝 Call Girls in Diplomatic Enclave | Delhi
 
From Event to Action: Accelerate Your Decision Making with Real-Time Automation
From Event to Action: Accelerate Your Decision Making with Real-Time AutomationFrom Event to Action: Accelerate Your Decision Making with Real-Time Automation
From Event to Action: Accelerate Your Decision Making with Real-Time Automation
 
Tech-Forward - Achieving Business Readiness For Copilot in Microsoft 365
Tech-Forward - Achieving Business Readiness For Copilot in Microsoft 365Tech-Forward - Achieving Business Readiness For Copilot in Microsoft 365
Tech-Forward - Achieving Business Readiness For Copilot in Microsoft 365
 
Automating Business Process via MuleSoft Composer | Bangalore MuleSoft Meetup...
Automating Business Process via MuleSoft Composer | Bangalore MuleSoft Meetup...Automating Business Process via MuleSoft Composer | Bangalore MuleSoft Meetup...
Automating Business Process via MuleSoft Composer | Bangalore MuleSoft Meetup...
 
How to Remove Document Management Hurdles with X-Docs?
How to Remove Document Management Hurdles with X-Docs?How to Remove Document Management Hurdles with X-Docs?
How to Remove Document Management Hurdles with X-Docs?
 
The 7 Things I Know About Cyber Security After 25 Years | April 2024
The 7 Things I Know About Cyber Security After 25 Years | April 2024The 7 Things I Know About Cyber Security After 25 Years | April 2024
The 7 Things I Know About Cyber Security After 25 Years | April 2024
 
Transcript: #StandardsGoals for 2024: What’s new for BISAC - Tech Forum 2024
Transcript: #StandardsGoals for 2024: What’s new for BISAC - Tech Forum 2024Transcript: #StandardsGoals for 2024: What’s new for BISAC - Tech Forum 2024
Transcript: #StandardsGoals for 2024: What’s new for BISAC - Tech Forum 2024
 
My Hashitalk Indonesia April 2024 Presentation
My Hashitalk Indonesia April 2024 PresentationMy Hashitalk Indonesia April 2024 Presentation
My Hashitalk Indonesia April 2024 Presentation
 
#StandardsGoals for 2024: What’s new for BISAC - Tech Forum 2024
#StandardsGoals for 2024: What’s new for BISAC - Tech Forum 2024#StandardsGoals for 2024: What’s new for BISAC - Tech Forum 2024
#StandardsGoals for 2024: What’s new for BISAC - Tech Forum 2024
 
Maximizing Board Effectiveness 2024 Webinar.pptx
Maximizing Board Effectiveness 2024 Webinar.pptxMaximizing Board Effectiveness 2024 Webinar.pptx
Maximizing Board Effectiveness 2024 Webinar.pptx
 
[2024]Digital Global Overview Report 2024 Meltwater.pdf
[2024]Digital Global Overview Report 2024 Meltwater.pdf[2024]Digital Global Overview Report 2024 Meltwater.pdf
[2024]Digital Global Overview Report 2024 Meltwater.pdf
 
Kotlin Multiplatform & Compose Multiplatform - Starter kit for pragmatics
Kotlin Multiplatform & Compose Multiplatform - Starter kit for pragmaticsKotlin Multiplatform & Compose Multiplatform - Starter kit for pragmatics
Kotlin Multiplatform & Compose Multiplatform - Starter kit for pragmatics
 
Human Factors of XR: Using Human Factors to Design XR Systems
Human Factors of XR: Using Human Factors to Design XR SystemsHuman Factors of XR: Using Human Factors to Design XR Systems
Human Factors of XR: Using Human Factors to Design XR Systems
 
Install Stable Diffusion in windows machine
Install Stable Diffusion in windows machineInstall Stable Diffusion in windows machine
Install Stable Diffusion in windows machine
 
Understanding the Laravel MVC Architecture
Understanding the Laravel MVC ArchitectureUnderstanding the Laravel MVC Architecture
Understanding the Laravel MVC Architecture
 
Beyond Boundaries: Leveraging No-Code Solutions for Industry Innovation
Beyond Boundaries: Leveraging No-Code Solutions for Industry InnovationBeyond Boundaries: Leveraging No-Code Solutions for Industry Innovation
Beyond Boundaries: Leveraging No-Code Solutions for Industry Innovation
 
How to Troubleshoot Apps for the Modern Connected Worker
How to Troubleshoot Apps for the Modern Connected WorkerHow to Troubleshoot Apps for the Modern Connected Worker
How to Troubleshoot Apps for the Modern Connected Worker
 
Scaling API-first – The story of a global engineering organization
Scaling API-first – The story of a global engineering organizationScaling API-first – The story of a global engineering organization
Scaling API-first – The story of a global engineering organization
 

Flex Rails Pres

  • 1. Adobe Flex with Rails Philip Sexton • The Rails Way • Flex Architecture • Demonstration • Code • Finish
  • 2. Other Flex/Rails Presentations • Flex on Rails; RailsConf 2007 BOF; Peter Armstrong • Using Adobe Flex with Rails; RailsConf 2007 Berlin; Borre Wessel • Building Rich Internet Applications with Flex and Rails; RailsConf 2007 Berlin; Simon Bateman
  • 3. Web Apps for Data Management
  • 4. Web Apps for Data Management • Responsive
  • 5. Web Apps for Data Management • Responsive • html/css
  • 6. Web Apps for Data Management • Responsive • html/css • + Ajax (Async Javascript and XML)
  • 7. Web Apps for Data Management • Responsive • html/css • + Ajax (Async Javascript and XML) • Scaleable
  • 8. Web Apps for Data Management • Responsive • html/css • + Ajax (Async Javascript and XML) • Scaleable • REST architecture
  • 9. Ajax and REST • IBM article: Ajax and REST, Part 1 •
  • 11. The best answer to the client requirement??? • Single HTML Page • Ajax • CSS • Stateful Client • Cross-browser
  • 13. Flex runtime architecture - from Adobe: Flex 2, technical overview Flex runtime architecture e Flex runtime architecture is closely aligned with the just-in-time deployment model of web applications. e client portion of a Flex application is deployed as a binary le that contains the compiled bytecode for the application. Users then deploy this le to a web server just as they would an HTML le or an image. When the le is requested by a browser, it is downloaded and the bytecode is executed by the Flash Player runtime. As illustrated in Figure 3, once started, the application can request additional data or content over the network via standard HTTP calls (sometimes referred to as REST services) or through web services (SOAP). Flex clients are server agnostic and can be used in conjunction with any server environment, including standard web servers and common server scripting environments such as JavaServer Pages (JSP), Active Server Pages (ASP), ASP.NET, PHP, and ColdFusion®. Browser Browser MXML and ActionScript Flash Player Data Data Web Server Web Server XML/HTTP XML/HTTP Flex Data Services 2 REST REST SOAP Web Services SOAP Web Services Java EE Application Server J2EE Application Server Existing Applications and Infrastructure Existing Applications and Infrastructure Figure 3: Flex runtime architecture. If the Flex client application is used in conjunction with Flex Data Services, the application has access to additional services. Flex clients can make direct calls to Java objects as well as subscribe to real-time data feeds, send messages to other clients, and integrate with existing Java Message Service (JMS) messaging systems. e Flex Data Services application runs on the server within the Java web container. Flex development model and application framework e development process for Flex applications mirrors the process for Java, C#, C++, or other traditional client development languages. Developers write MXML and ActionScript source code using the Flex Builder IDE or a standard text editor. As shown in Figure 4, the source code is then compiled into bytecode by the Flex compiler, resulting in a binary le with the *.swf extension.
  • 14. including standard web servers and common server scripting environments such as JavaServer Pages (JSP), Active Server Pages (ASP), ASP.NET, PHP, and ColdFusion®. Browser Browser MXML and ActionScript Flash Player Data Data Flex Framework Web Server Web Server XML/HTTP XML/HTTP Flex Data Services 2 REST REST SOAP Web Services SOAP Web Services Java EE Application Server J2EE Application Server - from Adobe: Flex 2, technical overview Existing Applications and Infrastructure Existing Applications and Infrastructure Figure 3: Flex runtime architecture. If the Flex client application is used in conjunction with Flex Data Services, the application has access to additional services. Flex clients can make direct calls to Java objects as well as subscribe to real-time data feeds, send messages to other clients, and integrate with existing Java Message Service (JMS) messaging systems. e Flex Data Services application runs on the server within the Java web container. Flex development model and application framework e development process for Flex applications mirrors the process for Java, C#, C++, or other traditional client development languages. Developers write MXML and ActionScript source code using the Flex Builder IDE or a standard text editor. As shown in Figure 4, the source code is then compiled into bytecode by the Flex compiler, resulting in a binary le with the *.swf extension. Flex Application Framework MXML ActionScript Compile Flex Class Library Figure 4: The Flex framework comprises MXML, ActionScript, and the Flex class library. As shown in Figure 4, the Flex application framework consists of MXML, ActionScript 3.0, and the Flex class library. Developers use MXML to declaratively de ne the application user interface elements and use ActionScript for client logic and procedural control. Adobe Flex 2 7
  • 15. Flex product line - from Adobe, Flex 2, technical overview Flex product line overview As shown in Figure 2, the Flex product family comprises four separate products: • Flex So ware Development Kit (SDK)— e core component library, development languages, and compiler for Flex applications • Flex Builder IDE—An Eclipse-based development environment that includes code editors, visual layout tools, project management tools, and an integrated debugger • Flex Data Services—A Java server-based application that enables high-performance data transfer, cross-tier data synchronization and con ict management, and real-time data messaging • Flex Charting—A library of extensible charting components that enables rapid construction of data visualization applications Figure 2: Members of the Flex product line. Flash Player No discussion of the Flex product would be complete without mentioning Flash Player. Flex applications are deployed as compiled bytecode that is executed within the Flash Player runtime. Installed on over 97% of Internet-connected PCs, Flash Player provides a consistent runtime environment that works across browsers and operating systems, enabling Flex applications to deliver much greater cross-platform compatibility than other RIA technologies. Flash Player provides a unique combination of capabilities that developers can use in their applications, including rich text rendering, powerful graphics APIs, an animation engine, and an integrated audio/video codec. ese capabilities not only contribute to the rich out-of-the-box look and feel displayed in Flex applications, but they are also available to developers who need to construct
  • 17. Demonstrate Sample User Interfaces
  • 18. Flex and Rails - request / response • code samples from Peter Armstrong: pages 10..12 • other code samples
  • 19. package com.anbawn.eile.trn.command { import com.adobe.cairngorm.commands.ICommand; import com.adobe.cairngorm.control.CairngormEvent; import mx.controls.Alert; import mx.rpc.IResponder; import mx.rpc.events.FaultEvent; import mx.rpc.events.ResultEvent; ... public class AccGjDocUpdate implements ICommand, IResponder { public function AccGjDocUpdate() { } public function execute(event : CairngormEvent) : void { var model : AccGjDocsModel = AppModelLocator.getInstance().accGjDocs; var delegate : AccGjDocsDelegate = new AccGjDocsDelegate(this); var doc :AccGjDoc = event.data as AccGjDoc; if (...) { delegate.update(event.data); ... } } public function result(event : Object) : void { var result:Object = event.result; var model : AccGjDocsModel = AppModelLocator.getInstance().accGjDocs; var doc :AccGjDoc; if (result is XML) { var x:XML = XML(result); if (x.name().localName == ...) { doc = AccGjDoc.fromXML(x); model.updateDoc(doc); ... } else if (...errors...) { var errors :ServerErrors; ... Alert.show(quot;Save Record FAILED - see errorsquot;); } else { Alert.show(quot;Save Record FAILED - But errors not available - Unexpected response from serverquot;); } } else { Alert.show(quot;Save Record - Unexpected response from serverquot;); } } } public function fault(event : Object) : void { Main.debug(quot;AccGjDocSave#fault, event = quot; + event); var faultEvent : FaultEvent = FaultEvent(event); Alert.show(quot;AccGjDoc could not be saved!quot;); } } }
  • 20. package com.anbawn.eile.trn.business { import mx.rpc.IResponder; import mx.controls.Alert; import com.anbawn.eile.util.ServiceUtils; import com.anbawn.eile.model.AccGjDoc; public class AccGjDocsDelegate { private var _responder : IResponder; public function AccGjDocsDelegate(responder : IResponder) { _responder = responder; } public function index() : void { ServiceUtils.send(quot;/acc_gj_docs.xmlquot;, _responder); } public function neww() : void { ServiceUtils.send(quot;/acc_gj_docs/new.xmlquot;, _responder); } public function create(rec : AccGjDoc) : void { ServiceUtils.send(quot;/acc_gj_docs.xmlquot;, _responder, quot;POSTquot;, rec.toXML(), true); } public function update(rec : AccGjDoc) : void { ServiceUtils.send(quot;/acc_gj_docs/quot; + rec.id + quot;.xmlquot;, _responder, quot;PUTquot;, rec.toUpdateObject(), false); } public function destroy(rec : AccGjDoc) : void { var params:Object = {}; params[quot;acc_gj_doc[lock_version]quot;] = rec.lock_version; ServiceUtils.send(quot;/acc_gj_docs/quot; + rec.id + quot;.xmlquot;, _responder, quot;DELETEquot;, params, false); } public function show(rec : AccGjDoc) : void { ServiceUtils.send(quot;/acc_gj_docs/quot; + rec.id + quot;.xmlquot;, _responder); } } }
  • 21. package com.anbawn.eile.util { import mx.rpc.IResponder; import mx.rpc.AsyncToken; import mx.rpc.http.HTTPService; public class ServiceUtils { /** * Note: PUT and DELETE don't work with XML since the _method hack * workaround doesn't work. */ public static function send( url:String, responder:IResponder = null, method:String = null, request:Object = null, sendXML:Boolean = false, resultFormat:String = quot;e4xquot;, useProxy:Boolean = false) : void { var service:HTTPService = new HTTPService(); service.url = url; service.contentType = sendXML ? quot;application/xmlquot; : quot;application/x-www-form-urlencodedquot;; service.resultFormat = resultFormat; if (method == null) {//the method wasn't set, so default sensibly service.method = (request == null) ? quot;GETquot; : quot;POSTquot;; } else if ((method == quot;PUTquot;) || (method == quot;DELETEquot;)) { service.method = quot;POSTquot;;//PUT and DELETE don't work in Flash yet if (request == null) { request = new Object(); } request[quot;_methodquot;] = method; } else { service.method = method; } service.request = request; service.useProxy = useProxy; var call:AsyncToken = service.send(); if (responder != null) { call.addResponder(responder); } } } }
  • 22. Flex - views and components • code samples
  • 23. <?xml version=quot;1.0quot; encoding=quot;utf-8quot;?> <!-- ABCList.mxml --> <mx:Panel xmlns:mx=quot;http://www.adobe.com/2006/mxmlquot; title=quot;Listquot; label=quot;AbcThingsquot; layout=quot;verticalquot; width=quot;100%quot; height=quot;100%quot;> <mx:Script> <![CDATA[ import mx.controls.Alert; ... [Bindable] public var model:AbcThingsModel = AppModelLocator.getInstance().abcThings; private function onSelect() : void { ... } private function statusName(item:Object, column:DataGridColumn):String { return item.status.name; } private function currencyCode(item:Object, column:DataGridColumn):String { return item.currency.currency; } ]]> </mx:Script> <mx:DataGrid id=quot;dgquot; x=quot;0quot; y=quot;0quot; width=quot;100%quot; height=quot;100%quot; dataProvider=quot;{model.abcThings}quot; change=quot;onSelect()quot;> <mx:columns> <mx:DataGridColumn headerText=quot;Codequot; dataField=quot;codequot;/> <mx:DataGridColumn headerText=quot;Namequot; dataField=quot;namequot;/> <mx:DataGridColumn headerText=quot;Currencyquot; dataField=quot;currency_idquot; labelFunction=quot;currencyCodequot;/> <mx:DataGridColumn headerText=quot;Statusquot; dataField=quot;status_codequot; labelFunction=quot;statusNamequot;/> </mx:columns> </mx:DataGrid> </mx:Panel>
  • 24. <?xml version=quot;1.0quot; encoding=quot;utf-8quot;?> <!-- ABCEdit.mxml --> <mx:Panel xmlns:mx=quot;http://www.adobe.com/2006/mxmlquot; xmlns:anb=quot;com.anbawn.components.*quot; xmlns=quot;*quot; title=quot;Editquot; layout=quot;verticalquot; width=quot;100%quot; height=quot;100%quot;> <mx:Script> <![CDATA[ import mx.controls.Alert; import mx.core.Application; import mx.events.ValidationResultEvent; import mx.events.CloseEvent; ... [Bindable] public var datarec:AbcThing; [Bindable] private var appModel : AppModelLocator = AppModelLocator.getInstance(); [Bindable] private var model : AbcThingsModel = AppModelLocator.getInstance().abcThings; private function validateAndSubmit():void { var invalid:Boolean = false; var vResult:ValidationResultEvent = nameV.validate(); if (vResult.type == ValidationResultEvent.INVALID) invalid = true; if (invalid) { Alert.show(quot;Validation errors, record not saved.quot;); return; } var rec:AbcThing = new AbcThing( dr_name.text, dr_code.text, 0, //currency_id:int = 0; Currency(cb1.selectedItem), 0, //status_code:int = 0; StatusOfMasterEntity(cb2.selectedItem), datarec.created_by, datarec.created_at, datarec.updated_by, datarec.updated_at, datarec.lock_version, datarec.id); CairngormUtils.dispatchEvent(EventNames.SAVE_ABC_THING, rec); }
  • 25. private function resetForm():void { ... } private function confirmResetForm(event:CloseEvent):void { if (event.detail == Alert.YES) CairngormUtils.dispatchEvent(EventNames.RESET_NEW_THING); } private function doDelete():void { ... } private function confirmDelete(event:CloseEvent):void { if (event.detail == Alert.YES) CairngormUtils.dispatchEvent(EventNames.DELETE_THING, datarec); } ]]> </mx:Script> <mx:StringValidator id=quot;nameVquot; source=quot;{dr_name}quot; property=quot;textquot; required=quot;truequot;/> <mx:HBox> <mx:VBox> <mx:Form id=quot;formH1quot; x=quot;0quot; y=quot;0quot; width=quot;100%quot; height=quot;100%quot; > <mx:FormItem label=quot;Code:quot; required=quot;truequot;> <mx:TextInput id=quot;dr_codequot; text=quot;{datarec.code}quot; /> </mx:FormItem> <mx:FormItem label=quot;Name:quot; required=quot;truequot;> <mx:TextInput id=quot;dr_namequot; text=quot;{datarec.name}quot; /> </mx:FormItem> <mx:FormItem label=quot;Currency:quot;> <mx:ComboBox id=quot;cb1quot; dataProvider=quot;{appModel.currencies}quot; selectedItem=quot;{datarec.currency}quot; labelField=quot;namequot;/> </mx:FormItem> <mx:FormItem label=quot;Status:quot;> <mx:ComboBox id=quot;cb2quot; dataProvider=quot;{appModel.statusesOfMasterEntity}quot; selectedItem=quot;{datarec.status}quot; labelField=quot;namequot;/> </mx:FormItem> </mx:Form>
  • 26. <mx:HBox> <mx:Button visible=quot;{datarec.deleting==false}quot; label=quot;Savequot; click=quot;validateAndSubmit()quot;/> <mx:Button visible=quot;{model.viewState == AppModelLocator.VIEW_STATE_NEW}quot; label=quot;Resetquot; click=quot;resetForm()quot;/> <mx:Button visible= quot;{model.viewState == AppModelLocator.VIEW_STATE_EDIT}quot; label=quot;Deletequot; click=quot;doDelete()quot;/> </mx:HBox> </mx:VBox> </mx:HBox> </mx:Panel>
  • 27. <?xml version=quot;1.0quot; encoding=quot;utf-8quot;?> <!-- CheckBoxXYZ.mxml --> <mx:HBox xmlns:mx=quot;http://www.adobe.com/2006/mxmlquot; horizontalAlign=quot;centerquot;> <mx:Script> <![CDATA[ import mx.controls.DataGrid; public var dataGrid:DataGrid; private function selectRow(event:Event) :void { if ( ... ) { data.selected = !data.selected; if (dataGrid != null) dataGrid.dispatchEvent(new Event(quot;rowSelectEventquot;)); } else //discard the user action by resetting the box cb1.selected = data.selected; } ]]> </mx:Script> <mx:CheckBox id=quot;cb1quot; selected=quot;{data.selected}quot; click=quot;selectRow(event)quot; /> </mx:HBox>
  • 28. package com.anbawn.components { import mx.controls.DataGrid; import mx.collections.ArrayCollection; import flash.display.Sprite; [Event(quot;rowSelectEventquot;)] public class DataGridPlus extends DataGrid { override protected function drawRowBackground(s:Sprite, rowIndex:int, y:Number, height:Number, color:uint, dataIndex:int):void { var dp:ArrayCollection = dataProvider as ArrayCollection; var item:Object; if (dp != null) { if( dataIndex < dp.length ) item = dp.getItemAt(dataIndex); if (item != null && item.selected) color = 0xFFFF00; //yellow //0xFF8800;//orange } super.drawRowBackground(s,rowIndex,y,height,color,dataIndex); } public function myDrawRowBackgrounds() :void { super.drawRowBackgrounds(); } } }
  • 29. Flash Player? • Adobe says... • on more than 97% of internet-enabled PCs • Flash Player 9: 90.3% (June 2007)
  • 30. Flex? • see Peter Armstrong’s Presentation: pages 15..18
  • 31. Flex, Be Aware • not html, hence search engines ! • printing ! • no back button
  • 32. Flex / Rails • Cairngorm • RubyAMF (Aaron Smith) • Resources • www.adobe.com/products/flex • www.flexiblerails.com (see links and resources there)