Top Banner
TMT CALENDAR HTTP Requests, Remoting e ValueObjects
21
Welcome message from author
This document is posted to help you gain knowledge. Please leave a comment to let me know what you think about it! Share it to your friends and learn new things together.
Transcript
Page 1: From A to Web (2009)

TMT CALENDAR

HTTP Requests, Remoting e ValueObjects

Page 2: From A to Web (2009)

AGENDA

1. TMT Calendar

2. HTTP Service e URL Loader

3. RemoteObject

4. ValueObject

5. Confronti

Page 3: From A to Web (2009)

TMT_CALENDAR

Page 4: From A to Web (2009)

TMT_CALENDAR

Page 5: From A to Web (2009)

HTTP REQUEST

• Viene invocato un URL sul server– HttpService – OOP friendly

– URLLoader – simile ad AS2

• I dati sono in formato testuale ( = cast)

Page 6: From A to Web (2009)

HTTPSERVICE - SINTASSI

<mx:HTTPService

id = “myService”

url= “http://www.miapaginacfml.cfm”

resultFormat = “e4x”

fault = “faultHandler(event)”

result = “resultHandler(event)” >

</mx:HTTPService>

Posso lanciare la chiamata con myService.send([parameters])

[parameters] deve essere un tipo base o un XML

Page 7: From A to Web (2009)

ESEMPIO: CONFIG LOADING

• Parametri generati dinamicamente

• Caricato allo startup

• XML

• Nella versione HTML il file viene letto con un accesso al disco,

• <cfsilent> garantisce sicurezza

Page 8: From A to Web (2009)

CONFIG/CALENDAR.CFM

Page 9: From A to Web (2009)

CONFIG/FLEX.CFM

La versione Flex non usa <cfsilent> perchè accede via HTTP

Page 10: From A to Web (2009)

DENTRO IL CONFIGOBJ

Com.lk2.core.components.config.RemoteConfigObj

Page 11: From A to Web (2009)

THE CHICKEN-EGG PROBLEM

• I parametri sono caricati dal configFile

• La path del configFile è un parametro

• Come ottengo l’url del contenitore di param?

• Una soluzione: FlashVars

• Brutto, scomodo e non CF-oriented

Page 12: From A to Web (2009)

LK2SWF

• Un custom tag wrapper per l’SWF e tutti parametri

• I parametri sono configurabili tramite gli attributi del tag

• I parametri dell’applicazione sono passati tramite struct

• Si può usare anche il configXML

• Supporto per il flex debugger

• includeJS – per escludere il JavaScript di caricamento

• alternativeText, alternativeInclude – per gestire la generazione di contenuto in assenza del FlashPlayer

Page 13: From A to Web (2009)

REMOTING

• Invoco direttamente i metodi dei CFC

• I dati sono passati in formato binario

• Posso mandare al client un CFC

Page 14: From A to Web (2009)

REMOTEOBJECT - SINTASSI

<mx:RemoteObject

id = “myRO”

destination= “ColdFusion”

source= “percorso.al.mio.cfc”

</mx:RemoteObject>

I metodi del CFC sono invocati direttamente con myRO.getHelloWorld([parameters])

[parameters] può essere qualunque cosa… anche un’oggetto AS..

Cos’è l’attributo “destination”? (remoting-config.xml)

Definire dei channel dinamici? (RemoteObjectFactory.as)

Page 15: From A to Web (2009)

VALUEOBJECTS

• Mapping 1:1 tra CFC e classi AS3

• Le classi sono legate dal metadato RemoteClass

• ProvaRO

Page 16: From A to Web (2009)

MAPPING DI DATI

String

Array[]

Struct[]

Query

CFC Class

CFC Date

CFC Numeric

CF XML

String

Array

Object (non tipizzato)

ArrayCollection

Object (tipizzato se uso VO)

ActionScript Date

ActionScript Numeric

ActionSctipt XML Object

ColdFusion ActionScript

Page 17: From A to Web (2009)

ACTION MESSAGE FORMAT 3

• Dati Binari

• Dati Compressi

• Similitudini con JAVA RMI

• HTTPS

• Le destinazioni sono in services-config.xml

• Specifiche rilasciate Open

• Implementazioni non solo CF (es. AMFPHP)

• Si può usare anche per invocare comandi sul back-end

• Il Remoting non consente di inviare dati “raw” al CFC

• Come gestisco immagini/audio/ecc.?

Page 18: From A to Web (2009)

CONFRONTI

• Dati nativamente XML (es.configObj)

• E4X

• WebServices

• Prestazioni

• Evita marshall/unmarshall

• Oggetti complessi

HttpService Remoting

Page 19: From A to Web (2009)

RIFERIMENTI

• TMT Calendar (GPL2)

– Demo su http://visual.unipv.it

– SVN su http://code.google.com/p/tmt-calendar/

• LK2SWF (GPL2) e ProvaRO– Scaricabile da http://www.lk2multimedia.com

• LK2FlexFramework (GPL2)

– SVN su http://code.google.com/p/lk2flexframework/

• Slide (a breve) su CFMentor http://www.cfmentor.com

Page 20: From A to Web (2009)

Q & A

Page 21: From A to Web (2009)

Q & A