<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0"
	xmlns:content="http://purl.org/rss/1.0/modules/content/"
	xmlns:wfw="http://wellformedweb.org/CommentAPI/"
	xmlns:dc="http://purl.org/dc/elements/1.1/"
	xmlns:atom="http://www.w3.org/2005/Atom"
	xmlns:sy="http://purl.org/rss/1.0/modules/syndication/"
	xmlns:slash="http://purl.org/rss/1.0/modules/slash/"
	>

<channel>
	<title>MadeInFlex &#187; Tutoriales</title>
	<atom:link href="http://www.madeinflex.com/categoria/tutoriales/feed/" rel="self" type="application/rss+xml" />
	<link>http://www.madeinflex.com</link>
	<description>Creando Soluciones RIA...</description>
	<lastBuildDate>Wed, 30 Nov 2011 16:04:06 +0000</lastBuildDate>
	<generator>http://wordpress.org/?v=2.8.6</generator>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
			<item>
		<title>Mobile ItemRenderer en ActionScript (Parte 1)</title>
		<link>http://www.madeinflex.com/2011/05/18/mobile-itemrenderer-en-actionscript-parte-1/</link>
		<comments>http://www.madeinflex.com/2011/05/18/mobile-itemrenderer-en-actionscript-parte-1/#comments</comments>
		<pubDate>Wed, 18 May 2011 21:09:33 +0000</pubDate>
		<dc:creator>Edgar Parada</dc:creator>
				<category><![CDATA[Flex 4]]></category>
		<category><![CDATA[Tutoriales]]></category>
		<category><![CDATA[dispositivos]]></category>

		<guid isPermaLink="false">http://www.madeinflex.com/?p=2274</guid>
		<description><![CDATA[<!-- matched  --><!-- final 0 -->Recientemente un viejo conocido de la comunidad Flex hispana (Nahuel Foronda) ha publicado una serie de interesantes posts sobre Optimización de Flex para Móviles que iremos posteando traducidos al español, previa autorización   
Si estás comenzando a hacer desarrollo móvil y estás acostumbrado a crear todos los ItemRenderers en MXML, habrás notado que pequeños [...]]]></description>
			<content:encoded><![CDATA[<!-- matched  --><!-- final 0 --><p>Recientemente un viejo conocido de la comunidad Flex hispana (<a href="http://twitter.com/#!/nahuel_es">Nahuel Foronda</a>) ha publicado una serie de interesantes posts sobre <strong>Optimización de Flex para Móviles</strong> que iremos posteando traducidos al español, previa autorización <img src='http://www.madeinflex.com/wp-includes/images/smilies/icon_smile.gif' alt=':-)' class='wp-smiley' />  </p>
<p>Si estás comenzando a hacer desarrollo móvil y estás acostumbrado a crear todos los <em>ItemRenderers</em> en <em>MXML</em>, habrás notado que pequeños dispositivos como teléfonos y tabletas no tienen un desempeño tan bueno como en escritorio y necesitarás buscar diferentes maneras de optimizar tu aplicación.<br />
<span id="more-2274"></span><br />
Una de las formas de optimizar tu aplicación móvil es crear tus <em>ItemRenderers</em> con ActionScript. <a href="http://twitter.com/#!/rictus">Narciso Jaramillo</a> escribió un <a href="http://www.adobe.com/devnet/flex/articles/mobile-development-flex-flashbuilder.html">buen artículo para Devnet</a> con buenos tips para el desarrollo móvil y uno de los puntos es precisamente eso, mantener tus <em>ItemRenderers</em> en puro ActionScript.</p>
<p>Narciso menciona que el Framework de Flex viene con dos <em>ItemRenderers</em> uno es <strong>LabelItemRenderer</strong> que extiende a <strong>UIComponent</strong> y el otro es <strong>IconItemRenderer</strong> que extiende a <strong>LabelItemRenderer</strong>. Esas clases son buenas, pero a veces tenemos un diferente caso de uso que necesita una serie diferente de clases. así que en los ejemplos, no utilizaré esos rendereres. En su lugar, extenderemos directamente desde <strong>UIComponent</strong> o desde <strong>SpriteVisualElement</strong> para tener inclusive una clase más ligera que <strong>UIComponent</strong>.</p>
<p>Para el propósito de este tutorial, estoy planeando una serie de entradas explicando las bases y pasar a <em>renderers</em> con mayor dificultad.</p>
<h2 id="toc-ejemplo-basico">Ejemplo Básico</h2>
<p>Comencemos con el <em>renderer</em> más simple, un <strong>TextField</strong> que muestre algún texto. Para hacerlo sencillo, extenderemos desde <strong>UIComponent</strong> e implementaremos la interfaz <strong>IDataRenderer</strong> requerida por <strong>List</strong>.</p>
<p>Pero antes de hablar sobre el renderer, hablemos de otros elementos.</p>
<h3 id="toc-application">Application</h3>
<p>Necesitas crear un proyecto tipo Mobile. En este ejemplo, usaré el más simple de los contenedores raíz, ese es un Application, no las subclases TabbedApplication o ViewBasedApplication. Agregaremos un List que se expanda al 100% como único elemento.</p>
<p><object classid="clsid:d27cdb6e-ae6d-11cf-96b8-444553540000" codebase="http://fpdownload.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=6,0,0,0" width="500" height="300" id="ftf_wp" align="middle">
		  <param name="movie" value="http://www.madeinflex.com/./wp-content/plugins/FlashTextFormatter/ftf_wp.swf" />
		  <param name="quality" value="high" />
		  <param name="scale" value="noscale" />
		  <param name="bgcolor" value="#ffffff" />
		  <param name="flashvars" value="w=500&#038;h=300&#038;file=http://www.madeinflex.com/index.php&#038;ftf=true&#038;postID=2274&#038;no=0&#038;def=http://www.madeinflex.com./wp-content/plugins/FlashTextFormatter/definitions/as2.xml&#038;auto=true&#038;" />
		  <embed src="http://www.madeinflex.com/./wp-content/plugins/FlashTextFormatter/ftf_wp.swf" quality="high" scale="noscale" bgcolor="#ffffff" width="500" height="300" name="ftf_wp" align="middle" type="application/x-shockwave-flash" pluginspage="http://www.macromedia.com/go/getflashplayer" flashvars="w=500&#038;h=300&#038;file=http://www.madeinflex.com/index.php&#038;ftf=true&#038;postID=2274&#038;no=0&#038;def=http://www.madeinflex.com./wp-content/plugins/FlashTextFormatter/definitions/as2.xml&#038;auto=true&#038;" />
		</object></p>
<h3 id="toc-estilos">Estilos</h3>
<p>Agregué una hoja de estilos externa donde tenemos todos los estilos para el <em>ItemRenderer</em>:</p>
<p><object classid="clsid:d27cdb6e-ae6d-11cf-96b8-444553540000" codebase="http://fpdownload.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=6,0,0,0" width="500" height="200" id="ftf_wp" align="middle">
		  <param name="movie" value="http://www.madeinflex.com/./wp-content/plugins/FlashTextFormatter/ftf_wp.swf" />
		  <param name="quality" value="high" />
		  <param name="scale" value="noscale" />
		  <param name="bgcolor" value="#ffffff" />
		  <param name="flashvars" value="w=500&#038;h=200&#038;file=http://www.madeinflex.com/index.php&#038;ftf=true&#038;postID=2274&#038;no=1&#038;def=http://www.madeinflex.com./wp-content/plugins/FlashTextFormatter/definitions/as2.xml&#038;auto=true&#038;" />
		  <embed src="http://www.madeinflex.com/./wp-content/plugins/FlashTextFormatter/ftf_wp.swf" quality="high" scale="noscale" bgcolor="#ffffff" width="500" height="200" name="ftf_wp" align="middle" type="application/x-shockwave-flash" pluginspage="http://www.macromedia.com/go/getflashplayer" flashvars="w=500&#038;h=200&#038;file=http://www.madeinflex.com/index.php&#038;ftf=true&#038;postID=2274&#038;no=1&#038;def=http://www.madeinflex.com./wp-content/plugins/FlashTextFormatter/definitions/as2.xml&#038;auto=true&#038;" />
		</object></p>
<h3 id="toc-itemrenderer">ItemRenderer</h3>
<p>Tenemos una clase simple que extiende a <strong>UIComponet</strong> que nos da algunos métodos útiles y la habilidad de participar en el framework de CSS.</p>
<p>Estos 3 métodos de <strong>UIComponent</strong> que utilizaremos son los siguientes:</p>
<p><strong>measure</strong> donde nosotros leemos el tamaño mínimo del <em>renderer</em> desde la hoja de estilos. Esto se vuelve útil porque dispositivos con diferentes resoluciones dpi necesitan diferentes medidas.</p>
<p><strong>createChildren</strong> donde nosotros creamos el <strong>TextField</strong>, establecemos los estilos y si hay datos disponibles, configuramos el texto en el <strong>TextField</strong> a ser mostrado.</p>
<p><strong>updateDisplayList</strong> donde posicionamos los elementos y dibujamos cada línea separadora para cada <em>ItemRenderer</em>.</p>
<p>Adicionalmente a estos métodos, tenemos la propiedad <strong>data</strong>, que es la implementación de la iterfaz <strong>IDataRenderer</strong>. Esa interfaz es el contrato con <strong>List</strong> y es la forma en la que los datos son empujados hacia el <em>ItemRenderer</em>. Si el <strong>TextField</strong> existe al momento de configurar los datos, entonces configuramos el texto dentro del TextField, de otra manera, lo guardamos para después.</p>
<p><object classid="clsid:d27cdb6e-ae6d-11cf-96b8-444553540000" codebase="http://fpdownload.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=6,0,0,0" width="500" height="300" id="ftf_wp" align="middle">
		  <param name="movie" value="http://www.madeinflex.com/./wp-content/plugins/FlashTextFormatter/ftf_wp.swf" />
		  <param name="quality" value="high" />
		  <param name="scale" value="noscale" />
		  <param name="bgcolor" value="#ffffff" />
		  <param name="flashvars" value="w=500&#038;h=300&#038;file=http://www.madeinflex.com/index.php&#038;ftf=true&#038;postID=2274&#038;no=2&#038;def=http://www.madeinflex.com./wp-content/plugins/FlashTextFormatter/definitions/as2.xml&#038;auto=true&#038;" />
		  <embed src="http://www.madeinflex.com/./wp-content/plugins/FlashTextFormatter/ftf_wp.swf" quality="high" scale="noscale" bgcolor="#ffffff" width="500" height="300" name="ftf_wp" align="middle" type="application/x-shockwave-flash" pluginspage="http://www.macromedia.com/go/getflashplayer" flashvars="w=500&#038;h=300&#038;file=http://www.madeinflex.com/index.php&#038;ftf=true&#038;postID=2274&#038;no=2&#038;def=http://www.madeinflex.com./wp-content/plugins/FlashTextFormatter/definitions/as2.xml&#038;auto=true&#038;" />
		</object></p>
<p>Como pueden ver escribir un ItemRenderer en ActionScript no es tan difícil como suena.</p>
<p>Estoy planeando mostrar otros ejemplos en el futuro con múltiples elementos, fondos, estados, manipulación de texto, columnas múltiples y más.</p>
<p><a href="http://www.asfusion.com/assets/content//tutorialFiles/renderers/renderers_1.zip">El código fuente esta disponible para descargar.</a></p>
<p>Nota: Este artículo está traducido en MadeInFlex con autorización previa del autor, si quieren consultar la fuente original <a href="http://www.asfusion.com/blog/entry/mobile-itemrenderer-in-actionscript-part-1">aquí tienen el enlace.</a></p>]]></content:encoded>
			<wfw:commentRss>http://www.madeinflex.com/2011/05/18/mobile-itemrenderer-en-actionscript-parte-1/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Lazy loading desde Flex con Pimento y Cinnamon</title>
		<link>http://www.madeinflex.com/2010/12/09/lazy-loading-desde-flex-con-pimento-y-cinnamon/</link>
		<comments>http://www.madeinflex.com/2010/12/09/lazy-loading-desde-flex-con-pimento-y-cinnamon/#comments</comments>
		<pubDate>Thu, 09 Dec 2010 07:08:13 +0000</pubDate>
		<dc:creator>Nono F. Carballo Escalona</dc:creator>
				<category><![CDATA[Artículos]]></category>
		<category><![CDATA[Flex 4]]></category>
		<category><![CDATA[Tutoriales]]></category>

		<guid isPermaLink="false">http://www.madeinflex.com/?p=1947</guid>
		<description><![CDATA[<!-- matched  --><!-- final 0 -->El ejemplo
Conclusiones


El framework Pimento Data Services nos permite realizar el “lazy loading” de una asociación que haya sido configurada como “lazy” en JPA. Para ese tipo de asociación el framework envía al cliente solamente “proxies”, no los datos reales, los datos reales serán cargados en el momento que se invoque el método “initialize” de la [...]]]></description>
			<content:encoded><![CDATA[<!-- matched  --><!-- final 0 --><p><span id="more-1947"></span><br />
<!--noteaser--></p>
<div class="toc">
<ol>
<li><a href="http://www.madeinflex.com/2010/12/09/lazy-loading-desde-flex-con-pimento-y-cinnamon/#toc-el-ejemplo">El ejemplo</a></li>
<li><a href="http://www.madeinflex.com/2010/12/09/lazy-loading-desde-flex-con-pimento-y-cinnamon/#toc-conclusiones">Conclusiones</a></li>
</ol>
</div>
<p>El framework Pimento Data Services nos permite realizar el “lazy loading” de una asociación que haya sido configurada como “lazy” en JPA. Para ese tipo de asociación el framework envía al cliente solamente “proxies”, no los datos reales, los datos reales serán cargados en el momento que se invoque el método “initialize” de la clase EntityManager, y no obtendremos una excepción del tipo LazyInitializationException. Veamos cómo funciona a través de un ejemplo.</p>
<h4 id="toc-el-ejemplo">El ejemplo</h4>
<p>Lo primero será descargar el framework de <a href="http://www.spicefactory.org/pimento/download.php">aquí</a>. Luego creamos un proyecto de tipo “Dynamic Web Project” con las siguientes características:</p>
<ul>
<li>Nombre del proyecto: LazyPimentoServer</li>
<li>Target Runtime: En nuestro caso usaremos Apache Tomcat 6, pero puede utilizarse  cualquier otro que se haya configurado.</li>
<li>Versión del módulo Web Dinámico: 2.5</li>
<li>Configuración: Configuración por defecto para Apache Tomcat 6.0</li>
<li>Cambiamos la carpeta donde se compilarán las clases a “LazyPimentoServer/WebContent/WEB-INF/classes”.</li>
</ul>
<p>Una vez creado el proyecto copiamos el contenido de la carpeta “server/web/WEB-INF/lib” de la distribución del framework en “WebContent/WEB-INF/lib” de nuestro proyecto. Sustituimos el archivo de HSQLDB por el controlador JDBC de MySQL, y copiamos de la carpeta “server/release” los archivos “cinnamon-core”, “cinnamon-reflect” y “pimento-core”. Necesitamos copiar también el paquete “javassist”, este lo podemos encontrar en la distribución de Spring con dependencias.</p>
<p>Creamos una carpeta denominada “config” dentro de “WebContent/WEB-INF” de nuestro proyecto y copiamos los archivos “jpa-spring.xml” y “pimento-spring.xml” en “server/web/WEB-INF/config” en la distribución del framework; también copiamos el archivo “dp.properties.template.mysql” de “server/web/WEB-INF/config/db-templates” como “db.properties” en “WebContent/WEB-INF/config” de nuestro proyecto y ajustamos los valores de la conexión a la base de datos. Como estamos en fase de desarrollo ponemos “hibernate.hbm2ddl.auto=update”.</p>
<p>Finalmente el archivo “web.xml” de nuestro proyecto queda así:</p>
<p><object classid="clsid:d27cdb6e-ae6d-11cf-96b8-444553540000" codebase="http://fpdownload.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=6,0,0,0" width="500" height="200" id="ftf_wp" align="middle">
		  <param name="movie" value="http://www.madeinflex.com/./wp-content/plugins/FlashTextFormatter/ftf_wp.swf" />
		  <param name="quality" value="high" />
		  <param name="scale" value="noscale" />
		  <param name="bgcolor" value="#ffffff" />
		  <param name="flashvars" value="w=500&#038;h=200&#038;file=http://www.madeinflex.com/index.php&#038;ftf=true&#038;postID=1947&#038;no=0&#038;def=http://www.madeinflex.com./wp-content/plugins/FlashTextFormatter/definitions/as2.xml&#038;auto=true&#038;" />
		  <embed src="http://www.madeinflex.com/./wp-content/plugins/FlashTextFormatter/ftf_wp.swf" quality="high" scale="noscale" bgcolor="#ffffff" width="500" height="200" name="ftf_wp" align="middle" type="application/x-shockwave-flash" pluginspage="http://www.macromedia.com/go/getflashplayer" flashvars="w=500&#038;h=200&#038;file=http://www.madeinflex.com/index.php&#038;ftf=true&#038;postID=1947&#038;no=0&#038;def=http://www.madeinflex.com./wp-content/plugins/FlashTextFormatter/definitions/as2.xml&#038;auto=true&#038;" />
		</object></p>
<p>Seguidamente crearemos las entidades asociadas:</p>
<p>Project</p>
<p><object classid="clsid:d27cdb6e-ae6d-11cf-96b8-444553540000" codebase="http://fpdownload.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=6,0,0,0" width="500" height="200" id="ftf_wp" align="middle">
		  <param name="movie" value="http://www.madeinflex.com/./wp-content/plugins/FlashTextFormatter/ftf_wp.swf" />
		  <param name="quality" value="high" />
		  <param name="scale" value="noscale" />
		  <param name="bgcolor" value="#ffffff" />
		  <param name="flashvars" value="w=500&#038;h=200&#038;file=http://www.madeinflex.com/index.php&#038;ftf=true&#038;postID=1947&#038;no=1&#038;def=http://www.madeinflex.com./wp-content/plugins/FlashTextFormatter/definitions/as2.xml&#038;auto=true&#038;" />
		  <embed src="http://www.madeinflex.com/./wp-content/plugins/FlashTextFormatter/ftf_wp.swf" quality="high" scale="noscale" bgcolor="#ffffff" width="500" height="200" name="ftf_wp" align="middle" type="application/x-shockwave-flash" pluginspage="http://www.macromedia.com/go/getflashplayer" flashvars="w=500&#038;h=200&#038;file=http://www.madeinflex.com/index.php&#038;ftf=true&#038;postID=1947&#038;no=1&#038;def=http://www.madeinflex.com./wp-content/plugins/FlashTextFormatter/definitions/as2.xml&#038;auto=true&#038;" />
		</object></p>
<p>Task<br />
<object classid="clsid:d27cdb6e-ae6d-11cf-96b8-444553540000" codebase="http://fpdownload.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=6,0,0,0" width="500" height="200" id="ftf_wp" align="middle">
		  <param name="movie" value="http://www.madeinflex.com/./wp-content/plugins/FlashTextFormatter/ftf_wp.swf" />
		  <param name="quality" value="high" />
		  <param name="scale" value="noscale" />
		  <param name="bgcolor" value="#ffffff" />
		  <param name="flashvars" value="w=500&#038;h=200&#038;file=http://www.madeinflex.com/index.php&#038;ftf=true&#038;postID=1947&#038;no=2&#038;def=http://www.madeinflex.com./wp-content/plugins/FlashTextFormatter/definitions/as2.xml&#038;auto=true&#038;" />
		  <embed src="http://www.madeinflex.com/./wp-content/plugins/FlashTextFormatter/ftf_wp.swf" quality="high" scale="noscale" bgcolor="#ffffff" width="500" height="200" name="ftf_wp" align="middle" type="application/x-shockwave-flash" pluginspage="http://www.macromedia.com/go/getflashplayer" flashvars="w=500&#038;h=200&#038;file=http://www.madeinflex.com/index.php&#038;ftf=true&#038;postID=1947&#038;no=2&#038;def=http://www.madeinflex.com./wp-content/plugins/FlashTextFormatter/definitions/as2.xml&#038;auto=true&#038;" />
		</object></p>
<p>Como vemos son dos entidades JPA con anotaciones de Pimento que indican que serán gestionadas por éste. La entidad “Project” tiene una asociación con la entidad “Task” de tipo OneToMany configurada como “lazy”, lo que implica que cuando se cargue una instancia de “Project” no se cargarán en ese instante las instancias de “Task” asociadas con ésta. En este caso el framework enviará al cliente “proxies” que serán utilizados para cargar los datos reales. Veamos cómo funciona esto desde la UI, pero primero cargaremos algunos datos en la base de datos:</p>
<p><object classid="clsid:d27cdb6e-ae6d-11cf-96b8-444553540000" codebase="http://fpdownload.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=6,0,0,0" width="500" height="200" id="ftf_wp" align="middle">
		  <param name="movie" value="http://www.madeinflex.com/./wp-content/plugins/FlashTextFormatter/ftf_wp.swf" />
		  <param name="quality" value="high" />
		  <param name="scale" value="noscale" />
		  <param name="bgcolor" value="#ffffff" />
		  <param name="flashvars" value="w=500&#038;h=200&#038;file=http://www.madeinflex.com/index.php&#038;ftf=true&#038;postID=1947&#038;no=3&#038;def=http://www.madeinflex.com./wp-content/plugins/FlashTextFormatter/definitions/as2.xml&#038;auto=true&#038;" />
		  <embed src="http://www.madeinflex.com/./wp-content/plugins/FlashTextFormatter/ftf_wp.swf" quality="high" scale="noscale" bgcolor="#ffffff" width="500" height="200" name="ftf_wp" align="middle" type="application/x-shockwave-flash" pluginspage="http://www.macromedia.com/go/getflashplayer" flashvars="w=500&#038;h=200&#038;file=http://www.madeinflex.com/index.php&#038;ftf=true&#038;postID=1947&#038;no=3&#038;def=http://www.madeinflex.com./wp-content/plugins/FlashTextFormatter/definitions/as2.xml&#038;auto=true&#038;" />
		</object></p>
<p>Creamos un proyecto Flex con las siguientes características:</p>
<ul>
<li>Nombre del proyecto: LazyPimentoClient</li>
<li>Tipo de aplicación: Web</li>
<li>Seleccionamos el SDK por defecto</li>
<li>Como tecnología del servidor no seleccionamos ninguna</li>
<li>Como carpeta de salida seleccionamos la carpeta WebContent del proyecto LazyPimentoServer que creamos anteriormente.</li>
</ul>
<p>Nuestra interface de usuario sería algo como esto:</p>
<p><a href="http://www.madeinflex.com/wp-content/uploads/2010/11/1.png"><img src="http://www.madeinflex.com/wp-content/uploads/2010/11/1.png" alt="1" title="1" width="281" height="203" class="aligncenter size-full wp-image-1948" /></a></p>
<p>Inicialmente cargaremos una instancia de Project e inspeccionaremos el contenido de su propiedad “tasks”, luego cargaremos las instancias de “Task” asociadas mediante el método “initialize” de la clase EntityManager, las cuales mostraremos en el “DataGrid”.</p>
<p>Para estructurar mejor el proyecto nos auxiliaremos del framework Robotlegs. Lo primero que haremos será incluir en el proyecto las librerías del framework Pimento y Cinnamon. Copiamos en la carpeta “libs” del proyecto los archivos “cinnamon-1.1.0.swc” y “pimento-1.1.0.swc” que se encuentran en la carpeta “client\release” de la distribución, incluimos también “spicelib-core-2.0.1.swc” y “spicelib-reflect-2.0.1.swc” de la carpeta “client\lib” y la librería del framework Robotlegs.</p>
<p>Creamos luego las clases en ActionScript que representan las entidades:</p>
<p>Project<br />
<object classid="clsid:d27cdb6e-ae6d-11cf-96b8-444553540000" codebase="http://fpdownload.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=6,0,0,0" width="500" height="200" id="ftf_wp" align="middle">
		  <param name="movie" value="http://www.madeinflex.com/./wp-content/plugins/FlashTextFormatter/ftf_wp.swf" />
		  <param name="quality" value="high" />
		  <param name="scale" value="noscale" />
		  <param name="bgcolor" value="#ffffff" />
		  <param name="flashvars" value="w=500&#038;h=200&#038;file=http://www.madeinflex.com/index.php&#038;ftf=true&#038;postID=1947&#038;no=4&#038;def=http://www.madeinflex.com./wp-content/plugins/FlashTextFormatter/definitions/as2.xml&#038;auto=true&#038;" />
		  <embed src="http://www.madeinflex.com/./wp-content/plugins/FlashTextFormatter/ftf_wp.swf" quality="high" scale="noscale" bgcolor="#ffffff" width="500" height="200" name="ftf_wp" align="middle" type="application/x-shockwave-flash" pluginspage="http://www.macromedia.com/go/getflashplayer" flashvars="w=500&#038;h=200&#038;file=http://www.madeinflex.com/index.php&#038;ftf=true&#038;postID=1947&#038;no=4&#038;def=http://www.madeinflex.com./wp-content/plugins/FlashTextFormatter/definitions/as2.xml&#038;auto=true&#038;" />
		</object></p>
<p>Task<br />
<object classid="clsid:d27cdb6e-ae6d-11cf-96b8-444553540000" codebase="http://fpdownload.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=6,0,0,0" width="500" height="200" id="ftf_wp" align="middle">
		  <param name="movie" value="http://www.madeinflex.com/./wp-content/plugins/FlashTextFormatter/ftf_wp.swf" />
		  <param name="quality" value="high" />
		  <param name="scale" value="noscale" />
		  <param name="bgcolor" value="#ffffff" />
		  <param name="flashvars" value="w=500&#038;h=200&#038;file=http://www.madeinflex.com/index.php&#038;ftf=true&#038;postID=1947&#038;no=5&#038;def=http://www.madeinflex.com./wp-content/plugins/FlashTextFormatter/definitions/as2.xml&#038;auto=true&#038;" />
		  <embed src="http://www.madeinflex.com/./wp-content/plugins/FlashTextFormatter/ftf_wp.swf" quality="high" scale="noscale" bgcolor="#ffffff" width="500" height="200" name="ftf_wp" align="middle" type="application/x-shockwave-flash" pluginspage="http://www.macromedia.com/go/getflashplayer" flashvars="w=500&#038;h=200&#038;file=http://www.madeinflex.com/index.php&#038;ftf=true&#038;postID=1947&#038;no=5&#038;def=http://www.madeinflex.com./wp-content/plugins/FlashTextFormatter/definitions/as2.xml&#038;auto=true&#038;" />
		</object></p>
<p>La configuración del framework en el cliente comienza con la creación de una instancia de la clase “PimentoConfig”, a través de la cual podemos obtener el “EntityManager” que usaremos para invocar las operaciones de persistencia. La clase PimentoConfig necesita conocer el URL de la aplicación JEE que a través de Cinnamon recibirá las solicitudes del cliente para invocar las operaciones de persistencia, específicamente el URL al servlet “service”. En nuestro caso cargaremos esta información de un archivo xml externo. El comando que hace todo esto y además carga la instancia de “Project” que insertamos en la base de datos es el siguiente:</p>
<p><object classid="clsid:d27cdb6e-ae6d-11cf-96b8-444553540000" codebase="http://fpdownload.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=6,0,0,0" width="500" height="200" id="ftf_wp" align="middle">
		  <param name="movie" value="http://www.madeinflex.com/./wp-content/plugins/FlashTextFormatter/ftf_wp.swf" />
		  <param name="quality" value="high" />
		  <param name="scale" value="noscale" />
		  <param name="bgcolor" value="#ffffff" />
		  <param name="flashvars" value="w=500&#038;h=200&#038;file=http://www.madeinflex.com/index.php&#038;ftf=true&#038;postID=1947&#038;no=6&#038;def=http://www.madeinflex.com./wp-content/plugins/FlashTextFormatter/definitions/as2.xml&#038;auto=true&#038;" />
		  <embed src="http://www.madeinflex.com/./wp-content/plugins/FlashTextFormatter/ftf_wp.swf" quality="high" scale="noscale" bgcolor="#ffffff" width="500" height="200" name="ftf_wp" align="middle" type="application/x-shockwave-flash" pluginspage="http://www.macromedia.com/go/getflashplayer" flashvars="w=500&#038;h=200&#038;file=http://www.madeinflex.com/index.php&#038;ftf=true&#038;postID=1947&#038;no=6&#038;def=http://www.madeinflex.com./wp-content/plugins/FlashTextFormatter/definitions/as2.xml&#038;auto=true&#038;" />
		</object></p>
<p>Si corremos la aplicación con el “debugger” y nos paramos dentro del método loadResult veremos que el tipo de la propiedad “tasks” de Project no es un “Array” como está definido sino de tipo “ArrayProxy”.</p>
<p><a href="http://www.madeinflex.com/wp-content/uploads/2010/11/2.png"><img src="http://www.madeinflex.com/wp-content/uploads/2010/11/2.png" alt="2" title="2" width="504" height="248" class="aligncenter size-full wp-image-1949" /></a></p>
<p>Una vez cargada la instancia de Project, ante el evento “Click” del botón se ejecuta el comando que carga los datos de la asociación:</p>
<p><object classid="clsid:d27cdb6e-ae6d-11cf-96b8-444553540000" codebase="http://fpdownload.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=6,0,0,0" width="500" height="200" id="ftf_wp" align="middle">
		  <param name="movie" value="http://www.madeinflex.com/./wp-content/plugins/FlashTextFormatter/ftf_wp.swf" />
		  <param name="quality" value="high" />
		  <param name="scale" value="noscale" />
		  <param name="bgcolor" value="#ffffff" />
		  <param name="flashvars" value="w=500&#038;h=200&#038;file=http://www.madeinflex.com/index.php&#038;ftf=true&#038;postID=1947&#038;no=7&#038;def=http://www.madeinflex.com./wp-content/plugins/FlashTextFormatter/definitions/as2.xml&#038;auto=true&#038;" />
		  <embed src="http://www.madeinflex.com/./wp-content/plugins/FlashTextFormatter/ftf_wp.swf" quality="high" scale="noscale" bgcolor="#ffffff" width="500" height="200" name="ftf_wp" align="middle" type="application/x-shockwave-flash" pluginspage="http://www.macromedia.com/go/getflashplayer" flashvars="w=500&#038;h=200&#038;file=http://www.madeinflex.com/index.php&#038;ftf=true&#038;postID=1947&#038;no=7&#038;def=http://www.madeinflex.com./wp-content/plugins/FlashTextFormatter/definitions/as2.xml&#038;auto=true&#038;" />
		</object></p>
<p>El método que carga los datos de la asociación es “initialize”, de “EntityManager”, se le pasa como argumento la propiedad “tasks” de la instancia de “Project” previamente cargada.</p>
<p>Una vez más, si corremos la aplicación con el “debugger” y nos paramos dentro del método “initializeResult” veremos que el tipo de la propiedad “tasks” ha cambiado de “ArrayProxy” a “Array”, conteniendo las instancias de “Tasks” asociadas.</p>
<p><a href="http://www.madeinflex.com/wp-content/uploads/2010/11/3.png"><img src="http://www.madeinflex.com/wp-content/uploads/2010/11/3.png" alt="3" title="3" width="514" height="123" class="aligncenter size-full wp-image-1950" /></a></p>
<p>El código fuente del la aplicación, cliente y servidor se puede descargar de <a href='http://www.madeinflex.com/wp-content/uploads/2010/11/LazyPimentoCinnamonDemo.zip'>aquí</a>.</p>
<h4 id="toc-conclusiones">Conclusiones</h4>
<p>Hemos visto como Pimento Data Services nos permite hacer “lazy loading” de entidades directamente desde ActionScript de una forma verdaderamente simple. Tan solo debemos poner las anotaciones en la entidad Java y el framework se encarga del resto, es una lástima que Pimento y Cinnamon no soporten ninguna funcionalidad que permita hacer sincronización de datos entre varios clientes. ¿Alguien se anima?</p>]]></content:encoded>
			<wfw:commentRss>http://www.madeinflex.com/2010/12/09/lazy-loading-desde-flex-con-pimento-y-cinnamon/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Creación de componentes gráficos ligeros con Spark</title>
		<link>http://www.madeinflex.com/2010/10/23/clases-spark-para-crear-componentes-ligeros/</link>
		<comments>http://www.madeinflex.com/2010/10/23/clases-spark-para-crear-componentes-ligeros/#comments</comments>
		<pubDate>Sat, 23 Oct 2010 14:44:34 +0000</pubDate>
		<dc:creator>Sergi Dote Teixidor</dc:creator>
				<category><![CDATA[Artículos]]></category>
		<category><![CDATA[Flex 4]]></category>
		<category><![CDATA[Tutoriales]]></category>

		<guid isPermaLink="false">http://www.madeinflex.com/?p=1814</guid>
		<description><![CDATA[<!-- matched  --><!-- final 0 -->Al crear componentes en Flex, siempre deberíamos tener en mente la optimización: un componente más ligero ocupará menos memoria y repercutirá positivamente en la respuesta de la aplicación. Es un punto importantísimo, aunque, a menudo, no lo tengamos en cuenta, posiblemente debido a que cada vez tenemos equipos más potentes.
Es necesario si queremos tender a [...]]]></description>
			<content:encoded><![CDATA[<!-- matched  --><!-- final 0 --><p>Al crear componentes en Flex, siempre deberíamos tener en mente la optimización: un componente más ligero ocupará menos memoria y repercutirá positivamente en la respuesta de la aplicación. Es un punto importantísimo, aunque, a menudo, no lo tengamos en cuenta, posiblemente debido a que cada vez tenemos equipos más potentes.<br />
Es necesario si queremos tender a una programación que no exija un consumo de memoria excesivo y que no perjudique la performance de la aplicación, y es imprescindible para desarrollar aplicaciones con Flex para mobile devices.<br />
<span id="more-1814"></span><br />
Distintos tutoriales de Flex 4 explican que para crear componentes custom, extendamos SkinnableComponent, le demos el comportamiento deseado, tratemos los eventos y estados del componente y que finalmente creemos la skin para tener la representación visual del componente. </p>
<p>Después de leer varios artículos he descubierto unas clases que pueden ayudar a la creación de componentes gráficos custom y que quisiera compartir con vosotros.<br />
<strong><br />
<h2 id="toc-spritevisualelement">SpriteVisualElement</h2>
<p></strong></p>
<p>Una de las clases de las que quiero hablar en este post es SpriteVisualElement.</p>
<h4 id="toc-comparacion-entre-spritevisualelement-y-uicomponent">Comparación entre SpriteVisualElement y UIComponent</h4>
<p>Comparando esta clase con UIComponent, que es la clase base que se suele usar para componentes visuales, tanto los interactivos, como los que no, vemos que SpriteVisualElement parece ser más light-weight, ya no sólo pro el número de líneas que contiene esta clase (2900 aprox. UIComponent tiene unas 13000), sino por el número de interfaces que deben implementar cada una (SpriteVisualElement implementa 3 interfaces, UIComponent implementa 16). </p>
<p>UIComponent aporta más características, pero si no las necesitamos, SpriteVisualElement es la clase base ideal.</p>
<p>En la página de SpriteVisualElement dentro de la Language Reference, se describe como la clase más ligera para las implementaciones basadas en Sprite de la interface IVisualElement y que los layouts Spark pueden gestionar objetos de este tipo. </p>
<p>Si usamos ActionScript para añadir un componente FXG a nuestra aplicación, éste debe ser de tipo SpriteVisualElement. IVisualElement proporciona las constraints de layout tal que height, width, top, right, bottom, left&#8230;</p>
<p>Otro punto importante es que al ser una clase hija de Sprite, tiene las características de cualquier Flash interactive object, es un Sprite que puede ser usado en arquitecturas Spark.</p>
<h4 id="toc-creacion-de-un-custom-spritevisualelement-component">Creación de un Custom SpriteVisualElement component</h4>
<p>El <a href="http://www.madeinflex.com/wp-content/uploads/2010/10/OptimizedComponents.zip">proyecto</a> que adjunto viene a ser como un cronómetro: haciendo click sobre él, podemos ponerlo en marcha o pararlo.</p>
<h4 id="toc-pasos-en-la-vida-del-componente">Pasos en la vida del componente</h4>
<p>Al crear custom components debemos tener muy en cuenta el ciclo de vida del componente, y en este caso las dimensiones y layout del componente, importante a la hora de redibujarlo. Durante el proceso de layout del componente, Spark hace una llamada a setLayoutBoundsSize(width, height, postLayoutTransform), que determina las dimensiones del componente en la disposición de éste, es decir, las dimensiones que usa para dibujarse.<br />
La llamada a setLayoutBoundsSize puede afectar a la posición del layout. Podemos llamar setLayoutBoundPosition()  después de haber llamado a setLayoutBoundSize() para reubicar el componente.<br />
En el código de ejemplo la función setLayoutBoundsSize ha sido sobrescrita:</p>
<p><object classid="clsid:d27cdb6e-ae6d-11cf-96b8-444553540000" codebase="http://fpdownload.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=6,0,0,0" width="500" height="120" id="ftf_wp" align="middle">
		  <param name="movie" value="http://www.madeinflex.com/./wp-content/plugins/FlashTextFormatter/ftf_wp.swf" />
		  <param name="quality" value="high" />
		  <param name="scale" value="noscale" />
		  <param name="bgcolor" value="#ffffff" />
		  <param name="flashvars" value="w=500&#038;h=120&#038;file=http://www.madeinflex.com/index.php&#038;ftf=true&#038;postID=1814&#038;no=0&#038;def=http://www.madeinflex.com./wp-content/plugins/FlashTextFormatter/definitions/as2.xml&#038;auto=true&#038;" />
		  <embed src="http://www.madeinflex.com/./wp-content/plugins/FlashTextFormatter/ftf_wp.swf" quality="high" scale="noscale" bgcolor="#ffffff" width="500" height="120" name="ftf_wp" align="middle" type="application/x-shockwave-flash" pluginspage="http://www.macromedia.com/go/getflashplayer" flashvars="w=500&#038;h=120&#038;file=http://www.madeinflex.com/index.php&#038;ftf=true&#038;postID=1814&#038;no=0&#038;def=http://www.madeinflex.com./wp-content/plugins/FlashTextFormatter/definitions/as2.xml&#038;auto=true&#038;" />
		</object></p>
<p>Cuando el componente cambie una propiedad que afecte a su distribución y repintado, debemos invalidarlo para que Flex lo redibuje. Lo haremos con invalidateParentSizeAndDisplayList().</p>
<p><object classid="clsid:d27cdb6e-ae6d-11cf-96b8-444553540000" codebase="http://fpdownload.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=6,0,0,0" width="500" height="120" id="ftf_wp" align="middle">
		  <param name="movie" value="http://www.madeinflex.com/./wp-content/plugins/FlashTextFormatter/ftf_wp.swf" />
		  <param name="quality" value="high" />
		  <param name="scale" value="noscale" />
		  <param name="bgcolor" value="#ffffff" />
		  <param name="flashvars" value="w=500&#038;h=120&#038;file=http://www.madeinflex.com/index.php&#038;ftf=true&#038;postID=1814&#038;no=1&#038;def=http://www.madeinflex.com./wp-content/plugins/FlashTextFormatter/definitions/as2.xml&#038;auto=true&#038;" />
		  <embed src="http://www.madeinflex.com/./wp-content/plugins/FlashTextFormatter/ftf_wp.swf" quality="high" scale="noscale" bgcolor="#ffffff" width="500" height="120" name="ftf_wp" align="middle" type="application/x-shockwave-flash" pluginspage="http://www.macromedia.com/go/getflashplayer" flashvars="w=500&#038;h=120&#038;file=http://www.madeinflex.com/index.php&#038;ftf=true&#038;postID=1814&#038;no=1&#038;def=http://www.madeinflex.com./wp-content/plugins/FlashTextFormatter/definitions/as2.xml&#038;auto=true&#038;" />
		</object></p>
<p>Al producirse esta invalidación, Flex lanza la función setLayoutBoundsSize para repintar el componente con los nuevos cambios en las propiedades.</p>
<p><strong><br />
<h2 id="toc-graphicelement">GraphicElement</h2>
<p></strong></p>
<p>Es una clase más ligera que SpriteVisualElement, poniéndose, en cuanto a jerarquía, al nivel de DisplayObject. Es la clase base para definir un elemento gráfico, como shapes, text o images. Al definir un objeto gráfico, debemos especificar las dimensiones del elemento, pero no nos permite usar una especificación de éstas en valores porcentuales.</p>
<p>En este <a href="http://www.hulstkamp.com/byard/flex4/AHFlowerGraphicElement/AHFlowerTest.html">ejemplo</a>,el autor nos muestra un uso adecuado de esta clase. </p>
<p>Debemos tener claros dos conceptos: las fronteras que delimita un determinado objeto dentro del espacio de coordenadas del padre y las fronteras que delimita dentro de su propio espacio de coordenadas. </p>
<p>Para hacer transformaciones necesitamos la clase Matrix, lo que sobrescribe valores de transformación previamente definidos como rotation, scaleX, scaleY, x e y. Si setteamos transform.matrix o las propiedades de transformación en ActionScript, se usarán los últimos valores aplicados.</p>
<p>La responsabilidad de la clase GraphicElement y sus subclases es la de dibujar componentes gráficos Spark, componentes FXG que parten de GraphicElement.</p>
<p>No confundir GraphicElement con DisplayObject, ya que la primera no nos da ningún tipo de interacción. GraphicElement usa un DisplayObject interno para dibujarse. Dentro del mismo display object podemos dibujar varios elementos gráficos. Así reducimos sobrecarga y damos un mayor rendimiento. </p>
<p>Será necesario implementar ciertas interfaces  como IVisualElement y IGraphicElement y así poder ser dibujada y dispuesta por Spark.</p>
<p>Puntos claves de GraphicElement:</p>
<ul>
<li>GraphicElement usa un DisplayObject, que puede ser compartido, para dibujar dentro de él.</li>
<li>Cuando un GraphicElement necesita ser repintado, todos los elementos gráficos que comparten el mismo DisplayObject se redibujan.</li>
<li>Al crear un GraphicElement que comparte un display object con otros elementos gráficos, debemos asegurarnos de no hacer un clear de la instancia graphics, esto eliminaría las anteriores representaciones hechas por otros elementos.</li>
<li>Si aplicamos ciertas propiedades al DisplayObject, éstas serán aplicadas a todos los elementos gráficos  que compartan este display object. Esto implica que el uso de filtros, transformaciones, etc., a una determinada instancia, requieren que el GraphicElement tenga su display object propio. Con la implementación estándar lo solucionamos.</li>
<li>GraphicElement necesita acceder a una instancia de graphics para dibujar. Podemos extraer esta referencia de la propiedad drawnDisplayObject de GraphicElement.</li>
<li>Al dibujar, debemos tener en cuenta el desplazamiento del elemento gráfico en relación a su objeto de visualización.</li>
</ul>
<h4 id="toc-creacion-de-un-custom-graphicelement">Creación de un custom GraphicElement</h4>
<p>Con FXG y el elemento Path, dibujamos la mayoría de elementos gráficos. Un Path se representa en un display object. A veces nos será más fácil crear elementos gráficos con GraphicElement, sobre todo cuando el elemento a dibujar es dinámico en cuando a cambio en su forma.</p>
<p>Al crear un GraphicElement custom debemos considerar lo siguiente:</p>
<ul>
<li>Sobrescribir la function updateDisplayList() para refrescar el dibujado del elemento.</li>
<li>Usar una instancia de graphics para dibujar: (drawnDisplayObject as Sprite).graphics.</li>
<li>Respetar las coordenadas del objeto GraphicElement en relación de su DisplayObject, mediante las propiedades drawX y drawY de la clase GraphicElement.</li>
<li>La función que dibuje el elemento no puede hacer un clear de graphics, ya que el DisplayObject asociado puede ser compartido y esto provoca el borrado de los gráficos de otros elementos.</li>
<li>GraphicElement implementa la interface IInvalidating para tomar parte en el proceso de invalidación. Si una propiedad que afecta al repintado del elemento es setteada, debemos invalidar este elemento y actualizarlo en el paso de validación.</li>
</ul>
<h4 id="toc-control-del-display-object-compartido">Control del display object compartido</h4>
<p>El control de los display objects asociados a un GraphicElement lo hace Flex. Si necesitamos manipular personalmente el DisplayObject en lugar de dejárselo a Flex, se nos ofrece diferentes vías:</p>
<ul>
<li>needsDisplayObject() nos permite determinar si el GraphicElement necesita su propio display object. La implementación por defecto comprueba si hay propiedades que requieren un display object propio (rotation, color transformation, blend modes, etc.).</li>
<li>
canShareWithNext() dice si el display object puede compartirse con el siguiente IGraphicElement de la secuencia.</li>
<li>canShareWithPrevious() nos dice si el display object puede compartirse con el anterior IGraphicElement de la secuencia.</li>
<li>Cuidado con el uso de displaySharingMode. No funciona como se espera, ya que Flex la usa para administrar los objetos. Si la usamos, los valores se sobrescribirán manualmente.</li>
<li>Si Flex necesita crear un display object para un determinado GraphicElement, invoca la función itscreateDisplayObject(). La implementación por defecto  nos devuelve un objeto de tipo InvalidatingSprite que implementa la interface ISharedDisplayObject.</li>
<p></lu></p>
<h4 id="toc-interaccion">Interacción</h4>
<p>GraphicElement tiene como finalidad dibujar gráficos de manera optimizada, compartiendo display objects. No está pensado como elemento de interacción, el elemento se incrusta en el container Spark y la interacción debe hacerse a través del container. </p>
<p>Para permitir que un GraphicElement tenga interacción directa, debemos llevar a cabo ciertos aspectos que en muchos casos se consideran malas prácticas. Vamos a ver como conseguirlo.<br />
El DisplayObject que usa el GraphicElement para dibujarse, es un InvalidatingSprite, que tiene las propiedades mouseEnabled y mouseChildren a false. Esto hace que la interactividad esté desactivada.<br />
Debemos habilitar la interactividad en el element InvalidatingSprite y deshabilitar que el display object sea compartido para evitar que el repintado de otros elementos gráficos pueda afectar a este. Para ello es necesario: </p>
<ul>
<li>Subreescribir la function createDisplayObject()</li>
<li>Settear mouseEnbled y mouseChildren del DisplayObject creado a true</li>
<li>Añadir event listeners al DisplayObject</li>
<li>Sobreescribir needsDisplayObject() y devolver true</li>
<li>Sobreescribir canShareWithNext() y canShareWithPrevious() y devolver false</li>
</ul>
<h4 id="toc-conclusiones">Conclusiones</h4>
<p>SpriteVisualElement  es una clase a tener en cuenta cuando queremos crear componentes gráficos ligeros, ya que los containers Spark aceptan elementos de este tipo y se pueden usar dentro de skins o combinarlos con FXG.<br />
Por otro lado, la clase GraphicElement nos permite crear elementos gráficos muy optimizados, pero, como hemos visto, tiene la interactividad limitada. </p>
<p>Si necesitamos interacción directa con un elemento gráfico, es mejor usar SpriteVisualElement, que es un objeto interactivo (extiende de InteractiveObject).</p>]]></content:encoded>
			<wfw:commentRss>http://www.madeinflex.com/2010/10/23/clases-spark-para-crear-componentes-ligeros/feed/</wfw:commentRss>
		<slash:comments>2</slash:comments>
		</item>
		<item>
		<title>Autenticación en aplicaciones Flex con Spring Security 3</title>
		<link>http://www.madeinflex.com/2010/08/13/autenticacion-en-aplicaciones-flex-con-spring-security-3/</link>
		<comments>http://www.madeinflex.com/2010/08/13/autenticacion-en-aplicaciones-flex-con-spring-security-3/#comments</comments>
		<pubDate>Thu, 12 Aug 2010 23:05:05 +0000</pubDate>
		<dc:creator>Nono F. Carballo Escalona</dc:creator>
				<category><![CDATA[Artículos]]></category>
		<category><![CDATA[Seguridad]]></category>
		<category><![CDATA[Tutoriales]]></category>

		<guid isPermaLink="false">http://www.madeinflex.com/?p=1679</guid>
		<description><![CDATA[<!-- matched  --><!-- final 0 -->El back-end
La aplicación Flex
Más información del usuario en Flex
Conclusiones


Spring Security es un framework que se centra en proveer mecanismos de autenticación y autorización para aplicaciones basadas en Spring. Mediante el paquete de integración de Spring con BlazeDS spring-flex, conjuntamente con Spring Security, podemos añadir seguridad a nuestras aplicaciones Flex/BlazeDS.
En este artículo veremos, a través de [...]]]></description>
			<content:encoded><![CDATA[<!-- matched  --><!-- final 0 --><p><span id="more-1679"></span><br />
<!--noteaser--></p>
<div class="toc">
<ol>
<li><a href="http://www.madeinflex.com/2010/08/13/autenticacion-en-aplicaciones-flex-con-spring-security-3/#toc-el-back-end">El back-end</a></li>
<li><a href="http://www.madeinflex.com/2010/08/13/autenticacion-en-aplicaciones-flex-con-spring-security-3/#toc-la-aplicacion-flex">La aplicación Flex</a></li>
<li><a href="http://www.madeinflex.com/2010/08/13/autenticacion-en-aplicaciones-flex-con-spring-security-3/#toc-mas-informacion-del-usuario-en-flex">Más información del usuario en Flex</a></li>
<li><a href="http://www.madeinflex.com/2010/08/13/autenticacion-en-aplicaciones-flex-con-spring-security-3/#toc-conclusiones">Conclusiones</a></li>
</ol>
</div>
<p><a href="http://static.springsource.org/spring-security/site/index.html">Spring Security</a> es un framework que se centra en proveer mecanismos de autenticación y autorización para aplicaciones basadas en Spring. Mediante el paquete de integración de Spring con BlazeDS <a href="http://www.springsource.org/spring-flex">spring-flex</a>, conjuntamente con Spring Security, podemos añadir seguridad a nuestras aplicaciones Flex/BlazeDS.</p>
<p>En este artículo veremos, a través de un ejemplo, cómo podemos utilizar el mecanismo de autenticación de Spring Security desde una aplicación Flex. En la aplicación que desarrollaremos tenemos la información de los usuarios y los roles asignados a éstos en una base de datos MySQL, a la cual accederemos utilizando JPA e Hibernate. Desde Flex invocaremos el servicio de autenticación de Spring Security, el cual utilizará la información de los usuarios y roles en la base de datos para comprobar las credenciales de usuario suministradas, si el proceso termina exitosamente tendremos en la aplicación Flex la información del usuario autenticado, en caso contrario se nos notificará del error.</p>
<p>Para el desarrollo de la aplicación utilizaremos:</p>
<ul>
<li>Spring 3.0.2</li>
<li>Spring Security 3.0.3</li>
<li>Spring-Flex 1.5.0.M1</li>
<li>BlazeDS 4.0.0.14931</li>
<li>Flex 4</li>
<li>Flash Builder 4 plugin en Eclipse IDE for J2EE (Galileo)</li>
<li>RobotLegs 1.1.2</li>
</ul>
<p>La aplicación la desarrollaremos en dos proyectos, un proyecto Web J2EE para el back-end y un proyecto Flex para la interface visual.</p>
<h4 id="toc-el-back-end">El back-end</h4>
<p>Comenzaremos por la creación del proyecto Web J2EE</p>
<ol>
<li>File … Import … Web->War File</li>
<li>WAR File: El camino del archivo blazeds.war</li>
<li>Web Project: FlexSpringSecurity</li>
<li>Target Runtime: Alguno que se haya configurado previamente</li>
<li>War Import: Web Libraries. No seleccionamos ningún paquete</li>
</ol>
<p>Copiamos en la carpeta WebContent\WEB-INF\lib los archivos de Spring, Spring Security, Spring-Flex, el driver JDBC de MySQL. El listado de los archivos de la carpeta se puede ver <a href='http://www.madeinflex.com/wp-content/uploads/2010/08/webcontent.txt'>aquí</a>.</p>
<p>Como utilizamos el paquete de integración de Spring con BlazeDS solamente necesitamos en la carpeta WebContent\WEB-INF\flex el archivo <a href='http://www.madeinflex.com/wp-content/uploads/2010/08/services-config.xml_.txt'>services-config.xml</a>. También necesitamos modificar el archivo <a href='http://www.madeinflex.com/wp-content/uploads/2010/08/web.xml_.txt'>web.xml</a> en WebContent\WEB-INF, en el que se hace referencia a los archivos <a href='http://www.madeinflex.com/wp-content/uploads/2010/08/web-application-config.xml_.txt'>web-application-config.xml</a> y <a href='http://www.madeinflex.com/wp-content/uploads/2010/08/web-application-context-config.xml_.txt'>web-application-context-config.xml</a>, donde se configura el contexto de Spring.</p>
<p>Comenzaremos por crear la capa que accederá a la base de datos para obtener la información de usuarios y roles.</p>
<p>User.java</p>
<div class="igBar"><span id="ljava-18"><a href="#" onclick="javascript:showPlainTxt('java-18'); return false;">PLAIN TEXT</a></span></div>
<div class="syntax_hilite"><span class="langName">JAVA:</span>
<div id="java-18">
<div class="java">
<ol>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#3A6A8B;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">package com.<span style="color: #006600;">nonocarballo</span>.<span style="color: #006600;">flexspringsecurity</span>.<span style="color: #006600;">valueobject</span>;</div>
</li>
<li style="font-weight: bold;color:#26536A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp;</div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#3A6A8B;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;"><span style="color: #a1a100;">import java.util.List;</span></div>
</li>
<li style="font-weight: bold;color:#26536A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp;</div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#3A6A8B;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;"><span style="color: #a1a100;">import javax.persistence.CascadeType;</span></div>
</li>
<li style="font-weight: bold;color:#26536A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;"><span style="color: #a1a100;">import javax.persistence.Entity;</span></div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#3A6A8B;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;"><span style="color: #a1a100;">import javax.persistence.FetchType;</span></div>
</li>
<li style="font-weight: bold;color:#26536A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;"><span style="color: #a1a100;">import javax.persistence.GeneratedValue;</span></div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#3A6A8B;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;"><span style="color: #a1a100;">import javax.persistence.Id;</span></div>
</li>
<li style="font-weight: bold;color:#26536A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;"><span style="color: #a1a100;">import javax.persistence.ManyToMany;</span></div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#3A6A8B;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp;</div>
</li>
<li style="font-weight: bold;color:#26536A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">@<a href="http://www.google.com/search?q=allinurl%3AEntity+java.sun.com&amp;bntl=1"><span style="color: #aaaadd; font-weight: bold;">Entity</span></a></div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#3A6A8B;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;"><span style="color: #000000; font-weight: bold;">public</span> <span style="color: #000000; font-weight: bold;">class</span> User <span style="color: #66cc66;">&#123;</span></div>
</li>
<li style="font-weight: bold;color:#26536A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp;</div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#3A6A8B;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; <span style="color: #000000; font-weight: bold;">private</span> <a href="http://www.google.com/search?q=allinurl%3ALong+java.sun.com&amp;bntl=1"><span style="color: #aaaadd; font-weight: bold;">Long</span></a> id;</div>
</li>
<li style="font-weight: bold;color:#26536A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; <span style="color: #000000; font-weight: bold;">private</span> <a href="http://www.google.com/search?q=allinurl%3AString+java.sun.com&amp;bntl=1"><span style="color: #aaaadd; font-weight: bold;">String</span></a> fullName;</div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#3A6A8B;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; <span style="color: #000000; font-weight: bold;">private</span> <a href="http://www.google.com/search?q=allinurl%3AString+java.sun.com&amp;bntl=1"><span style="color: #aaaadd; font-weight: bold;">String</span></a> userName;</div>
</li>
<li style="font-weight: bold;color:#26536A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; <span style="color: #000000; font-weight: bold;">private</span> <a href="http://www.google.com/search?q=allinurl%3AString+java.sun.com&amp;bntl=1"><span style="color: #aaaadd; font-weight: bold;">String</span></a> password;</div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#3A6A8B;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp;</div>
</li>
<li style="font-weight: bold;color:#26536A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; @Id</div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#3A6A8B;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; @GeneratedValue</div>
</li>
<li style="font-weight: bold;color:#26536A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; <span style="color: #000000; font-weight: bold;">public</span> <a href="http://www.google.com/search?q=allinurl%3ALong+java.sun.com&amp;bntl=1"><span style="color: #aaaadd; font-weight: bold;">Long</span></a> getId<span style="color: #66cc66;">&#40;</span><span style="color: #66cc66;">&#41;</span> <span style="color: #66cc66;">&#123;</span></div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#3A6A8B;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #000000; font-weight: bold;">return</span> id;</div>
</li>
<li style="font-weight: bold;color:#26536A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; <span style="color: #66cc66;">&#125;</span></div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#3A6A8B;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp;</div>
</li>
<li style="font-weight: bold;color:#26536A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; <span style="color: #000000; font-weight: bold;">public</span> <span style="color: #993333;">void</span> setId<span style="color: #66cc66;">&#40;</span><a href="http://www.google.com/search?q=allinurl%3ALong+java.sun.com&amp;bntl=1"><span style="color: #aaaadd; font-weight: bold;">Long</span></a> id<span style="color: #66cc66;">&#41;</span> <span style="color: #66cc66;">&#123;</span></div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#3A6A8B;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #000000; font-weight: bold;">this</span>.<span style="color: #006600;">id</span> = id;</div>
</li>
<li style="font-weight: bold;color:#26536A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; <span style="color: #66cc66;">&#125;</span></div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#3A6A8B;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp;</div>
</li>
<li style="font-weight: bold;color:#26536A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; <span style="color: #000000; font-weight: bold;">public</span> <a href="http://www.google.com/search?q=allinurl%3AString+java.sun.com&amp;bntl=1"><span style="color: #aaaadd; font-weight: bold;">String</span></a> getFullName<span style="color: #66cc66;">&#40;</span><span style="color: #66cc66;">&#41;</span> <span style="color: #66cc66;">&#123;</span></div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#3A6A8B;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #000000; font-weight: bold;">return</span> fullName;</div>
</li>
<li style="font-weight: bold;color:#26536A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; <span style="color: #66cc66;">&#125;</span></div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#3A6A8B;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp;</div>
</li>
<li style="font-weight: bold;color:#26536A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; <span style="color: #000000; font-weight: bold;">public</span> <span style="color: #993333;">void</span> setFullName<span style="color: #66cc66;">&#40;</span><a href="http://www.google.com/search?q=allinurl%3AString+java.sun.com&amp;bntl=1"><span style="color: #aaaadd; font-weight: bold;">String</span></a> fullName<span style="color: #66cc66;">&#41;</span> <span style="color: #66cc66;">&#123;</span></div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#3A6A8B;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #000000; font-weight: bold;">this</span>.<span style="color: #006600;">fullName</span> = fullName;</div>
</li>
<li style="font-weight: bold;color:#26536A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; <span style="color: #66cc66;">&#125;</span></div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#3A6A8B;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp;</div>
</li>
<li style="font-weight: bold;color:#26536A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; <span style="color: #000000; font-weight: bold;">public</span> <a href="http://www.google.com/search?q=allinurl%3AString+java.sun.com&amp;bntl=1"><span style="color: #aaaadd; font-weight: bold;">String</span></a> getUserName<span style="color: #66cc66;">&#40;</span><span style="color: #66cc66;">&#41;</span> <span style="color: #66cc66;">&#123;</span></div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#3A6A8B;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #000000; font-weight: bold;">return</span> userName;</div>
</li>
<li style="font-weight: bold;color:#26536A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; <span style="color: #66cc66;">&#125;</span></div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#3A6A8B;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp;</div>
</li>
<li style="font-weight: bold;color:#26536A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; <span style="color: #000000; font-weight: bold;">public</span> <span style="color: #993333;">void</span> setUserName<span style="color: #66cc66;">&#40;</span><a href="http://www.google.com/search?q=allinurl%3AString+java.sun.com&amp;bntl=1"><span style="color: #aaaadd; font-weight: bold;">String</span></a> userName<span style="color: #66cc66;">&#41;</span> <span style="color: #66cc66;">&#123;</span></div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#3A6A8B;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #000000; font-weight: bold;">this</span>.<span style="color: #006600;">userName</span> = userName;</div>
</li>
<li style="font-weight: bold;color:#26536A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; <span style="color: #66cc66;">&#125;</span></div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#3A6A8B;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp;</div>
</li>
<li style="font-weight: bold;color:#26536A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; <span style="color: #000000; font-weight: bold;">public</span> <a href="http://www.google.com/search?q=allinurl%3AString+java.sun.com&amp;bntl=1"><span style="color: #aaaadd; font-weight: bold;">String</span></a> getPassword<span style="color: #66cc66;">&#40;</span><span style="color: #66cc66;">&#41;</span> <span style="color: #66cc66;">&#123;</span></div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#3A6A8B;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #000000; font-weight: bold;">return</span> password;</div>
</li>
<li style="font-weight: bold;color:#26536A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; <span style="color: #66cc66;">&#125;</span></div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#3A6A8B;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp;</div>
</li>
<li style="font-weight: bold;color:#26536A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; <span style="color: #000000; font-weight: bold;">public</span> <span style="color: #993333;">void</span> setPassword<span style="color: #66cc66;">&#40;</span><a href="http://www.google.com/search?q=allinurl%3AString+java.sun.com&amp;bntl=1"><span style="color: #aaaadd; font-weight: bold;">String</span></a> password<span style="color: #66cc66;">&#41;</span> <span style="color: #66cc66;">&#123;</span></div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#3A6A8B;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #000000; font-weight: bold;">this</span>.<span style="color: #006600;">password</span> = password;</div>
</li>
<li style="font-weight: bold;color:#26536A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; <span style="color: #66cc66;">&#125;</span></div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#3A6A8B;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; </div>
</li>
<li style="font-weight: bold;color:#26536A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; <span style="color: #000000; font-weight: bold;">private</span> List&lt;Role&gt; roleList;</div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#3A6A8B;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp;</div>
</li>
<li style="font-weight: bold;color:#26536A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; @ManyToMany<span style="color: #66cc66;">&#40;</span>cascade=CascadeType.<span style="color: #006600;">ALL</span>, fetch=FetchType.<span style="color: #006600;">LAZY</span><span style="color: #66cc66;">&#41;</span></div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#3A6A8B;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; <span style="color: #000000; font-weight: bold;">public</span> List&lt;Role&gt; getRoleList<span style="color: #66cc66;">&#40;</span><span style="color: #66cc66;">&#41;</span> <span style="color: #66cc66;">&#123;</span></div>
</li>
<li style="font-weight: bold;color:#26536A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #000000; font-weight: bold;">return</span> roleList;</div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#3A6A8B;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; <span style="color: #66cc66;">&#125;</span></div>
</li>
<li style="font-weight: bold;color:#26536A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp;</div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#3A6A8B;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; <span style="color: #000000; font-weight: bold;">public</span> <span style="color: #993333;">void</span> setRoleList<span style="color: #66cc66;">&#40;</span>List&lt;Role&gt; roleList<span style="color: #66cc66;">&#41;</span> <span style="color: #66cc66;">&#123;</span></div>
</li>
<li style="font-weight: bold;color:#26536A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #000000; font-weight: bold;">this</span>.<span style="color: #006600;">roleList</span> = roleList;</div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#3A6A8B;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; <span style="color: #66cc66;">&#125;</span></div>
</li>
<li style="font-weight: bold;color:#26536A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;"><span style="color: #66cc66;">&#125;</span> </div>
</li>
</ol>
</div>
</div>
</div>
<p></p>
<p>Role.java</p>
<div class="igBar"><span id="ljava-19"><a href="#" onclick="javascript:showPlainTxt('java-19'); return false;">PLAIN TEXT</a></span></div>
<div class="syntax_hilite"><span class="langName">JAVA:</span>
<div id="java-19">
<div class="java">
<ol>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#3A6A8B;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">package com.<span style="color: #006600;">nonocarballo</span>.<span style="color: #006600;">flexspringsecurity</span>.<span style="color: #006600;">valueobject</span>;</div>
</li>
<li style="font-weight: bold;color:#26536A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp;</div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#3A6A8B;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;"><span style="color: #a1a100;">import javax.persistence.Entity;</span></div>
</li>
<li style="font-weight: bold;color:#26536A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;"><span style="color: #a1a100;">import javax.persistence.GeneratedValue;</span></div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#3A6A8B;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;"><span style="color: #a1a100;">import javax.persistence.Id;</span></div>
</li>
<li style="font-weight: bold;color:#26536A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp;</div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#3A6A8B;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">@<a href="http://www.google.com/search?q=allinurl%3AEntity+java.sun.com&amp;bntl=1"><span style="color: #aaaadd; font-weight: bold;">Entity</span></a></div>
</li>
<li style="font-weight: bold;color:#26536A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;"><span style="color: #000000; font-weight: bold;">public</span> <span style="color: #000000; font-weight: bold;">class</span> Role <span style="color: #66cc66;">&#123;</span></div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#3A6A8B;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp;</div>
</li>
<li style="font-weight: bold;color:#26536A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; <span style="color: #000000; font-weight: bold;">private</span> <a href="http://www.google.com/search?q=allinurl%3ALong+java.sun.com&amp;bntl=1"><span style="color: #aaaadd; font-weight: bold;">Long</span></a> id;</div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#3A6A8B;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; <span style="color: #000000; font-weight: bold;">private</span> <a href="http://www.google.com/search?q=allinurl%3AString+java.sun.com&amp;bntl=1"><span style="color: #aaaadd; font-weight: bold;">String</span></a> name;</div>
</li>
<li style="font-weight: bold;color:#26536A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp;</div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#3A6A8B;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; @Id</div>
</li>
<li style="font-weight: bold;color:#26536A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; @GeneratedValue</div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#3A6A8B;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; <span style="color: #000000; font-weight: bold;">public</span> <a href="http://www.google.com/search?q=allinurl%3ALong+java.sun.com&amp;bntl=1"><span style="color: #aaaadd; font-weight: bold;">Long</span></a> getId<span style="color: #66cc66;">&#40;</span><span style="color: #66cc66;">&#41;</span> <span style="color: #66cc66;">&#123;</span></div>
</li>
<li style="font-weight: bold;color:#26536A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #000000; font-weight: bold;">return</span> id;</div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#3A6A8B;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; <span style="color: #66cc66;">&#125;</span></div>
</li>
<li style="font-weight: bold;color:#26536A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp;</div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#3A6A8B;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; <span style="color: #000000; font-weight: bold;">public</span> <span style="color: #993333;">void</span> setId<span style="color: #66cc66;">&#40;</span><a href="http://www.google.com/search?q=allinurl%3ALong+java.sun.com&amp;bntl=1"><span style="color: #aaaadd; font-weight: bold;">Long</span></a> id<span style="color: #66cc66;">&#41;</span> <span style="color: #66cc66;">&#123;</span></div>
</li>
<li style="font-weight: bold;color:#26536A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #000000; font-weight: bold;">this</span>.<span style="color: #006600;">id</span> = id;</div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#3A6A8B;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; <span style="color: #66cc66;">&#125;</span></div>
</li>
<li style="font-weight: bold;color:#26536A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp;</div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#3A6A8B;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; <span style="color: #000000; font-weight: bold;">public</span> <a href="http://www.google.com/search?q=allinurl%3AString+java.sun.com&amp;bntl=1"><span style="color: #aaaadd; font-weight: bold;">String</span></a> getName<span style="color: #66cc66;">&#40;</span><span style="color: #66cc66;">&#41;</span> <span style="color: #66cc66;">&#123;</span></div>
</li>
<li style="font-weight: bold;color:#26536A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #000000; font-weight: bold;">return</span> name;</div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#3A6A8B;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; <span style="color: #66cc66;">&#125;</span></div>
</li>
<li style="font-weight: bold;color:#26536A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp;</div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#3A6A8B;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; <span style="color: #000000; font-weight: bold;">public</span> <span style="color: #993333;">void</span> setName<span style="color: #66cc66;">&#40;</span><a href="http://www.google.com/search?q=allinurl%3AString+java.sun.com&amp;bntl=1"><span style="color: #aaaadd; font-weight: bold;">String</span></a> name<span style="color: #66cc66;">&#41;</span> <span style="color: #66cc66;">&#123;</span></div>
</li>
<li style="font-weight: bold;color:#26536A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #000000; font-weight: bold;">this</span>.<span style="color: #006600;">name</span> = name;</div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#3A6A8B;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; <span style="color: #66cc66;">&#125;</span></div>
</li>
<li style="font-weight: bold;color:#26536A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;"><span style="color: #66cc66;">&#125;</span> </div>
</li>
</ol>
</div>
</div>
</div>
<p></p>
<p>RoleType.java</p>
<div class="igBar"><span id="ljava-20"><a href="#" onclick="javascript:showPlainTxt('java-20'); return false;">PLAIN TEXT</a></span></div>
<div class="syntax_hilite"><span class="langName">JAVA:</span>
<div id="java-20">
<div class="java">
<ol>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#3A6A8B;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">package com.<span style="color: #006600;">nonocarballo</span>.<span style="color: #006600;">flexspringsecurity</span>.<span style="color: #006600;">valueobject</span>;</div>
</li>
<li style="font-weight: bold;color:#26536A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp;</div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#3A6A8B;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;"><span style="color: #000000; font-weight: bold;">public</span> <span style="color: #000000; font-weight: bold;">class</span> RoleType <span style="color: #66cc66;">&#123;</span></div>
</li>
<li style="font-weight: bold;color:#26536A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; <span style="color: #000000; font-weight: bold;">public</span> <span style="color: #993333;">static</span> <span style="color: #000000; font-weight: bold;">final</span> <a href="http://www.google.com/search?q=allinurl%3AString+java.sun.com&amp;bntl=1"><span style="color: #aaaadd; font-weight: bold;">String</span></a> ADMIN = <span style="color: #ff0000;">"ADMINISTRATOR"</span>;</div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#3A6A8B;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; <span style="color: #000000; font-weight: bold;">public</span> <span style="color: #993333;">static</span> <span style="color: #000000; font-weight: bold;">final</span> <a href="http://www.google.com/search?q=allinurl%3AString+java.sun.com&amp;bntl=1"><span style="color: #aaaadd; font-weight: bold;">String</span></a> USER = <span style="color: #ff0000;">"USER"</span>;</div>
</li>
<li style="font-weight: bold;color:#26536A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; <span style="color: #000000; font-weight: bold;">public</span> <span style="color: #993333;">static</span> <span style="color: #000000; font-weight: bold;">final</span> <a href="http://www.google.com/search?q=allinurl%3AString+java.sun.com&amp;bntl=1"><span style="color: #aaaadd; font-weight: bold;">String</span></a> GEST = <span style="color: #ff0000;">"GEST"</span>;</div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#3A6A8B;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;"><span style="color: #66cc66;">&#125;</span> </div>
</li>
</ol>
</div>
</div>
</div>
<p></p>
<p>IUserService.java</p>
<div class="igBar"><span id="ljava-21"><a href="#" onclick="javascript:showPlainTxt('java-21'); return false;">PLAIN TEXT</a></span></div>
<div class="syntax_hilite"><span class="langName">JAVA:</span>
<div id="java-21">
<div class="java">
<ol>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#3A6A8B;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">package com.<span style="color: #006600;">nonocarballo</span>.<span style="color: #006600;">flexspringsecurity</span>.<span style="color: #006600;">service</span>;</div>
</li>
<li style="font-weight: bold;color:#26536A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp;</div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#3A6A8B;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;"><span style="color: #a1a100;">import java.util.List;</span></div>
</li>
<li style="font-weight: bold;color:#26536A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;"><span style="color: #a1a100;">import com.nonocarballo.flexspringsecurity.valueobject.User;</span></div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#3A6A8B;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp;</div>
</li>
<li style="font-weight: bold;color:#26536A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;"><span style="color: #000000; font-weight: bold;">public</span> <span style="color: #000000; font-weight: bold;">interface</span> IUserService <span style="color: #66cc66;">&#123;</span></div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#3A6A8B;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; <span style="color: #000000; font-weight: bold;">public</span> List&lt;User&gt; loadAllUsers<span style="color: #66cc66;">&#40;</span><span style="color: #66cc66;">&#41;</span>;</div>
</li>
<li style="font-weight: bold;color:#26536A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; <span style="color: #000000; font-weight: bold;">public</span> <span style="color: #993333;">void</span> addUser<span style="color: #66cc66;">&#40;</span>User user<span style="color: #66cc66;">&#41;</span>;</div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#3A6A8B;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; <span style="color: #000000; font-weight: bold;">public</span> User loabByUserName<span style="color: #66cc66;">&#40;</span><a href="http://www.google.com/search?q=allinurl%3AString+java.sun.com&amp;bntl=1"><span style="color: #aaaadd; font-weight: bold;">String</span></a> username<span style="color: #66cc66;">&#41;</span>;</div>
</li>
<li style="font-weight: bold;color:#26536A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;"><span style="color: #66cc66;">&#125;</span> </div>
</li>
</ol>
</div>
</div>
</div>
<p></p>
<p>UserService.java</p>
<div class="igBar"><span id="ljava-22"><a href="#" onclick="javascript:showPlainTxt('java-22'); return false;">PLAIN TEXT</a></span></div>
<div class="syntax_hilite"><span class="langName">JAVA:</span>
<div id="java-22">
<div class="java">
<ol>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#3A6A8B;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">package com.<span style="color: #006600;">nonocarballo</span>.<span style="color: #006600;">flexspringsecurity</span>.<span style="color: #006600;">service</span>.<span style="color: #006600;">impl</span>;</div>
</li>
<li style="font-weight: bold;color:#26536A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp;</div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#3A6A8B;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;"><span style="color: #a1a100;">import java.util.List;</span></div>
</li>
<li style="font-weight: bold;color:#26536A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;"><span style="color: #a1a100;">import javax.persistence.EntityManager;</span></div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#3A6A8B;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;"><span style="color: #a1a100;">import javax.persistence.PersistenceContext;</span></div>
</li>
<li style="font-weight: bold;color:#26536A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;"><span style="color: #a1a100;">import javax.persistence.PersistenceContextType;</span></div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#3A6A8B;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;"><span style="color: #a1a100;">import javax.persistence.Query;</span></div>
</li>
<li style="font-weight: bold;color:#26536A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp;</div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#3A6A8B;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;"><span style="color: #a1a100;">import org.springframework.flex.remoting.RemotingDestination;</span></div>
</li>
<li style="font-weight: bold;color:#26536A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;"><span style="color: #a1a100;">import org.springframework.flex.remoting.RemotingExclude;</span></div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#3A6A8B;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;"><span style="color: #a1a100;">import org.springframework.stereotype.Repository;</span></div>
</li>
<li style="font-weight: bold;color:#26536A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;"><span style="color: #a1a100;">import org.springframework.transaction.annotation.Transactional;</span></div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#3A6A8B;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp;</div>
</li>
<li style="font-weight: bold;color:#26536A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;"><span style="color: #a1a100;">import com.nonocarballo.flexspringsecurity.service.IUserService;</span></div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#3A6A8B;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;"><span style="color: #a1a100;">import com.nonocarballo.flexspringsecurity.valueobject.User;</span></div>
</li>
<li style="font-weight: bold;color:#26536A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp;</div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#3A6A8B;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">@<a href="http://www.google.com/search?q=allinurl%3ARepository+java.sun.com&amp;bntl=1"><span style="color: #aaaadd; font-weight: bold;">Repository</span></a></div>
</li>
<li style="font-weight: bold;color:#26536A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">@RemotingDestination</div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#3A6A8B;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;"><span style="color: #000000; font-weight: bold;">public</span> <span style="color: #000000; font-weight: bold;">class</span> UserService <span style="color: #000000; font-weight: bold;">implements</span> IUserService <span style="color: #66cc66;">&#123;</span></div>
</li>
<li style="font-weight: bold;color:#26536A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp;</div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#3A6A8B;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; <span style="color: #000000; font-weight: bold;">private</span> EntityManager entityManager;</div>
</li>
<li style="font-weight: bold;color:#26536A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; </div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#3A6A8B;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; @RemotingExclude</div>
</li>
<li style="font-weight: bold;color:#26536A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; <span style="color: #000000; font-weight: bold;">public</span> EntityManager getEntityManager<span style="color: #66cc66;">&#40;</span><span style="color: #66cc66;">&#41;</span> <span style="color: #66cc66;">&#123;</span></div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#3A6A8B;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #000000; font-weight: bold;">return</span> entityManager;</div>
</li>
<li style="font-weight: bold;color:#26536A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; <span style="color: #66cc66;">&#125;</span></div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#3A6A8B;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp;</div>
</li>
<li style="font-weight: bold;color:#26536A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; @RemotingExclude</div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#3A6A8B;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; @PersistenceContext<span style="color: #66cc66;">&#40;</span>type = PersistenceContextType.<span style="color: #006600;">EXTENDED</span><span style="color: #66cc66;">&#41;</span></div>
</li>
<li style="font-weight: bold;color:#26536A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; <span style="color: #000000; font-weight: bold;">public</span> <span style="color: #993333;">void</span> setEntityManager<span style="color: #66cc66;">&#40;</span>EntityManager entityManager<span style="color: #66cc66;">&#41;</span> <span style="color: #66cc66;">&#123;</span></div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#3A6A8B;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #000000; font-weight: bold;">this</span>.<span style="color: #006600;">entityManager</span> = entityManager;</div>
</li>
<li style="font-weight: bold;color:#26536A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; <span style="color: #66cc66;">&#125;</span></div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#3A6A8B;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp;</div>
</li>
<li style="font-weight: bold;color:#26536A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; @SuppressWarnings<span style="color: #66cc66;">&#40;</span><span style="color: #ff0000;">"unchecked"</span><span style="color: #66cc66;">&#41;</span></div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#3A6A8B;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; @Override</div>
</li>
<li style="font-weight: bold;color:#26536A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; <span style="color: #000000; font-weight: bold;">public</span> List&lt;User&gt; loadAllUsers<span style="color: #66cc66;">&#40;</span><span style="color: #66cc66;">&#41;</span> <span style="color: #66cc66;">&#123;</span></div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#3A6A8B;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #808080; font-style: italic;">// TODO Auto-generated method stub</span></div>
</li>
<li style="font-weight: bold;color:#26536A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #000000; font-weight: bold;">return</span> entityManager.<span style="color: #006600;">createQuery</span><span style="color: #66cc66;">&#40;</span><span style="color: #ff0000;">"from User u"</span><span style="color: #66cc66;">&#41;</span>.<span style="color: #006600;">getResultList</span><span style="color: #66cc66;">&#40;</span><span style="color: #66cc66;">&#41;</span>;</div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#3A6A8B;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; <span style="color: #66cc66;">&#125;</span></div>
</li>
<li style="font-weight: bold;color:#26536A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp;</div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#3A6A8B;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; @Override</div>
</li>
<li style="font-weight: bold;color:#26536A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; @Transactional</div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#3A6A8B;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; <span style="color: #000000; font-weight: bold;">public</span> User loabByUserName<span style="color: #66cc66;">&#40;</span><a href="http://www.google.com/search?q=allinurl%3AString+java.sun.com&amp;bntl=1"><span style="color: #aaaadd; font-weight: bold;">String</span></a> username<span style="color: #66cc66;">&#41;</span> <span style="color: #66cc66;">&#123;</span></div>
</li>
<li style="font-weight: bold;color:#26536A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; &nbsp; &nbsp; Query userQuery = entityManager.<span style="color: #006600;">createQuery</span><span style="color: #66cc66;">&#40;</span><span style="color: #ff0000;">"from User u where u.userName = :user"</span><span style="color: #66cc66;">&#41;</span>;</div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#3A6A8B;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; &nbsp; &nbsp; userQuery.<span style="color: #006600;">setParameter</span><span style="color: #66cc66;">&#40;</span><span style="color: #ff0000;">"user"</span>, username<span style="color: #66cc66;">&#41;</span>;</div>
</li>
<li style="font-weight: bold;color:#26536A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; &nbsp; &nbsp; User user = <span style="color: #66cc66;">&#40;</span>User<span style="color: #66cc66;">&#41;</span> userQuery.<span style="color: #006600;">getSingleResult</span><span style="color: #66cc66;">&#40;</span><span style="color: #66cc66;">&#41;</span>;</div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#3A6A8B;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #000000; font-weight: bold;">return</span> user;</div>
</li>
<li style="font-weight: bold;color:#26536A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; <span style="color: #66cc66;">&#125;</span></div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#3A6A8B;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp;</div>
</li>
<li style="font-weight: bold;color:#26536A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; @Override</div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#3A6A8B;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; @Transactional</div>
</li>
<li style="font-weight: bold;color:#26536A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; <span style="color: #000000; font-weight: bold;">public</span> <span style="color: #993333;">void</span> addUser<span style="color: #66cc66;">&#40;</span>User user<span style="color: #66cc66;">&#41;</span> <span style="color: #66cc66;">&#123;</span></div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#3A6A8B;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #808080; font-style: italic;">// TODO Auto-generated method stub</span></div>
</li>
<li style="font-weight: bold;color:#26536A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; &nbsp; &nbsp; entityManager.<span style="color: #006600;">persist</span><span style="color: #66cc66;">&#40;</span>user<span style="color: #66cc66;">&#41;</span>;&nbsp; &nbsp; &nbsp; &nbsp; </div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#3A6A8B;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; <span style="color: #66cc66;">&#125;</span></div>
</li>
<li style="font-weight: bold;color:#26536A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;"><span style="color: #66cc66;">&#125;</span> </div>
</li>
</ol>
</div>
</div>
</div>
<p></p>
<p>Escribimos ahora un código en forma de test para generar las tablas de la base de datos y llenarlas con alguna información.</p>
<p>UserServiceTest.java</p>
<div class="igBar"><span id="ljava-23"><a href="#" onclick="javascript:showPlainTxt('java-23'); return false;">PLAIN TEXT</a></span></div>
<div class="syntax_hilite"><span class="langName">JAVA:</span>
<div id="java-23">
<div class="java">
<ol>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#3A6A8B;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">package com.<span style="color: #006600;">nonocarballo</span>.<span style="color: #006600;">flexspringsecurity</span>.<span style="color: #006600;">test</span>;</div>
</li>
<li style="font-weight: bold;color:#26536A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp;</div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#3A6A8B;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;"><span style="color: #a1a100;">import static org.junit.Assert.*;</span></div>
</li>
<li style="font-weight: bold;color:#26536A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp;</div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#3A6A8B;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;"><span style="color: #a1a100;">import java.util.ArrayList;</span></div>
</li>
<li style="font-weight: bold;color:#26536A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp;</div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#3A6A8B;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;"><span style="color: #a1a100;">import org.junit.Test;</span></div>
</li>
<li style="font-weight: bold;color:#26536A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;"><span style="color: #a1a100;">import org.junit.runner.RunWith;</span></div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#3A6A8B;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;"><span style="color: #a1a100;">import org.springframework.beans.factory.annotation.Autowired;</span></div>
</li>
<li style="font-weight: bold;color:#26536A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;"><span style="color: #a1a100;">import org.springframework.test.context.ContextConfiguration;</span></div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#3A6A8B;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;"><span style="color: #a1a100;">import org.springframework.test.context.junit4.SpringJUnit4ClassRunner;</span></div>
</li>
<li style="font-weight: bold;color:#26536A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp;</div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#3A6A8B;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;"><span style="color: #a1a100;">import com.nonocarballo.flexspringsecurity.service.IUserService;</span></div>
</li>
<li style="font-weight: bold;color:#26536A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;"><span style="color: #a1a100;">import com.nonocarballo.flexspringsecurity.valueobject.Role;</span></div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#3A6A8B;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;"><span style="color: #a1a100;">import com.nonocarballo.flexspringsecurity.valueobject.RoleType;</span></div>
</li>
<li style="font-weight: bold;color:#26536A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;"><span style="color: #a1a100;">import com.nonocarballo.flexspringsecurity.valueobject.User;</span></div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#3A6A8B;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp;</div>
</li>
<li style="font-weight: bold;color:#26536A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">@RunWith<span style="color: #66cc66;">&#40;</span>SpringJUnit4ClassRunner.<span style="color: #000000; font-weight: bold;">class</span><span style="color: #66cc66;">&#41;</span></div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#3A6A8B;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">@ContextConfiguration<span style="color: #66cc66;">&#40;</span>locations=<span style="color: #66cc66;">&#123;</span><span style="color: #ff0000;">"classpath:/spring/web-application-context-config.xml"</span><span style="color: #66cc66;">&#125;</span><span style="color: #66cc66;">&#41;</span></div>
</li>
<li style="font-weight: bold;color:#26536A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;"><span style="color: #000000; font-weight: bold;">public</span> <span style="color: #000000; font-weight: bold;">class</span> UserServiceTest <span style="color: #66cc66;">&#123;</span></div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#3A6A8B;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp;</div>
</li>
<li style="font-weight: bold;color:#26536A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; <span style="color: #000000; font-weight: bold;">private</span> IUserService userService;</div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#3A6A8B;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp;</div>
</li>
<li style="font-weight: bold;color:#26536A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; <span style="color: #000000; font-weight: bold;">public</span> IUserService getUserService<span style="color: #66cc66;">&#40;</span><span style="color: #66cc66;">&#41;</span> <span style="color: #66cc66;">&#123;</span></div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#3A6A8B;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #000000; font-weight: bold;">return</span> userService;</div>
</li>
<li style="font-weight: bold;color:#26536A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; <span style="color: #66cc66;">&#125;</span></div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#3A6A8B;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp;</div>
</li>
<li style="font-weight: bold;color:#26536A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; @Autowired</div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#3A6A8B;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; <span style="color: #000000; font-weight: bold;">public</span> <span style="color: #993333;">void</span> setUserService<span style="color: #66cc66;">&#40;</span>IUserService userService<span style="color: #66cc66;">&#41;</span> <span style="color: #66cc66;">&#123;</span></div>
</li>
<li style="font-weight: bold;color:#26536A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #000000; font-weight: bold;">this</span>.<span style="color: #006600;">userService</span> = userService;</div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#3A6A8B;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; <span style="color: #66cc66;">&#125;</span></div>
</li>
<li style="font-weight: bold;color:#26536A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; </div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#3A6A8B;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; @Test</div>
</li>
<li style="font-weight: bold;color:#26536A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; <span style="color: #000000; font-weight: bold;">public</span> <span style="color: #993333;">void</span> addUserTest<span style="color: #66cc66;">&#40;</span><span style="color: #66cc66;">&#41;</span><span style="color: #66cc66;">&#123;</span></div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#3A6A8B;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; &nbsp; &nbsp; </div>
</li>
<li style="font-weight: bold;color:#26536A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; &nbsp; &nbsp; User user = <span style="color: #000000; font-weight: bold;">new</span> User<span style="color: #66cc66;">&#40;</span><span style="color: #66cc66;">&#41;</span>;</div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#3A6A8B;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; &nbsp; &nbsp; user.<span style="color: #006600;">setFullName</span><span style="color: #66cc66;">&#40;</span><span style="color: #ff0000;">"Nono Carballo Escalona"</span><span style="color: #66cc66;">&#41;</span>;</div>
</li>
<li style="font-weight: bold;color:#26536A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; &nbsp; &nbsp; user.<span style="color: #006600;">setUserName</span><span style="color: #66cc66;">&#40;</span><span style="color: #ff0000;">"nono"</span><span style="color: #66cc66;">&#41;</span>;</div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#3A6A8B;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; &nbsp; &nbsp; user.<span style="color: #006600;">setPassword</span><span style="color: #66cc66;">&#40;</span><span style="color: #ff0000;">"mypassword"</span><span style="color: #66cc66;">&#41;</span>;</div>
</li>
<li style="font-weight: bold;color:#26536A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; &nbsp; &nbsp; </div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#3A6A8B;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; &nbsp; &nbsp; ArrayList&lt;Role&gt; roleList = <span style="color: #000000; font-weight: bold;">new</span> ArrayList&lt;Role&gt;<span style="color: #66cc66;">&#40;</span><span style="color: #66cc66;">&#41;</span>;</div>
</li>
<li style="font-weight: bold;color:#26536A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; &nbsp; &nbsp; </div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#3A6A8B;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; &nbsp; &nbsp; Role role = <span style="color: #000000; font-weight: bold;">new</span> Role<span style="color: #66cc66;">&#40;</span><span style="color: #66cc66;">&#41;</span>;&nbsp;&nbsp;</div>
</li>
<li style="font-weight: bold;color:#26536A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; &nbsp; &nbsp; role.<span style="color: #006600;">setName</span><span style="color: #66cc66;">&#40;</span>RoleType.<span style="color: #006600;">GEST</span><span style="color: #66cc66;">&#41;</span>;</div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#3A6A8B;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; &nbsp; &nbsp; roleList.<span style="color: #006600;">add</span><span style="color: #66cc66;">&#40;</span>role<span style="color: #66cc66;">&#41;</span>;</div>
</li>
<li style="font-weight: bold;color:#26536A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; &nbsp; &nbsp; </div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#3A6A8B;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; &nbsp; &nbsp; role = <span style="color: #000000; font-weight: bold;">new</span> Role<span style="color: #66cc66;">&#40;</span><span style="color: #66cc66;">&#41;</span>;&nbsp; &nbsp; </div>
</li>
<li style="font-weight: bold;color:#26536A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; &nbsp; &nbsp; role.<span style="color: #006600;">setName</span><span style="color: #66cc66;">&#40;</span>RoleType.<span style="color: #006600;">USER</span><span style="color: #66cc66;">&#41;</span>;</div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#3A6A8B;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; &nbsp; &nbsp; roleList.<span style="color: #006600;">add</span><span style="color: #66cc66;">&#40;</span>role<span style="color: #66cc66;">&#41;</span>;</div>
</li>
<li style="font-weight: bold;color:#26536A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; &nbsp; &nbsp; </div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#3A6A8B;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; &nbsp; &nbsp; role = <span style="color: #000000; font-weight: bold;">new</span> Role<span style="color: #66cc66;">&#40;</span><span style="color: #66cc66;">&#41;</span>;&nbsp; &nbsp; </div>
</li>
<li style="font-weight: bold;color:#26536A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; &nbsp; &nbsp; role.<span style="color: #006600;">setName</span><span style="color: #66cc66;">&#40;</span>RoleType.<span style="color: #006600;">ADMIN</span><span style="color: #66cc66;">&#41;</span>;</div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#3A6A8B;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; &nbsp; &nbsp; roleList.<span style="color: #006600;">add</span><span style="color: #66cc66;">&#40;</span>role<span style="color: #66cc66;">&#41;</span>;</div>
</li>
<li style="font-weight: bold;color:#26536A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; &nbsp; &nbsp; </div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#3A6A8B;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; &nbsp; &nbsp; user.<span style="color: #006600;">setRoleList</span><span style="color: #66cc66;">&#40;</span>roleList<span style="color: #66cc66;">&#41;</span>;</div>
</li>
<li style="font-weight: bold;color:#26536A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; &nbsp; &nbsp; </div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#3A6A8B;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; &nbsp; &nbsp; userService.<span style="color: #006600;">addUser</span><span style="color: #66cc66;">&#40;</span>user<span style="color: #66cc66;">&#41;</span>;</div>
</li>
<li style="font-weight: bold;color:#26536A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; &nbsp; &nbsp; </div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#3A6A8B;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; &nbsp; &nbsp; user = <span style="color: #000000; font-weight: bold;">new</span> User<span style="color: #66cc66;">&#40;</span><span style="color: #66cc66;">&#41;</span>;</div>
</li>
<li style="font-weight: bold;color:#26536A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; &nbsp; &nbsp; user.<span style="color: #006600;">setFullName</span><span style="color: #66cc66;">&#40;</span><span style="color: #ff0000;">"Nono Carballo Escalona1"</span><span style="color: #66cc66;">&#41;</span>;</div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#3A6A8B;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; &nbsp; &nbsp; user.<span style="color: #006600;">setUserName</span><span style="color: #66cc66;">&#40;</span><span style="color: #ff0000;">"nono1"</span><span style="color: #66cc66;">&#41;</span>;</div>
</li>
<li style="font-weight: bold;color:#26536A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; &nbsp; &nbsp; user.<span style="color: #006600;">setPassword</span><span style="color: #66cc66;">&#40;</span><span style="color: #ff0000;">"mypassword1"</span><span style="color: #66cc66;">&#41;</span>;</div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#3A6A8B;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; &nbsp; &nbsp; </div>
</li>
<li style="font-weight: bold;color:#26536A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; &nbsp; &nbsp; roleList = <span style="color: #000000; font-weight: bold;">new</span> ArrayList&lt;Role&gt;<span style="color: #66cc66;">&#40;</span><span style="color: #66cc66;">&#41;</span>;</div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#3A6A8B;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; &nbsp; &nbsp; </div>
</li>
<li style="font-weight: bold;color:#26536A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; &nbsp; &nbsp; role = <span style="color: #000000; font-weight: bold;">new</span> Role<span style="color: #66cc66;">&#40;</span><span style="color: #66cc66;">&#41;</span>;&nbsp; &nbsp; </div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#3A6A8B;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; &nbsp; &nbsp; role.<span style="color: #006600;">setName</span><span style="color: #66cc66;">&#40;</span>RoleType.<span style="color: #006600;">GEST</span><span style="color: #66cc66;">&#41;</span>;</div>
</li>
<li style="font-weight: bold;color:#26536A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; &nbsp; &nbsp; roleList.<span style="color: #006600;">add</span><span style="color: #66cc66;">&#40;</span>role<span style="color: #66cc66;">&#41;</span>;</div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#3A6A8B;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; &nbsp; &nbsp; </div>
</li>
<li style="font-weight: bold;color:#26536A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; &nbsp; &nbsp; user.<span style="color: #006600;">setRoleList</span><span style="color: #66cc66;">&#40;</span>roleList<span style="color: #66cc66;">&#41;</span>;</div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#3A6A8B;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; &nbsp; &nbsp; </div>
</li>
<li style="font-weight: bold;color:#26536A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; &nbsp; &nbsp; userService.<span style="color: #006600;">addUser</span><span style="color: #66cc66;">&#40;</span>user<span style="color: #66cc66;">&#41;</span>;</div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#3A6A8B;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; &nbsp; &nbsp; </div>
</li>
<li style="font-weight: bold;color:#26536A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; &nbsp; &nbsp; user = <span style="color: #000000; font-weight: bold;">new</span> User<span style="color: #66cc66;">&#40;</span><span style="color: #66cc66;">&#41;</span>;</div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#3A6A8B;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; &nbsp; &nbsp; user.<span style="color: #006600;">setFullName</span><span style="color: #66cc66;">&#40;</span><span style="color: #ff0000;">"Nono Carballo Escalona2"</span><span style="color: #66cc66;">&#41;</span>;</div>
</li>
<li style="font-weight: bold;color:#26536A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; &nbsp; &nbsp; user.<span style="color: #006600;">setUserName</span><span style="color: #66cc66;">&#40;</span><span style="color: #ff0000;">"nono2"</span><span style="color: #66cc66;">&#41;</span>;</div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#3A6A8B;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; &nbsp; &nbsp; user.<span style="color: #006600;">setPassword</span><span style="color: #66cc66;">&#40;</span><span style="color: #ff0000;">"mypassword2"</span><span style="color: #66cc66;">&#41;</span>;</div>
</li>
<li style="font-weight: bold;color:#26536A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; &nbsp; &nbsp; </div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#3A6A8B;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; &nbsp; &nbsp; roleList = <span style="color: #000000; font-weight: bold;">new</span> ArrayList&lt;Role&gt;<span style="color: #66cc66;">&#40;</span><span style="color: #66cc66;">&#41;</span>;</div>
</li>
<li style="font-weight: bold;color:#26536A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; &nbsp; &nbsp; </div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#3A6A8B;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; &nbsp; &nbsp; role = <span style="color: #000000; font-weight: bold;">new</span> Role<span style="color: #66cc66;">&#40;</span><span style="color: #66cc66;">&#41;</span>;&nbsp; &nbsp; </div>
</li>
<li style="font-weight: bold;color:#26536A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; &nbsp; &nbsp; role.<span style="color: #006600;">setName</span><span style="color: #66cc66;">&#40;</span>RoleType.<span style="color: #006600;">USER</span><span style="color: #66cc66;">&#41;</span>;</div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#3A6A8B;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; &nbsp; &nbsp; roleList.<span style="color: #006600;">add</span><span style="color: #66cc66;">&#40;</span>role<span style="color: #66cc66;">&#41;</span>;</div>
</li>
<li style="font-weight: bold;color:#26536A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; &nbsp; &nbsp; </div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#3A6A8B;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; &nbsp; &nbsp; user.<span style="color: #006600;">setRoleList</span><span style="color: #66cc66;">&#40;</span>roleList<span style="color: #66cc66;">&#41;</span>;</div>
</li>
<li style="font-weight: bold;color:#26536A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; &nbsp; &nbsp; </div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#3A6A8B;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; &nbsp; &nbsp; userService.<span style="color: #006600;">addUser</span><span style="color: #66cc66;">&#40;</span>user<span style="color: #66cc66;">&#41;</span>;</div>
</li>
<li style="font-weight: bold;color:#26536A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; &nbsp; &nbsp; </div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#3A6A8B;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; &nbsp; &nbsp; ArrayList&lt;User&gt; userList = <span style="color: #66cc66;">&#40;</span>ArrayList&lt;User&gt;<span style="color: #66cc66;">&#41;</span> userService.<span style="color: #006600;">loadAllUsers</span><span style="color: #66cc66;">&#40;</span><span style="color: #66cc66;">&#41;</span>;</div>
</li>
<li style="font-weight: bold;color:#26536A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; &nbsp; &nbsp; </div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#3A6A8B;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; &nbsp; &nbsp; assertTrue<span style="color: #66cc66;">&#40;</span>userList.<span style="color: #006600;">size</span><span style="color: #66cc66;">&#40;</span><span style="color: #66cc66;">&#41;</span> == <span style="color: #cc66cc;color:#800000;">3</span><span style="color: #66cc66;">&#41;</span>;</div>
</li>
<li style="font-weight: bold;color:#26536A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; &nbsp; &nbsp; </div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#3A6A8B;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; <span style="color: #66cc66;">&#125;</span></div>
</li>
<li style="font-weight: bold;color:#26536A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;"><span style="color: #66cc66;">&#125;</span> </div>
</li>
</ol>
</div>
</div>
</div>
<p></p>
<p>Para la interacción entre spring-flex y  Spring Security debe registrarse en el archivo web.xml el un filtro del tipo  DelegatingFilterProxy.</p>
<div class="igBar"><span id="lxml-24"><a href="#" onclick="javascript:showPlainTxt('xml-24'); return false;">PLAIN TEXT</a></span></div>
<div class="syntax_hilite"><span class="langName">XML:</span>
<div id="xml-24">
<div class="xml">
<ol>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#3A6A8B;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;"><span style="color: #009900;"><span style="font-weight: bold; color: black;">&lt;filter<span style="font-weight: bold; color: black;">&gt;</span></span></span> </div>
</li>
<li style="font-weight: bold;color:#26536A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp;&nbsp; &nbsp; &nbsp;<span style="color: #009900;"><span style="font-weight: bold; color: black;">&lt;filter</span>-name<span style="font-weight: bold; color: black;">&gt;</span></span>springSecurityFilterChain<span style="color: #009900;"><span style="font-weight: bold; color: black;">&lt;/filter</span>-name<span style="font-weight: bold; color: black;">&gt;</span></span> </div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#3A6A8B;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp;&nbsp; &nbsp; &nbsp;<span style="color: #009900;"><span style="font-weight: bold; color: black;">&lt;filter</span>-class<span style="font-weight: bold; color: black;">&gt;</span></span>org.springframework.web.filter.DelegatingFilterProxy<span style="color: #009900;"><span style="font-weight: bold; color: black;">&lt;/filter</span>-class<span style="font-weight: bold; color: black;">&gt;</span></span> </div>
</li>
<li style="font-weight: bold;color:#26536A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;"><span style="color: #009900;"><span style="font-weight: bold; color: black;">&lt;/filter<span style="font-weight: bold; color: black;">&gt;</span></span></span></div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#3A6A8B;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; </div>
</li>
<li style="font-weight: bold;color:#26536A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;"><span style="color: #009900;"><span style="font-weight: bold; color: black;">&lt;filter</span>-mapping<span style="font-weight: bold; color: black;">&gt;</span></span> </div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#3A6A8B;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #009900;"><span style="font-weight: bold; color: black;">&lt;filter</span>-name<span style="font-weight: bold; color: black;">&gt;</span></span>springSecurityFilterChain<span style="color: #009900;"><span style="font-weight: bold; color: black;">&lt;/filter</span>-name<span style="font-weight: bold; color: black;">&gt;</span></span> </div>
</li>
<li style="font-weight: bold;color:#26536A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #009900;"><span style="font-weight: bold; color: black;">&lt;url</span>-pattern<span style="font-weight: bold; color: black;">&gt;</span></span>/*<span style="color: #009900;"><span style="font-weight: bold; color: black;">&lt;/url</span>-pattern<span style="font-weight: bold; color: black;">&gt;</span></span> </div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#3A6A8B;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;"><span style="color: #009900;"><span style="font-weight: bold; color: black;">&lt;/filter</span>-mapping<span style="font-weight: bold; color: black;">&gt;</span></span> </div>
</li>
</ol>
</div>
</div>
</div>
<p></p>
<p>Debemos crear una clase a través de la cual Spring Security recuperará de la base de datos la información del usuario que intenta autenticarse. Esta clase implementará la interface UserDetailsService, que tiene un único método, loadUserByUsername, el cual será invocado por el proveedor de autenticación del framework.</p>
<p>MyUserDetailsService.java</p>
<div class="igBar"><span id="ljava-25"><a href="#" onclick="javascript:showPlainTxt('java-25'); return false;">PLAIN TEXT</a></span></div>
<div class="syntax_hilite"><span class="langName">JAVA:</span>
<div id="java-25">
<div class="java">
<ol>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#3A6A8B;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">package com.<span style="color: #006600;">nonocarballo</span>.<span style="color: #006600;">flexspringsecurity</span>.<span style="color: #006600;">service</span>;</div>
</li>
<li style="font-weight: bold;color:#26536A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp;</div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#3A6A8B;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;"><span style="color: #a1a100;">import java.util.ArrayList;</span></div>
</li>
<li style="font-weight: bold;color:#26536A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;"><span style="color: #a1a100;">import java.util.List;</span></div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#3A6A8B;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp;</div>
</li>
<li style="font-weight: bold;color:#26536A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;"><span style="color: #a1a100;">import org.apache.commons.logging.Log;</span></div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#3A6A8B;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;"><span style="color: #a1a100;">import org.apache.commons.logging.LogFactory;</span></div>
</li>
<li style="font-weight: bold;color:#26536A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;"><span style="color: #a1a100;">import org.springframework.beans.factory.annotation.Autowired;</span></div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#3A6A8B;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;"><span style="color: #a1a100;">import org.springframework.dao.DataAccessException;</span></div>
</li>
<li style="font-weight: bold;color:#26536A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;"><span style="color: #a1a100;">import org.springframework.security.core.GrantedAuthority;</span></div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#3A6A8B;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;"><span style="color: #a1a100;">import org.springframework.security.core.authority.GrantedAuthorityImpl;</span></div>
</li>
<li style="font-weight: bold;color:#26536A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;"><span style="color: #a1a100;">import org.springframework.security.core.userdetails.UserDetails;</span></div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#3A6A8B;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;"><span style="color: #a1a100;">import org.springframework.security.core.userdetails.UserDetailsService;</span></div>
</li>
<li style="font-weight: bold;color:#26536A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;"><span style="color: #a1a100;">import org.springframework.security.core.userdetails.UsernameNotFoundException;</span></div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#3A6A8B;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;"><span style="color: #a1a100;">import org.springframework.stereotype.Repository;</span></div>
</li>
<li style="font-weight: bold;color:#26536A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;"><span style="color: #a1a100;">import org.springframework.transaction.annotation.Transactional;</span></div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#3A6A8B;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp;</div>
</li>
<li style="font-weight: bold;color:#26536A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;"><span style="color: #a1a100;">import com.nonocarballo.flexspringsecurity.valueobject.AuthenticatedUser;</span></div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#3A6A8B;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;"><span style="color: #a1a100;">import com.nonocarballo.flexspringsecurity.valueobject.Role;</span></div>
</li>
<li style="font-weight: bold;color:#26536A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;"><span style="color: #a1a100;">import com.nonocarballo.flexspringsecurity.valueobject.User;</span></div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#3A6A8B;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp;</div>
</li>
<li style="font-weight: bold;color:#26536A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">@<a href="http://www.google.com/search?q=allinurl%3ARepository+java.sun.com&amp;bntl=1"><span style="color: #aaaadd; font-weight: bold;">Repository</span></a></div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#3A6A8B;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;"><span style="color: #000000; font-weight: bold;">public</span> <span style="color: #000000; font-weight: bold;">class</span> MyUserDetailsService <span style="color: #000000; font-weight: bold;">implements</span> UserDetailsService <span style="color: #66cc66;">&#123;</span></div>
</li>
<li style="font-weight: bold;color:#26536A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; </div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#3A6A8B;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; <span style="color: #000000; font-weight: bold;">private</span> IUserService userService;</div>
</li>
<li style="font-weight: bold;color:#26536A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp;</div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#3A6A8B;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; <span style="color: #000000; font-weight: bold;">public</span> IUserService getUserService<span style="color: #66cc66;">&#40;</span><span style="color: #66cc66;">&#41;</span> <span style="color: #66cc66;">&#123;</span></div>
</li>
<li style="font-weight: bold;color:#26536A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #000000; font-weight: bold;">return</span> userService;</div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#3A6A8B;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; <span style="color: #66cc66;">&#125;</span></div>
</li>
<li style="font-weight: bold;color:#26536A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp;</div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#3A6A8B;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; @Autowired</div>
</li>
<li style="font-weight: bold;color:#26536A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; <span style="color: #000000; font-weight: bold;">public</span> <span style="color: #993333;">void</span> setUserService<span style="color: #66cc66;">&#40;</span>IUserService userService<span style="color: #66cc66;">&#41;</span> <span style="color: #66cc66;">&#123;</span></div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#3A6A8B;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #000000; font-weight: bold;">this</span>.<span style="color: #006600;">userService</span> = userService;</div>
</li>
<li style="font-weight: bold;color:#26536A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; <span style="color: #66cc66;">&#125;</span></div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#3A6A8B;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp;</div>
</li>
<li style="font-weight: bold;color:#26536A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; @Override</div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#3A6A8B;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; @Transactional</div>
</li>
<li style="font-weight: bold;color:#26536A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; <span style="color: #000000; font-weight: bold;">public</span> UserDetails loadUserByUsername<span style="color: #66cc66;">&#40;</span><a href="http://www.google.com/search?q=allinurl%3AString+java.sun.com&amp;bntl=1"><span style="color: #aaaadd; font-weight: bold;">String</span></a> arg0<span style="color: #66cc66;">&#41;</span></div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#3A6A8B;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #000000; font-weight: bold;">throws</span> UsernameNotFoundException, DataAccessException <span style="color: #66cc66;">&#123;</span></div>
</li>
<li style="font-weight: bold;color:#26536A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; &nbsp; &nbsp; User user = userService.<span style="color: #006600;">loabByUserName</span><span style="color: #66cc66;">&#40;</span>arg0<span style="color: #66cc66;">&#41;</span>;</div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#3A6A8B;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #b1b100;">if</span><span style="color: #66cc66;">&#40;</span>user == <span style="color: #000000; font-weight: bold;">null</span><span style="color: #66cc66;">&#41;</span><span style="color: #66cc66;">&#123;</span></div>
</li>
<li style="font-weight: bold;color:#26536A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #000000; font-weight: bold;">throw</span> <span style="color: #000000; font-weight: bold;">new</span> </div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#3A6A8B;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">UsernameNotFoundException<span style="color: #66cc66;">&#40;</span><span style="color: #ff0000;">"User "</span>+arg0+<span style="color: #ff0000;">" not found."</span><span style="color: #66cc66;">&#41;</span>;</div>
</li>
<li style="font-weight: bold;color:#26536A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #66cc66;">&#125;</span></div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#3A6A8B;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; &nbsp; &nbsp; List&lt;Role&gt; roleList=<span style="color: #66cc66;">&#40;</span>List&lt;Role&gt;<span style="color: #66cc66;">&#41;</span> user.<span style="color: #006600;">getRoleList</span><span style="color: #66cc66;">&#40;</span><span style="color: #66cc66;">&#41;</span>;</div>
</li>
<li style="font-weight: bold;color:#26536A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; &nbsp; &nbsp; ArrayList&lt;GrantedAuthority&gt; grantedAuthorities = <span style="color: #000000; font-weight: bold;">new</span></div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#3A6A8B;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp;ArrayList&lt;GrantedAuthority&gt;<span style="color: #66cc66;">&#40;</span><span style="color: #66cc66;">&#41;</span>;</div>
</li>
<li style="font-weight: bold;color:#26536A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #b1b100;">for</span><span style="color: #66cc66;">&#40;</span>Role role : roleList<span style="color: #66cc66;">&#41;</span><span style="color: #66cc66;">&#123;</span></div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#3A6A8B;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; grantedAuthorities.<span style="color: #006600;">add</span><span style="color: #66cc66;">&#40;</span><span style="color: #000000; font-weight: bold;">new</span> GrantedAuthorityImpl<span style="color: #66cc66;">&#40;</span>role.<span style="color: #006600;">getName</span><span style="color: #66cc66;">&#40;</span><span style="color: #66cc66;">&#41;</span><span style="color: #66cc66;">&#41;</span><span style="color: #66cc66;">&#41;</span>;</div>
</li>
<li style="font-weight: bold;color:#26536A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #66cc66;">&#125;</span></div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#3A6A8B;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #000000; font-weight: bold;">return</span> <span style="color: #000000; font-weight: bold;">new</span></div>
</li>
<li style="font-weight: bold;color:#26536A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp;org.<span style="color: #006600;">springframework</span>.<span style="color: #006600;">security</span>.<span style="color: #006600;">core</span>.<span style="color: #006600;">userdetails</span>.<span style="color: #006600;">User</span><span style="color: #66cc66;">&#40;</span>user.<span style="color: #006600;">getUserName</span><span style="color: #66cc66;">&#40;</span><span style="color: #66cc66;">&#41;</span>, </div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#3A6A8B;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; user.<span style="color: #006600;">getPassword</span><span style="color: #66cc66;">&#40;</span><span style="color: #66cc66;">&#41;</span>, <span style="color: #000000; font-weight: bold;">true</span>, <span style="color: #000000; font-weight: bold;">true</span>, <span style="color: #000000; font-weight: bold;">true</span>, <span style="color: #000000; font-weight: bold;">true</span>, grantedAuthorities<span style="color: #66cc66;">&#41;</span>;</div>
</li>
<li style="font-weight: bold;color:#26536A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; &nbsp; &nbsp; </div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#3A6A8B;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; <span style="color: #66cc66;">&#125;</span></div>
</li>
<li style="font-weight: bold;color:#26536A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;"><span style="color: #66cc66;">&#125;</span> </div>
</li>
</ol>
</div>
</div>
</div>
<p></p>
<p>El objeto de tipo org.springframework.security.core.userdetails.User contiene la información que llegará a la aplicación Flex, en este caso el nombre de usuario y los roles que tiene asignados.</p>
<p>Ahora debemos informar a Spring Security que use nuestra clase y no la que trae el framework, esto se hace en el archivo web-application-context-config.xml, la configuración final queda como sigue:</p>
<div class="igBar"><span id="lxml-26"><a href="#" onclick="javascript:showPlainTxt('xml-26'); return false;">PLAIN TEXT</a></span></div>
<div class="syntax_hilite"><span class="langName">XML:</span>
<div id="xml-26">
<div class="xml">
<ol>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#3A6A8B;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;"><span style="color: #009900;"><span style="font-weight: bold; color: black;">&lt;security</span>:http <span style="color: #000066;">entry-point-ref</span>=<span style="color: #ff0000;">"entryPoint"</span><span style="font-weight: bold; color: black;">&gt;</span></span></div>
</li>
<li style="font-weight: bold;color:#26536A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp;<span style="color: #009900;"><span style="font-weight: bold; color: black;">&lt;security</span>:anonymous <span style="color: #000066;">enabled</span>=<span style="color: #ff0000;">"false"</span><span style="font-weight: bold; color: black;">/&gt;</span></span></div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#3A6A8B;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp;<span style="color: #009900;"><span style="font-weight: bold; color: black;">&lt;/security</span>:http<span style="font-weight: bold; color: black;">&gt;</span></span></div>
</li>
<li style="font-weight: bold;color:#26536A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; </div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#3A6A8B;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp;<span style="color: #009900;"><span style="font-weight: bold; color: black;">&lt;bean</span> <span style="color: #000066;">id</span>=<span style="color: #ff0000;">"entryPoint"</span> <span style="color: #000066;">class</span>=<span style="color: #ff0000;">"org.springframework.security.web.authentication.Http403ForbiddenEntryPoint"</span><span style="font-weight: bold; color: black;">/&gt;</span></span></div>
</li>
<li style="font-weight: bold;color:#26536A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp;</div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#3A6A8B;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;"><span style="color: #009900;"><span style="font-weight: bold; color: black;">&lt;security</span>:authentication-manager<span style="font-weight: bold; color: black;">&gt;</span></span></div>
</li>
<li style="font-weight: bold;color:#26536A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; <span style="color: #009900;"><span style="font-weight: bold; color: black;">&lt;security</span>:authentication-provider <span style="color: #000066;">user-service-ref</span>=<span style="color: #ff0000;">"myUserDetailsService"</span><span style="font-weight: bold; color: black;">/&gt;</span></span></div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#3A6A8B;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;"><span style="color: #009900;"><span style="font-weight: bold; color: black;">&lt;/security</span>:authentication-manager<span style="font-weight: bold; color: black;">&gt;</span></span> </div>
</li>
</ol>
</div>
</div>
</div>
<p></p>
<p>Y finalmente de debemos informar a spring-flex (en el archivo web-application-config.xml) que utilice el servicio de autenticación de Spring Security.</p>
<div class="igBar"><span id="lxml-27"><a href="#" onclick="javascript:showPlainTxt('xml-27'); return false;">PLAIN TEXT</a></span></div>
<div class="syntax_hilite"><span class="langName">XML:</span>
<div id="xml-27">
<div class="xml">
<ol>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#3A6A8B;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;"><span style="color: #009900;"><span style="font-weight: bold; color: black;">&lt;flex</span>:message-broker<span style="font-weight: bold; color: black;">&gt;</span></span>&nbsp; &nbsp;</div>
</li>
<li style="font-weight: bold;color:#26536A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; <span style="color: #009900;"><span style="font-weight: bold; color: black;">&lt;flex</span>:secured <span style="font-weight: bold; color: black;">/&gt;</span></span></div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#3A6A8B;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;"><span style="color: #009900;"><span style="font-weight: bold; color: black;">&lt;/flex</span>:message-broker<span style="font-weight: bold; color: black;">&gt;</span></span> </div>
</li>
</ol>
</div>
</div>
</div>
<p></p>
<h4 id="toc-la-aplicacion-flex">La aplicación Flex</h4>
<p>Crearemos un proyecto Flex que llamaremos FlexSpringSecurityUI con las siguientes características:</p>
<ul>
<li>Application Type: Web</li>
<li>Flex SDK Version: Flex 4.0</li>
<li>Application Server Type: J2EE</li>
<li>Remote access service: BlazeDS</li>
<li>RootFolder: el camino a la carpeta FlexSecurity/WebContent</li>
<li>Root URL: el URL donde se desplegó el proyecto FlexSpringSecurity</li>
<li>Context root: flexspringsecurity</li>
</ul>
<p>Nuestra aplicación  Flex contendrá un formulario para autenticación y un botón para entrar (login) y salir (logout).</p>
<p><a href="http://www.madeinflex.com/wp-content/uploads/2010/08/login.png"><img src="http://www.madeinflex.com/wp-content/uploads/2010/08/login.png" alt="login" title="login" width="220" height="98" class="aligncenter size-full wp-image-1687" /></a></p>
<p>Crearemos un objeto de tipo ChannelSet y le adicionaremos un canal de tipo AMFChannel, luego para invocar al servicio de autenticación de Spring Security desde Flex utilizaremos el método login de lal objeto ChannelSet, lo invocaremos pasándole como argumentos el nombre de usuario y la contraseña introducidos en el formulario. En esta aplicación recuperaremos el URL donde está desplegado el back-end en tiempo de ejecución, desde un archivo xml, y utilizaremos esa información para crear programáticamente el canal e insertarlo en el ChannelSet. Nos auxiliaremos del framework Robotlegs.</p>
<p>channels.xml</p>
<div class="igBar"><span id="lxml-28"><a href="#" onclick="javascript:showPlainTxt('xml-28'); return false;">PLAIN TEXT</a></span></div>
<div class="syntax_hilite"><span class="langName">XML:</span>
<div id="xml-28">
<div class="xml">
<ol>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#3A6A8B;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;"><span style="color: #009900;"><span style="font-weight: bold; color: black;">&lt;</span>?xml <span style="color: #000066;">version</span>=<span style="color: #ff0000;">"1.0"</span> <span style="color: #000066;">encoding</span>=<span style="color: #ff0000;">"UTF-8"</span>?<span style="font-weight: bold; color: black;">&gt;</span></span></div>
</li>
<li style="font-weight: bold;color:#26536A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;"><span style="color: #009900;"><span style="font-weight: bold; color: black;">&lt;channels<span style="font-weight: bold; color: black;">&gt;</span></span></span></div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#3A6A8B;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; <span style="color: #009900;"><span style="font-weight: bold; color: black;">&lt;channel</span> <span style="color: #000066;">type</span>=<span style="color: #ff0000;">"amf"</span><span style="font-weight: bold; color: black;">&gt;</span></span></div>
</li>
<li style="font-weight: bold;color:#26536A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #009900;"><span style="font-weight: bold; color: black;">&lt;uri<span style="font-weight: bold; color: black;">&gt;</span></span></span>http://localhost:8080/flexspringsecurity<span style="color: #009900;"><span style="font-weight: bold; color: black;">&lt;/uri<span style="font-weight: bold; color: black;">&gt;</span></span></span></div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#3A6A8B;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; <span style="color: #009900;"><span style="font-weight: bold; color: black;">&lt;/channel<span style="font-weight: bold; color: black;">&gt;</span></span></span></div>
</li>
<li style="font-weight: bold;color:#26536A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; <span style="color: #009900;"><span style="font-weight: bold; color: black;">&lt;channel</span> <span style="color: #000066;">type</span>=<span style="color: #ff0000;">"secure-amf"</span><span style="font-weight: bold; color: black;">&gt;</span></span></div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#3A6A8B;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #009900;"><span style="font-weight: bold; color: black;">&lt;uri<span style="font-weight: bold; color: black;">&gt;</span></span></span>https://localhost:8080/flexspringsecurity<span style="color: #009900;"><span style="font-weight: bold; color: black;">&lt;/uri<span style="font-weight: bold; color: black;">&gt;</span></span></span></div>
</li>
<li style="font-weight: bold;color:#26536A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; <span style="color: #009900;"><span style="font-weight: bold; color: black;">&lt;/channel<span style="font-weight: bold; color: black;">&gt;</span></span></span></div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#3A6A8B;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;"><span style="color: #009900;"><span style="font-weight: bold; color: black;">&lt;/channels<span style="font-weight: bold; color: black;">&gt;</span></span></span> </div>
</li>
</ol>
</div>
</div>
</div>
<p></p>
<div class="igBar"><span id="lactionscript3-29"><a href="#" onclick="javascript:showPlainTxt('actionscript3-29'); return false;">PLAIN TEXT</a></span></div>
<div class="syntax_hilite"><span class="langName">Actionscript 3:</span>
<div id="actionscript3-29">
<div class="actionscript3">
<ol>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#3A6A8B;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;"><span style="color: #9900cc; font-weight: bold;">package</span> com.nonocarballo.flexspringsecurity.command</div>
</li>
<li style="font-weight: bold;color:#26536A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;"><span style="color: #000000;">&#123;</span></div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#3A6A8B;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; <span style="color: #0033ff; font-weight: bold;">import</span> mx.messaging.ChannelSet;</div>
</li>
<li style="font-weight: bold;color:#26536A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; <span style="color: #0033ff; font-weight: bold;">import</span> mx.messaging.channels.AMFChannel;</div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#3A6A8B;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; <span style="color: #0033ff; font-weight: bold;">import</span> mx.rpc.CallResponder;</div>
</li>
<li style="font-weight: bold;color:#26536A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; <span style="color: #0033ff; font-weight: bold;">import</span> mx.rpc.events.ResultEvent;</div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#3A6A8B;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; <span style="color: #0033ff; font-weight: bold;">import</span> mx.rpc.http.HTTPService;</div>
</li>
<li style="font-weight: bold;color:#26536A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; </div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#3A6A8B;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; <span style="color: #0033ff; font-weight: bold;">import</span> org.robotlegs.mvcs.Command;</div>
</li>
<li style="font-weight: bold;color:#26536A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; </div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#3A6A8B;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; <span style="color: #0033ff; font-weight: bold;">public</span> <span style="color: #9900cc; font-weight: bold;">class</span> LoadConfigCommand <span style="color: #0033ff; font-weight: bold;">extends</span> Command</div>
</li>
<li style="font-weight: bold;color:#26536A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; <span style="color: #000000;">&#123;</span></div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#3A6A8B;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #0033ff; font-weight: bold;">public</span> <span style="color: #339966; font-weight: bold;">function</span> LoadConfigCommand<span style="color: #000000;">&#40;</span><span style="color: #000000;">&#41;</span></div>
</li>
<li style="font-weight: bold;color:#26536A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #000000;">&#123;</span></div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#3A6A8B;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #0033ff; font-weight: bold;">super</span><span style="color: #000000;">&#40;</span><span style="color: #000000;">&#41;</span>;</div>
</li>
<li style="font-weight: bold;color:#26536A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #000000;">&#125;</span></div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#3A6A8B;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; &nbsp; &nbsp; </div>
</li>
<li style="font-weight: bold;color:#26536A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #0033ff; font-weight: bold;">private</span> <span style="color: #6699cc; font-weight: bold;">var</span> responder:CallResponder = <span style="color: #0033ff; font-weight: bold;">new</span> CallResponder<span style="color: #000000;">&#40;</span><span style="color: #000000;">&#41;</span>;</div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#3A6A8B;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; &nbsp; &nbsp; </div>
</li>
<li style="font-weight: bold;color:#26536A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #0033ff; font-weight: bold;">override</span> <span style="color: #0033ff; font-weight: bold;">public</span> <span style="color: #339966; font-weight: bold;">function</span> execute<span style="color: #000000;">&#40;</span><span style="color: #000000;">&#41;</span>:<span style="color: #0033ff; font-weight: bold;">void</span><span style="color: #000000;">&#123;</span></div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#3A6A8B;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #6699cc; font-weight: bold;">var</span> service:HTTPService = <span style="color: #0033ff; font-weight: bold;">new</span> HTTPService<span style="color: #000000;">&#40;</span><span style="color: #000000;">&#41;</span>;</div>
</li>
<li style="font-weight: bold;color:#26536A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; service.<span style="color: #004993;">url</span> = <span style="color: #990000;">"config/channels.xml"</span>;</div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#3A6A8B;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; service.resultFormat = <span style="color: #990000;">"e4x"</span>;</div>
</li>
<li style="font-weight: bold;color:#26536A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; </div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#3A6A8B;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; responder.<span style="color: #004993;">addEventListener</span><span style="color: #000000;">&#40;</span>ResultEvent.RESULT, resultHandler<span style="color: #000000;">&#41;</span>;</div>
</li>
<li style="font-weight: bold;color:#26536A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; responder.token = service.<span style="color: #004993;">send</span><span style="color: #000000;">&#40;</span><span style="color: #000000;">&#41;</span>;</div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#3A6A8B;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #000000;">&#125;</span></div>
</li>
<li style="font-weight: bold;color:#26536A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; &nbsp; &nbsp; </div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#3A6A8B;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #0033ff; font-weight: bold;">private</span> <span style="color: #339966; font-weight: bold;">function</span> resultHandler<span style="color: #000000;">&#40;</span>event: ResultEvent<span style="color: #000000;">&#41;</span>:<span style="color: #0033ff; font-weight: bold;">void</span><span style="color: #000000;">&#123;</span></div>
</li>
<li style="font-weight: bold;color:#26536A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #6699cc; font-weight: bold;">var</span> xml:<span style="color: #004993;">XML</span> = event.result <span style="color: #0033ff; font-weight: bold;">as</span> <span style="color: #004993;">XML</span>;</div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#3A6A8B;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; </div>
</li>
<li style="font-weight: bold;color:#26536A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #6699cc; font-weight: bold;">var</span> channelSet:ChannelSet = <span style="color: #0033ff; font-weight: bold;">new</span> ChannelSet<span style="color: #000000;">&#40;</span><span style="color: #000000;">&#41;</span>;</div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#3A6A8B;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #0033ff; font-weight: bold;">for</span> <span style="color: #0033ff; font-weight: bold;">each</span><span style="color: #000000;">&#40;</span><span style="color: #6699cc; font-weight: bold;">var</span> item:<span style="color: #004993;">XML</span> <span style="color: #0033ff; font-weight: bold;">in</span> xml..channel<span style="color: #000000;">&#41;</span><span style="color: #000000;">&#123;</span></div>
</li>
<li style="font-weight: bold;color:#26536A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #0033ff; font-weight: bold;">if</span><span style="color: #000000;">&#40;</span>item.@<span style="color: #004993;">type</span>==<span style="color: #990000;">"amf"</span><span style="color: #000000;">&#41;</span><span style="color: #000000;">&#123;</span></div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#3A6A8B;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #6699cc; font-weight: bold;">var</span> amfChannel:AMFChannel = <span style="color: #0033ff; font-weight: bold;">new</span> AMFChannel<span style="color: #000000;">&#40;</span><span style="color: #000000;">&#41;</span>;</div>
</li>
<li style="font-weight: bold;color:#26536A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; amfChannel.<span style="color: #004993;">uri</span> = item.<span style="color: #004993;">uri</span>+<span style="color: #990000;">"/messagebroker/amf"</span>;</div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#3A6A8B;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; channelSet.addChannel<span style="color: #000000;">&#40;</span>amfChannel<span style="color: #000000;">&#41;</span>;</div>
</li>
<li style="font-weight: bold;color:#26536A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #0033ff; font-weight: bold;">break</span>;</div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#3A6A8B;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #000000;">&#125;</span></div>
</li>
<li style="font-weight: bold;color:#26536A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #000000;">&#125;</span></div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#3A6A8B;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; injector.mapValue<span style="color: #000000;">&#40;</span>ChannelSet, channelSet<span style="color: #000000;">&#41;</span>;</div>
</li>
<li style="font-weight: bold;color:#26536A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #000000;">&#125;</span></div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#3A6A8B;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; <span style="color: #000000;">&#125;</span></div>
</li>
<li style="font-weight: bold;color:#26536A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;"><span style="color: #000000;">&#125;</span> </div>
</li>
</ol>
</div>
</div>
</div>
<p></p>
<p>Cuando presionamos el botón “Entrar” invocamos el método login del objeto ChannelSet con la credencial del usuario:</p>
<div class="igBar"><span id="lactionscript3-30"><a href="#" onclick="javascript:showPlainTxt('actionscript3-30'); return false;">PLAIN TEXT</a></span></div>
<div class="syntax_hilite"><span class="langName">Actionscript 3:</span>
<div id="actionscript3-30">
<div class="actionscript3">
<ol>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#3A6A8B;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;"><span style="color: #9900cc; font-weight: bold;">package</span> com.nonocarballo.flexspringsecurity.command</div>
</li>
<li style="font-weight: bold;color:#26536A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;"><span style="color: #000000;">&#123;</span></div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#3A6A8B;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; <span style="color: #0033ff; font-weight: bold;">import</span> com.nonocarballo.flexspringsecurity.event.AuthenticatedEvent;</div>
</li>
<li style="font-weight: bold;color:#26536A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; <span style="color: #0033ff; font-weight: bold;">import</span> com.nonocarballo.flexspringsecurity.event.LoginEvent;</div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#3A6A8B;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; </div>
</li>
<li style="font-weight: bold;color:#26536A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; <span style="color: #0033ff; font-weight: bold;">import</span> <span style="color: #004993;">flash.events</span>.<span style="color: #004993;">Event</span>;</div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#3A6A8B;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; </div>
</li>
<li style="font-weight: bold;color:#26536A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; <span style="color: #0033ff; font-weight: bold;">import</span> mx.messaging.ChannelSet;</div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#3A6A8B;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; <span style="color: #0033ff; font-weight: bold;">import</span> mx.rpc.CallResponder;</div>
</li>
<li style="font-weight: bold;color:#26536A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; <span style="color: #0033ff; font-weight: bold;">import</span> mx.rpc.events.FaultEvent;</div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#3A6A8B;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; <span style="color: #0033ff; font-weight: bold;">import</span> mx.rpc.events.ResultEvent;</div>
</li>
<li style="font-weight: bold;color:#26536A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; </div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#3A6A8B;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; <span style="color: #0033ff; font-weight: bold;">import</span> org.robotlegs.mvcs.Command;</div>
</li>
<li style="font-weight: bold;color:#26536A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; </div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#3A6A8B;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; <span style="color: #0033ff; font-weight: bold;">public</span> <span style="color: #9900cc; font-weight: bold;">class</span> LoginCommand <span style="color: #0033ff; font-weight: bold;">extends</span> Command</div>
</li>
<li style="font-weight: bold;color:#26536A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; <span style="color: #000000;">&#123;</span></div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#3A6A8B;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #0033ff; font-weight: bold;">public</span> <span style="color: #339966; font-weight: bold;">function</span> LoginCommand<span style="color: #000000;">&#40;</span><span style="color: #000000;">&#41;</span></div>
</li>
<li style="font-weight: bold;color:#26536A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #000000;">&#123;</span></div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#3A6A8B;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #0033ff; font-weight: bold;">super</span><span style="color: #000000;">&#40;</span><span style="color: #000000;">&#41;</span>;</div>
</li>
<li style="font-weight: bold;color:#26536A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #000000;">&#125;</span></div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#3A6A8B;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; &nbsp; &nbsp; </div>
</li>
<li style="font-weight: bold;color:#26536A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #000000;">&#91;</span>Inject<span style="color: #000000;">&#93;</span></div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#3A6A8B;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #0033ff; font-weight: bold;">public</span> <span style="color: #6699cc; font-weight: bold;">var</span> channelSet:ChannelSet;</div>
</li>
<li style="font-weight: bold;color:#26536A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; &nbsp; &nbsp; </div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#3A6A8B;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #000000;">&#91;</span>Inject<span style="color: #000000;">&#93;</span></div>
</li>
<li style="font-weight: bold;color:#26536A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #0033ff; font-weight: bold;">public</span> <span style="color: #6699cc; font-weight: bold;">var</span> event:LoginEvent;</div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#3A6A8B;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; &nbsp; &nbsp; </div>
</li>
<li style="font-weight: bold;color:#26536A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #0033ff; font-weight: bold;">private</span> <span style="color: #6699cc; font-weight: bold;">var</span> responder:CallResponder = <span style="color: #0033ff; font-weight: bold;">new</span> CallResponder<span style="color: #000000;">&#40;</span><span style="color: #000000;">&#41;</span>;</div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#3A6A8B;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; &nbsp; &nbsp; </div>
</li>
<li style="font-weight: bold;color:#26536A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #0033ff; font-weight: bold;">override</span> <span style="color: #0033ff; font-weight: bold;">public</span> <span style="color: #339966; font-weight: bold;">function</span> execute<span style="color: #000000;">&#40;</span><span style="color: #000000;">&#41;</span>:<span style="color: #0033ff; font-weight: bold;">void</span><span style="color: #000000;">&#123;</span></div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#3A6A8B;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #0033ff; font-weight: bold;">if</span><span style="color: #000000;">&#40;</span>!channelSet.authenticated<span style="color: #000000;">&#41;</span><span style="color: #000000;">&#123;</span></div>
</li>
<li style="font-weight: bold;color:#26536A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; responder.<span style="color: #004993;">addEventListener</span><span style="color: #000000;">&#40;</span>ResultEvent.RESULT, resultHandler<span style="color: #000000;">&#41;</span>;</div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#3A6A8B;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; responder.<span style="color: #004993;">addEventListener</span><span style="color: #000000;">&#40;</span>FaultEvent.FAULT, faultHandler<span style="color: #000000;">&#41;</span>;</div>
</li>
<li style="font-weight: bold;color:#26536A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; responder.token = channelSet.login<span style="color: #000000;">&#40;</span>event.username, </div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#3A6A8B;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">event.password<span style="color: #000000;">&#41;</span>;</div>
</li>
<li style="font-weight: bold;color:#26536A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #000000;">&#125;</span></div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#3A6A8B;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #000000;">&#125;</span></div>
</li>
<li style="font-weight: bold;color:#26536A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; &nbsp; &nbsp; </div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#3A6A8B;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #0033ff; font-weight: bold;">private</span> <span style="color: #339966; font-weight: bold;">function</span> resultHandler<span style="color: #000000;">&#40;</span>event:ResultEvent<span style="color: #000000;">&#41;</span>:<span style="color: #0033ff; font-weight: bold;">void</span><span style="color: #000000;">&#123;</span></div>
</li>
<li style="font-weight: bold;color:#26536A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; dispatch<span style="color: #000000;">&#40;</span><span style="color: #0033ff; font-weight: bold;">new</span> AuthenticatedEvent<span style="color: #000000;">&#40;</span>AuthenticatedEvent.AUTHENTICATED, </div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#3A6A8B;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">event.result<span style="color: #000000;">&#41;</span><span style="color: #000000;">&#41;</span>;</div>
</li>
<li style="font-weight: bold;color:#26536A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #000000;">&#125;</span></div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#3A6A8B;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; &nbsp; &nbsp; </div>
</li>
<li style="font-weight: bold;color:#26536A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #0033ff; font-weight: bold;">private</span> <span style="color: #339966; font-weight: bold;">function</span> faultHandler<span style="color: #000000;">&#40;</span>event:FaultEvent<span style="color: #000000;">&#41;</span>:<span style="color: #0033ff; font-weight: bold;">void</span><span style="color: #000000;">&#123;</span></div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#3A6A8B;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; dispatch<span style="color: #000000;">&#40;</span><span style="color: #0033ff; font-weight: bold;">new</span> AuthenticatedEvent<span style="color: #000000;">&#40;</span>AuthenticatedEvent.LOGIN_FAILURE<span style="color: #000000;">&#41;</span><span style="color: #000000;">&#41;</span>;</div>
</li>
<li style="font-weight: bold;color:#26536A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #000000;">&#125;</span></div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#3A6A8B;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; <span style="color: #000000;">&#125;</span></div>
</li>
<li style="font-weight: bold;color:#26536A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;"><span style="color: #000000;">&#125;</span> </div>
</li>
</ol>
</div>
</div>
</div>
<p></p>
<p>Si la credencial de usuario no es válida obtendremos:</p>
<p><a href="http://www.madeinflex.com/wp-content/uploads/2010/08/login-fail.png"><img src="http://www.madeinflex.com/wp-content/uploads/2010/08/login-fail.png" alt="login-fail" title="login-fail" width="254" height="138" class="aligncenter size-full wp-image-1688" /></a></p>
<p>En caso contrario:</p>
<p><a href="http://www.madeinflex.com/wp-content/uploads/2010/08/login-ok-pre.png"><img src="http://www.madeinflex.com/wp-content/uploads/2010/08/login-ok-pre.png" alt="login-ok-pre" title="login-ok-pre" width="251" height="165" class="aligncenter size-full wp-image-1689" /></a></p>
<h4 id="toc-mas-informacion-del-usuario-en-flex">Más información del usuario en Flex</h4>
<p>Con el objeto org.springframework.security.core.userdetails.User solo obtenemos información del nombre de usuario y los roles, pero casi nunca esa información es suficiente. Haremos los cambios necesarios para poder traer hacia la aplicación Flex información extra del usuario que se ha autenticado.</p>
<p>Primeramente debemos crear nuestra propia implementación de UserDetails y añadir toda la información que necesitemos, en nuestro caso solo añadimos el nombre completo del usuario (fullname).</p>
<p>AuthenticatedUser.java</p>
<div class="igBar"><span id="ljava-31"><a href="#" onclick="javascript:showPlainTxt('java-31'); return false;">PLAIN TEXT</a></span></div>
<div class="syntax_hilite"><span class="langName">JAVA:</span>
<div id="java-31">
<div class="java">
<ol>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#3A6A8B;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">package com.<span style="color: #006600;">nonocarballo</span>.<span style="color: #006600;">flexspringsecurity</span>.<span style="color: #006600;">valueobject</span>;</div>
</li>
<li style="font-weight: bold;color:#26536A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp;</div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#3A6A8B;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;"><span style="color: #a1a100;">import java.util.Collection;</span></div>
</li>
<li style="font-weight: bold;color:#26536A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp;</div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#3A6A8B;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;"><span style="color: #a1a100;">import org.springframework.security.core.GrantedAuthority;</span></div>
</li>
<li style="font-weight: bold;color:#26536A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;"><span style="color: #a1a100;">import org.springframework.security.core.userdetails.UserDetails;</span></div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#3A6A8B;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp;</div>
</li>
<li style="font-weight: bold;color:#26536A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">@SuppressWarnings<span style="color: #66cc66;">&#40;</span><span style="color: #ff0000;">"serial"</span><span style="color: #66cc66;">&#41;</span></div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#3A6A8B;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;"><span style="color: #000000; font-weight: bold;">public</span> <span style="color: #000000; font-weight: bold;">class</span> AuthenticatedUser <span style="color: #000000; font-weight: bold;">implements</span> UserDetails <span style="color: #66cc66;">&#123;</span></div>
</li>
<li style="font-weight: bold;color:#26536A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp;</div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#3A6A8B;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; <span style="color: #000000; font-weight: bold;">private</span> <a href="http://www.google.com/search?q=allinurl%3AString+java.sun.com&amp;bntl=1"><span style="color: #aaaadd; font-weight: bold;">String</span></a> username;</div>
</li>
<li style="font-weight: bold;color:#26536A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; <span style="color: #000000; font-weight: bold;">private</span> <a href="http://www.google.com/search?q=allinurl%3AString+java.sun.com&amp;bntl=1"><span style="color: #aaaadd; font-weight: bold;">String</span></a> password;</div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#3A6A8B;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; <span style="color: #000000; font-weight: bold;">private</span> <a href="http://www.google.com/search?q=allinurl%3AString+java.sun.com&amp;bntl=1"><span style="color: #aaaadd; font-weight: bold;">String</span></a> fullname;</div>
</li>
<li style="font-weight: bold;color:#26536A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; </div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#3A6A8B;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; </div>
</li>
<li style="font-weight: bold;color:#26536A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; <span style="color: #000000; font-weight: bold;">public</span> <a href="http://www.google.com/search?q=allinurl%3AString+java.sun.com&amp;bntl=1"><span style="color: #aaaadd; font-weight: bold;">String</span></a> getFullname<span style="color: #66cc66;">&#40;</span><span style="color: #66cc66;">&#41;</span> <span style="color: #66cc66;">&#123;</span></div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#3A6A8B;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #000000; font-weight: bold;">return</span> fullname;</div>
</li>
<li style="font-weight: bold;color:#26536A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; <span style="color: #66cc66;">&#125;</span></div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#3A6A8B;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp;</div>
</li>
<li style="font-weight: bold;color:#26536A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; <span style="color: #000000; font-weight: bold;">private</span> Collection&lt;GrantedAuthority&gt; authorities;</div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#3A6A8B;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; </div>
</li>
<li style="font-weight: bold;color:#26536A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; @Override</div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#3A6A8B;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; <span style="color: #000000; font-weight: bold;">public</span> Collection&lt;GrantedAuthority&gt; getAuthorities<span style="color: #66cc66;">&#40;</span><span style="color: #66cc66;">&#41;</span> <span style="color: #66cc66;">&#123;</span></div>
</li>
<li style="font-weight: bold;color:#26536A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #808080; font-style: italic;">// TODO Auto-generated method stub</span></div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#3A6A8B;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #000000; font-weight: bold;">return</span> authorities;</div>
</li>
<li style="font-weight: bold;color:#26536A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; <span style="color: #66cc66;">&#125;</span></div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#3A6A8B;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp;</div>
</li>
<li style="font-weight: bold;color:#26536A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; @Override</div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#3A6A8B;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; <span style="color: #000000; font-weight: bold;">public</span> <a href="http://www.google.com/search?q=allinurl%3AString+java.sun.com&amp;bntl=1"><span style="color: #aaaadd; font-weight: bold;">String</span></a> getPassword<span style="color: #66cc66;">&#40;</span><span style="color: #66cc66;">&#41;</span> <span style="color: #66cc66;">&#123;</span></div>
</li>
<li style="font-weight: bold;color:#26536A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #808080; font-style: italic;">// TODO Auto-generated method stub</span></div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#3A6A8B;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #000000; font-weight: bold;">return</span> password;</div>
</li>
<li style="font-weight: bold;color:#26536A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; <span style="color: #66cc66;">&#125;</span></div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#3A6A8B;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp;</div>
</li>
<li style="font-weight: bold;color:#26536A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; @Override</div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#3A6A8B;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; <span style="color: #000000; font-weight: bold;">public</span> <a href="http://www.google.com/search?q=allinurl%3AString+java.sun.com&amp;bntl=1"><span style="color: #aaaadd; font-weight: bold;">String</span></a> getUsername<span style="color: #66cc66;">&#40;</span><span style="color: #66cc66;">&#41;</span> <span style="color: #66cc66;">&#123;</span></div>
</li>
<li style="font-weight: bold;color:#26536A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #808080; font-style: italic;">// TODO Auto-generated method stub</span></div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#3A6A8B;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #000000; font-weight: bold;">return</span> username;</div>
</li>
<li style="font-weight: bold;color:#26536A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; <span style="color: #66cc66;">&#125;</span></div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#3A6A8B;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp;</div>
</li>
<li style="font-weight: bold;color:#26536A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; @Override</div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#3A6A8B;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; <span style="color: #000000; font-weight: bold;">public</span> <span style="color: #993333;">boolean</span> isAccountNonExpired<span style="color: #66cc66;">&#40;</span><span style="color: #66cc66;">&#41;</span> <span style="color: #66cc66;">&#123;</span></div>
</li>
<li style="font-weight: bold;color:#26536A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #808080; font-style: italic;">// TODO Auto-generated method stub</span></div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#3A6A8B;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #000000; font-weight: bold;">return</span> <span style="color: #000000; font-weight: bold;">true</span>;</div>
</li>
<li style="font-weight: bold;color:#26536A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; <span style="color: #66cc66;">&#125;</span></div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#3A6A8B;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp;</div>
</li>
<li style="font-weight: bold;color:#26536A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; @Override</div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#3A6A8B;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; <span style="color: #000000; font-weight: bold;">public</span> <span style="color: #993333;">boolean</span> isAccountNonLocked<span style="color: #66cc66;">&#40;</span><span style="color: #66cc66;">&#41;</span> <span style="color: #66cc66;">&#123;</span></div>
</li>
<li style="font-weight: bold;color:#26536A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #808080; font-style: italic;">// TODO Auto-generated method stub</span></div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#3A6A8B;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #000000; font-weight: bold;">return</span> <span style="color: #000000; font-weight: bold;">true</span>;</div>
</li>
<li style="font-weight: bold;color:#26536A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; <span style="color: #66cc66;">&#125;</span></div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#3A6A8B;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp;</div>
</li>
<li style="font-weight: bold;color:#26536A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; @Override</div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#3A6A8B;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; <span style="color: #000000; font-weight: bold;">public</span> <span style="color: #993333;">boolean</span> isCredentialsNonExpired<span style="color: #66cc66;">&#40;</span><span style="color: #66cc66;">&#41;</span> <span style="color: #66cc66;">&#123;</span></div>
</li>
<li style="font-weight: bold;color:#26536A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #808080; font-style: italic;">// TODO Auto-generated method stub</span></div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#3A6A8B;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #000000; font-weight: bold;">return</span> <span style="color: #000000; font-weight: bold;">true</span>;</div>
</li>
<li style="font-weight: bold;color:#26536A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; <span style="color: #66cc66;">&#125;</span></div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#3A6A8B;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp;</div>
</li>
<li style="font-weight: bold;color:#26536A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; @Override</div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#3A6A8B;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; <span style="color: #000000; font-weight: bold;">public</span> <span style="color: #993333;">boolean</span> isEnabled<span style="color: #66cc66;">&#40;</span><span style="color: #66cc66;">&#41;</span> <span style="color: #66cc66;">&#123;</span></div>
</li>
<li style="font-weight: bold;color:#26536A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #808080; font-style: italic;">// TODO Auto-generated method stub</span></div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#3A6A8B;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #000000; font-weight: bold;">return</span> <span style="color: #000000; font-weight: bold;">true</span>;</div>
</li>
<li style="font-weight: bold;color:#26536A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; <span style="color: #66cc66;">&#125;</span></div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#3A6A8B;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp;</div>
</li>
<li style="font-weight: bold;color:#26536A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; <span style="color: #000000; font-weight: bold;">public</span> AuthenticatedUser<span style="color: #66cc66;">&#40;</span><span style="color: #66cc66;">&#41;</span> <span style="color: #66cc66;">&#123;</span></div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#3A6A8B;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; &nbsp; &nbsp; super<span style="color: #66cc66;">&#40;</span><span style="color: #66cc66;">&#41;</span>;</div>
</li>
<li style="font-weight: bold;color:#26536A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #808080; font-style: italic;">// TODO Auto-generated constructor stub</span></div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#3A6A8B;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; <span style="color: #66cc66;">&#125;</span></div>
</li>
<li style="font-weight: bold;color:#26536A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp;</div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#3A6A8B;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; <span style="color: #000000; font-weight: bold;">public</span> AuthenticatedUser<span style="color: #66cc66;">&#40;</span><a href="http://www.google.com/search?q=allinurl%3AString+java.sun.com&amp;bntl=1"><span style="color: #aaaadd; font-weight: bold;">String</span></a> username, <a href="http://www.google.com/search?q=allinurl%3AString+java.sun.com&amp;bntl=1"><span style="color: #aaaadd; font-weight: bold;">String</span></a> fullname, <a href="http://www.google.com/search?q=allinurl%3AString+java.sun.com&amp;bntl=1"><span style="color: #aaaadd; font-weight: bold;">String</span></a> password,</div>
</li>
<li style="font-weight: bold;color:#26536A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; Collection&lt;GrantedAuthority&gt; authorities<span style="color: #66cc66;">&#41;</span> <span style="color: #66cc66;">&#123;</span></div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#3A6A8B;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; &nbsp; &nbsp; super<span style="color: #66cc66;">&#40;</span><span style="color: #66cc66;">&#41;</span>;</div>
</li>
<li style="font-weight: bold;color:#26536A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #000000; font-weight: bold;">this</span>.<span style="color: #006600;">username</span> = username;</div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#3A6A8B;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #000000; font-weight: bold;">this</span>.<span style="color: #006600;">fullname</span> = fullname;</div>
</li>
<li style="font-weight: bold;color:#26536A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #000000; font-weight: bold;">this</span>.<span style="color: #006600;">password</span> = password;</div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#3A6A8B;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #000000; font-weight: bold;">this</span>.<span style="color: #006600;">authorities</span> = authorities;</div>
</li>
<li style="font-weight: bold;color:#26536A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; <span style="color: #66cc66;">&#125;</span></div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#3A6A8B;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;"><span style="color: #66cc66;">&#125;</span> </div>
</li>
</ol>
</div>
</div>
</div>
<p></p>
<p>Luego necesitamos crear nuestro propio interceptor de mensaje implementando MessageInterceptor. Esta clase es la encargada de extraer del resultado del proceso de autenticación la información que llegará a la aplicación Flex una vez concluido éste exitosamente.</p>
<p>MyLoginMessageInterceptor.java</p>
<div class="igBar"><span id="ljava-32"><a href="#" onclick="javascript:showPlainTxt('java-32'); return false;">PLAIN TEXT</a></span></div>
<div class="syntax_hilite"><span class="langName">JAVA:</span>
<div id="java-32">
<div class="java">
<ol>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#3A6A8B;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">package com.<span style="color: #006600;">nonocarballo</span>.<span style="color: #006600;">flexspringsecurity</span>.<span style="color: #006600;">service</span>;</div>
</li>
<li style="font-weight: bold;color:#26536A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp;</div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#3A6A8B;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;"><span style="color: #a1a100;">import org.apache.commons.logging.Log;</span></div>
</li>
<li style="font-weight: bold;color:#26536A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;"><span style="color: #a1a100;">import org.apache.commons.logging.LogFactory;</span></div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#3A6A8B;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;"><span style="color: #a1a100;">import org.springframework.flex.core.MessageInterceptor;</span></div>
</li>
<li style="font-weight: bold;color:#26536A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;"><span style="color: #a1a100;">import org.springframework.flex.core.MessageProcessingContext;</span></div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#3A6A8B;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;"><span style="color: #a1a100;">import org.springframework.stereotype.Service;</span></div>
</li>
<li style="font-weight: bold;color:#26536A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp;</div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#3A6A8B;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;"><span style="color: #a1a100;">import flex.messaging.messages.CommandMessage;</span></div>
</li>
<li style="font-weight: bold;color:#26536A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;"><span style="color: #a1a100;">import flex.messaging.messages.Message;</span></div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#3A6A8B;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp;</div>
</li>
<li style="font-weight: bold;color:#26536A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">@Service</div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#3A6A8B;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;"><span style="color: #000000; font-weight: bold;">public</span> <span style="color: #000000; font-weight: bold;">class</span> MyLoginMessageInterceptor <span style="color: #000000; font-weight: bold;">implements</span> MessageInterceptor <span style="color: #66cc66;">&#123;</span></div>
</li>
<li style="font-weight: bold;color:#26536A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp;</div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#3A6A8B;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; <span style="color: #000000; font-weight: bold;">private</span> <span style="color: #000000; font-weight: bold;">final</span> Log logger = LogFactory.<span style="color: #006600;">getLog</span><span style="color: #66cc66;">&#40;</span>getClass<span style="color: #66cc66;">&#40;</span><span style="color: #66cc66;">&#41;</span><span style="color: #66cc66;">&#41;</span>;</div>
</li>
<li style="font-weight: bold;color:#26536A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp;&nbsp; </div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#3A6A8B;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; @Override</div>
</li>
<li style="font-weight: bold;color:#26536A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;"><span style="color: #000000; font-weight: bold;">public</span> Message postProcess<span style="color: #66cc66;">&#40;</span>MessageProcessingContext context, Message inputMessage,</div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#3A6A8B;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; Message outputMessage<span style="color: #66cc66;">&#41;</span> <span style="color: #66cc66;">&#123;</span></div>
</li>
<li style="font-weight: bold;color:#26536A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #808080; font-style: italic;">// TODO Auto-generated method stub</span></div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#3A6A8B;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #b1b100;">if</span> <span style="color: #66cc66;">&#40;</span>inputMessage <span style="color: #000000; font-weight: bold;">instanceof</span> CommandMessage &amp;&amp; </div>
</li>
<li style="font-weight: bold;color:#26536A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;"><span style="color: #66cc66;">&#40;</span><span style="color: #66cc66;">&#40;</span>CommandMessage<span style="color: #66cc66;">&#41;</span> inputMessage<span style="color: #66cc66;">&#41;</span>.<span style="color: #006600;">getOperation</span><span style="color: #66cc66;">&#40;</span><span style="color: #66cc66;">&#41;</span> == </div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#3A6A8B;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">CommandMessage.<span style="color: #006600;">LOGIN_OPERATION</span><span style="color: #66cc66;">&#41;</span> <span style="color: #66cc66;">&#123;</span></div>
</li>
<li style="font-weight: bold;color:#26536A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #b1b100;">if</span> <span style="color: #66cc66;">&#40;</span>outputMessage.<span style="color: #006600;">getBody</span><span style="color: #66cc66;">&#40;</span><span style="color: #66cc66;">&#41;</span>!= <span style="color: #000000; font-weight: bold;">null</span><span style="color: #66cc66;">&#41;</span> <span style="color: #66cc66;">&#123;</span></div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#3A6A8B;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; outputMessage.<span style="color: #006600;">setBody</span><span style="color: #66cc66;">&#40;</span></div>
</li>
<li style="font-weight: bold;color:#26536A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">MyAuthenticationResultUtils.<span style="color: #006600;">getAuthenticationResult</span><span style="color: #66cc66;">&#40;</span><span style="color: #66cc66;">&#41;</span><span style="color: #66cc66;">&#41;</span>;</div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#3A6A8B;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;"><span style="color: #66cc66;">&#125;</span></div>
</li>
<li style="font-weight: bold;color:#26536A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;"><span style="color: #66cc66;">&#125;</span></div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#3A6A8B;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;"><span style="color: #000000; font-weight: bold;">return</span> outputMessage; </div>
</li>
<li style="font-weight: bold;color:#26536A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; <span style="color: #66cc66;">&#125;</span></div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#3A6A8B;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp;</div>
</li>
<li style="font-weight: bold;color:#26536A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; @Override</div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#3A6A8B;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; <span style="color: #000000; font-weight: bold;">public</span> Message preProcess<span style="color: #66cc66;">&#40;</span>MessageProcessingContext context, Message inputMessage<span style="color: #66cc66;">&#41;</span> <span style="color: #66cc66;">&#123;</span></div>
</li>
<li style="font-weight: bold;color:#26536A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #808080; font-style: italic;">// TODO Auto-generated method stub</span></div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#3A6A8B;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #000000; font-weight: bold;">return</span> inputMessage;</div>
</li>
<li style="font-weight: bold;color:#26536A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; <span style="color: #66cc66;">&#125;</span></div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#3A6A8B;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp;</div>
</li>
<li style="font-weight: bold;color:#26536A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;"><span style="color: #66cc66;">&#125;</span> </div>
</li>
</ol>
</div>
</div>
</div>
<p></p>
<p>Como vemos, esta clase hace uso de MyAuthenticationResultUtils, la cual crearemos también, y donde ocurre la creación del objeto que llegará a la aplicación Flex en la propiedad result de la clase ResultEvent.</p>
<div class="igBar"><span id="ljava-33"><a href="#" onclick="javascript:showPlainTxt('java-33'); return false;">PLAIN TEXT</a></span></div>
<div class="syntax_hilite"><span class="langName">JAVA:</span>
<div id="java-33">
<div class="java">
<ol>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#3A6A8B;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">package com.<span style="color: #006600;">nonocarballo</span>.<span style="color: #006600;">flexspringsecurity</span>.<span style="color: #006600;">service</span>;</div>
</li>
<li style="font-weight: bold;color:#26536A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp;</div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#3A6A8B;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;"><span style="color: #a1a100;">import java.util.HashMap;</span></div>
</li>
<li style="font-weight: bold;color:#26536A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;"><span style="color: #a1a100;">import java.util.Map;</span></div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#3A6A8B;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp;</div>
</li>
<li style="font-weight: bold;color:#26536A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;"><span style="color: #a1a100;">import org.springframework.security.core.Authentication;</span></div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#3A6A8B;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;"><span style="color: #a1a100;">import org.springframework.security.core.GrantedAuthority;</span></div>
</li>
<li style="font-weight: bold;color:#26536A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;"><span style="color: #a1a100;">import org.springframework.security.core.context.SecurityContextHolder;</span></div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#3A6A8B;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp;</div>
</li>
<li style="font-weight: bold;color:#26536A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;"><span style="color: #a1a100;">import com.nonocarballo.flexspringsecurity.valueobject.AuthenticatedUser;</span></div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#3A6A8B;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp;</div>
</li>
<li style="font-weight: bold;color:#26536A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;"><span style="color: #000000; font-weight: bold;">public</span> <span style="color: #000000; font-weight: bold;">abstract</span> <span style="color: #000000; font-weight: bold;">class</span> MyAuthenticationResultUtils <span style="color: #66cc66;">&#123;</span></div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#3A6A8B;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp;</div>
</li>
<li style="font-weight: bold;color:#26536A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; <span style="color: #000000; font-weight: bold;">public</span> <span style="color: #993333;">static</span> Map&lt;String, Object&gt; getAuthenticationResult<span style="color: #66cc66;">&#40;</span><span style="color: #66cc66;">&#41;</span> <span style="color: #66cc66;">&#123;</span></div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#3A6A8B;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; &nbsp; &nbsp; Authentication authentication = SecurityContextHolder.<span style="color: #006600;">getContext</span><span style="color: #66cc66;">&#40;</span><span style="color: #66cc66;">&#41;</span>.<span style="color: #006600;">getAuthentication</span><span style="color: #66cc66;">&#40;</span><span style="color: #66cc66;">&#41;</span>;</div>
</li>
<li style="font-weight: bold;color:#26536A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #b1b100;">if</span> <span style="color: #66cc66;">&#40;</span>authentication == <span style="color: #000000; font-weight: bold;">null</span><span style="color: #66cc66;">&#41;</span> <span style="color: #66cc66;">&#123;</span></div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#3A6A8B;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #000000; font-weight: bold;">return</span> <span style="color: #000000; font-weight: bold;">null</span>;</div>
</li>
<li style="font-weight: bold;color:#26536A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #66cc66;">&#125;</span></div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#3A6A8B;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; &nbsp; &nbsp; Map&lt;String, Object&gt; authenticationResult = <span style="color: #000000; font-weight: bold;">new</span> HashMap&lt;String, Object&gt;<span style="color: #66cc66;">&#40;</span><span style="color: #66cc66;">&#41;</span>;</div>
</li>
<li style="font-weight: bold;color:#26536A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; &nbsp; &nbsp; authenticationResult.<span style="color: #006600;">put</span><span style="color: #66cc66;">&#40;</span><span style="color: #ff0000;">"name"</span>, authentication.<span style="color: #006600;">getName</span><span style="color: #66cc66;">&#40;</span><span style="color: #66cc66;">&#41;</span><span style="color: #66cc66;">&#41;</span>;</div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#3A6A8B;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; &nbsp; &nbsp; <a href="http://www.google.com/search?q=allinurl%3AString+java.sun.com&amp;bntl=1"><span style="color: #aaaadd; font-weight: bold;">String</span></a><span style="color: #66cc66;">&#91;</span><span style="color: #66cc66;">&#93;</span> authorities = <span style="color: #000000; font-weight: bold;">new</span> <a href="http://www.google.com/search?q=allinurl%3AString+java.sun.com&amp;bntl=1"><span style="color: #aaaadd; font-weight: bold;">String</span></a><span style="color: #66cc66;">&#91;</span>authentication.<span style="color: #006600;">getAuthorities</span><span style="color: #66cc66;">&#40;</span><span style="color: #66cc66;">&#41;</span>.<span style="color: #006600;">size</span><span style="color: #66cc66;">&#40;</span><span style="color: #66cc66;">&#41;</span><span style="color: #66cc66;">&#93;</span>;</div>
</li>
<li style="font-weight: bold;color:#26536A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #993333;">int</span> i=<span style="color: #cc66cc;color:#800000;">0</span>;</div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#3A6A8B;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #b1b100;">for</span> <span style="color: #66cc66;">&#40;</span>GrantedAuthority granted : authentication.<span style="color: #006600;">getAuthorities</span><span style="color: #66cc66;">&#40;</span><span style="color: #66cc66;">&#41;</span><span style="color: #66cc66;">&#41;</span> <span style="color: #66cc66;">&#123;</span></div>
</li>
<li style="font-weight: bold;color:#26536A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; authorities<span style="color: #66cc66;">&#91;</span>i++<span style="color: #66cc66;">&#93;</span> = granted.<span style="color: #006600;">getAuthority</span><span style="color: #66cc66;">&#40;</span><span style="color: #66cc66;">&#41;</span>;</div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#3A6A8B;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #66cc66;">&#125;</span></div>
</li>
<li style="font-weight: bold;color:#26536A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; &nbsp; &nbsp; authenticationResult.<span style="color: #006600;">put</span><span style="color: #66cc66;">&#40;</span><span style="color: #ff0000;">"authorities"</span>, authorities<span style="color: #66cc66;">&#41;</span>;</div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#3A6A8B;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; &nbsp; &nbsp; authenticationResult.<span style="color: #006600;">put</span><span style="color: #66cc66;">&#40;</span><span style="color: #ff0000;">"fullname"</span>, <span style="color: #66cc66;">&#40;</span><span style="color: #66cc66;">&#40;</span>AuthenticatedUser<span style="color: #66cc66;">&#41;</span>authentication.<span style="color: #006600;">getPrincipal</span><span style="color: #66cc66;">&#40;</span><span style="color: #66cc66;">&#41;</span><span style="color: #66cc66;">&#41;</span>.<span style="color: #006600;">getFullname</span><span style="color: #66cc66;">&#40;</span><span style="color: #66cc66;">&#41;</span><span style="color: #66cc66;">&#41;</span>;</div>
</li>
<li style="font-weight: bold;color:#26536A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #000000; font-weight: bold;">return</span> authenticationResult;</div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#3A6A8B;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; <span style="color: #66cc66;">&#125;</span> </div>
</li>
<li style="font-weight: bold;color:#26536A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;"><span style="color: #66cc66;">&#125;</span> </div>
</li>
</ol>
</div>
</div>
</div>
<p></p>
<p>Finalmente debemos registrar nuestro interceptor de mensaje personalizado:</p>
<div class="igBar"><span id="lxml-34"><a href="#" onclick="javascript:showPlainTxt('xml-34'); return false;">PLAIN TEXT</a></span></div>
<div class="syntax_hilite"><span class="langName">XML:</span>
<div id="xml-34">
<div class="xml">
<ol>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#3A6A8B;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;"><span style="color: #009900;"><span style="font-weight: bold; color: black;">&lt;flex</span>:message-broker<span style="font-weight: bold; color: black;">&gt;</span></span></div>
</li>
<li style="font-weight: bold;color:#26536A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #009900;"><span style="font-weight: bold; color: black;">&lt;flex</span>:message-interceptor <span style="color: #000066;">ref</span>=<span style="color: #ff0000;">"myLoginMessageInterceptor"</span><span style="font-weight: bold; color: black;">/&gt;</span></span></div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#3A6A8B;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #009900;"><span style="font-weight: bold; color: black;">&lt;flex</span>:secured <span style="font-weight: bold; color: black;">/&gt;</span></span></div>
</li>
<li style="font-weight: bold;color:#26536A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;"><span style="color: #009900;"><span style="font-weight: bold; color: black;">&lt;/flex</span>:message-broker<span style="font-weight: bold; color: black;">&gt;</span></span> </div>
</li>
</ol>
</div>
</div>
</div>
<p></p>
<p>Cuando nos autenticamos nuevamente obtenemos:</p>
<p><a href="http://www.madeinflex.com/wp-content/uploads/2010/08/login-ok.png"><img src="http://www.madeinflex.com/wp-content/uploads/2010/08/login-ok.png" alt="login-ok" title="login-ok" width="262" height="169" class="aligncenter size-full wp-image-1690" /></a></p>
<p>El código fuente de los proyectos se puede descargar <a href='http://www.madeinflex.com/wp-content/uploads/2010/08/FlexSpringSecurityDemo.zip'>aquí</a>.</p>
<h4 id="toc-conclusiones">Conclusiones</h4>
<p>Spring Security provee un mecanismo flexible de autenticación (y control de acceso) para aplicaciones basadas en Spring. En nuestra aplicación de ejemplo utilizamos JPA e Hibernate para acceder a la información de los usuarios.</p>
<p>Utilizando el paquete de integración de Spring con BlazeDS y Spring Security podemos implementar mecanismos de autenticación en nuestras aplicaciones Flex/BlazeDS.</p>]]></content:encoded>
			<wfw:commentRss>http://www.madeinflex.com/2010/08/13/autenticacion-en-aplicaciones-flex-con-spring-security-3/feed/</wfw:commentRss>
		<slash:comments>8</slash:comments>
		</item>
		<item>
		<title>Utilizando Robotlegs para el desarrollo de aplicaciones Flex</title>
		<link>http://www.madeinflex.com/2010/07/13/utilizando-robotlegs-para-el-desarrollo-de-aplicaciones-flex/</link>
		<comments>http://www.madeinflex.com/2010/07/13/utilizando-robotlegs-para-el-desarrollo-de-aplicaciones-flex/#comments</comments>
		<pubDate>Tue, 13 Jul 2010 07:33:04 +0000</pubDate>
		<dc:creator>Nono F. Carballo Escalona</dc:creator>
				<category><![CDATA[Artículos]]></category>
		<category><![CDATA[Flex 4]]></category>
		<category><![CDATA[Tutoriales]]></category>

		<guid isPermaLink="false">http://www.madeinflex.com/?p=1506</guid>
		<description><![CDATA[<!-- matched  --><!-- final 0 -->Principio de funcionamiento
El funcionamiento a través de un ejemplo
Conclusiones


Robotlegs es una microarquitectura escrita completamente en AS3 para el desarrollo de aplicaciones Flex, Flash y Air, cuyo principal objetivo es interconectar las diferentes partes de la aplicación y proveer un mecanismo para que se comuniquen, en este caso utiliza el sistema de mensajería nativo de Flex.
El [...]]]></description>
			<content:encoded><![CDATA[<!-- matched  --><!-- final 0 --><p><span id="more-1506"></span><br />
<!--noteaser--></p>
<div class="toc">
<ol>
<li><a href="http://www.madeinflex.com/2010/07/13/utilizando-robotlegs-para-el-desarrollo-de-aplicaciones-flex/#toc-principio-de-funcionamiento">Principio de funcionamiento</a></li>
<li><a href="http://www.madeinflex.com/2010/07/13/utilizando-robotlegs-para-el-desarrollo-de-aplicaciones-flex/#toc-el-funcionamiento-a-traves-de-un-ejemplo">El funcionamiento a través de un ejemplo</a></li>
<li><a href="http://www.madeinflex.com/2010/07/13/utilizando-robotlegs-para-el-desarrollo-de-aplicaciones-flex/#toc-conclusiones">Conclusiones</a></li>
</ol>
</div>
<p><a href="http://www.robotlegs.org">Robotlegs</a> es una microarquitectura escrita completamente en AS3 para el desarrollo de aplicaciones Flex, Flash y Air, cuyo principal objetivo es interconectar las diferentes partes de la aplicación y proveer un mecanismo para que se comuniquen, en este caso utiliza el sistema de mensajería nativo de Flex.</p>
<p>El framework viene con una implementación de referencia basada en el patrón MVC+S que sirve de guía para estructurar la aplicación, que incluye las clases Mediator, Command y Actor (denominadas los actores del framework), y aunque no es obligatorio su uso constituye un punto de comienzo. La inyección de dependencias la realiza a través de la biblioteca SwiftSuspenders, aunque deja abierta la posibilidad de usar otras, los puntos de inyección de dependencias se indican declarativamente a través de metadata.</p>
<h4 id="toc-principio-de-funcionamiento">Principio de funcionamiento</h4>
<p>La clase Context es el corazón del framework, sirve como un bus centralizado de eventos y permite que las implementaciones de las diferentes partes de la arquitectura se comuniquen entre sí. Es el mecanismo de arranque que inicializa la inyección de dependencias y otras utilidades del framework. El contexto define ámbito, los actores del framework viven dentro de un contexto y se comunican con otros que viven dentro del mismo ámbito de ese contexto. En una aplicación pueden existir varios contextos, y éstos pueden comunicarse entre sí, lo cual  es muy útil para el desarrollo de aplicaciones modulares que requieren comunicación entre módulos.</p>
<p>La capa controladora se representa por la clase Command. Los comandos son objetos de corta vida, sin estado, que representan acciones individuales a ejecutar por la aplicación, comúnmente como respuesta a interacciones con el usuario pero su uso no está limitado a esto. Estos objetos pueden enviar eventos que pueden ser recibidos por mediadores para ejecutar acciones sobre las vistas, o que pueden desencadenar la ejecución de otros comandos.</p>
<p>La capa de la vista es representada por la clase Mediator. Las clases que heredan de Mediator se utilizan para controlar la interacción de los actores del framework con los componentes visuales. Los mediadores escuchan los eventos despachados por los actores del framework y en consecuencia modifican el estado del componente visual que representan, registran escuchadores de los eventos generados por el componente visual que representan y despachan además eventos como respuesta éstos. Esto permite poner la lógica del componente visual en el mediador y desacoplarlo al máximo de la aplicación, permitiendo su reutilización y modificación con el menor costo.</p>
<p>Para implementar la capa del modelo y de los servicios el framework ofrece la clase Actor. Cualquier clase que herede de Actor tiene la funcionalidad de comunicarse con el resto de los actores del framework.</p>
<h4 id="toc-el-funcionamiento-a-traves-de-un-ejemplo">El funcionamiento a través de un ejemplo</h4>
<p>Para ejemplificar el funcionamiento de Robotlegs desarrollaremos un pequeño ejemplo en el que tendremos una vista compuesta por un botón y una tabla, al oprimir el botón recuperaremos un conjunto de datos en formato XML a través de una solicitud HTTP y los mostraremos en la tabla. Utilizaremos Flash Builder 4 y <a href="http://www.robotlegs.org/">Robotlegs 1.1.1</a>. Aunque el ejemplo es muy simple nos servirá para explorar cómo interactúan las diferentes partes de una aplicación que utilice Robotlegs.</p>
<p>Comenzaremos descargando el archivo robotlegs-framework-v1.1.1.zip de http://www.robotlegs.org y  creando un proyecto Flex con las siguientes características:</p>
<p><a href="http://www.madeinflex.com/wp-content/uploads/2010/07/1.jpg"><img src="http://www.madeinflex.com/wp-content/uploads/2010/07/1.jpg" alt="1" title="1" width="427" height="515" class="aligncenter size-full wp-image-1508" /></a></p>
<p>Una vez creado el proyecto copiamos en la carpeta libs de proyecto el archivo “robotlegs-framework-v1.1.1.swc”, que se encuentra en la carpeta bin del archivo previamente descargado; y creamos la siguiente estructura en el proyecto:</p>
<p><a href="http://www.madeinflex.com/wp-content/uploads/2010/07/2.jpg"><img src="http://www.madeinflex.com/wp-content/uploads/2010/07/2.jpg" alt="2" title="2" width="187" height="238" class="aligncenter size-full wp-image-1509" /></a></p>
<p>A continuación procederemos a crear el único componente visual de la aplicación, al cual llamaremos CountryListView y se creará en la carpeta views del proyecto:</p>
<p><a href="http://www.madeinflex.com/wp-content/uploads/2010/07/3.jpg"><img src="http://www.madeinflex.com/wp-content/uploads/2010/07/3.jpg" alt="3" title="3" width="392" height="291" class="aligncenter size-full wp-image-1510" /></a></p>
<p>El código queda así:</p>
<div class="igBar"><span id="lmxml-41"><a href="#" onclick="javascript:showPlainTxt('mxml-41'); return false;">PLAIN TEXT</a></span></div>
<div class="syntax_hilite"><span class="langName">MXML:</span>
<div id="mxml-41">
<div class="mxml">
<ol>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#3A6A8B;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;"><span style="color: #000000;">&lt;?xml version=<span style="color: #ff0000;">"1.0"</span> encoding=<span style="color: #ff0000;">"utf-8"</span>?<span style="color: #7400FF;">&gt;</span></span></div>
</li>
<li style="font-weight: bold;color:#26536A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;"><span style="color: #000000;"><span style="color: #7400FF;">&lt;s:VGroup</span> xmlns:fx=<span style="color: #ff0000;">"http://ns.adobe.com/mxml/2009"</span> </div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#3A6A8B;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; &nbsp; &nbsp;&nbsp; &nbsp;xmlns:s=<span style="color: #ff0000;">"library://ns.adobe.com/flex/spark"</span> </div>
</li>
<li style="font-weight: bold;color:#26536A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; &nbsp; &nbsp;&nbsp; &nbsp;xmlns:mx=<span style="color: #ff0000;">"library://ns.adobe.com/flex/mx"</span> </div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#3A6A8B;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; &nbsp; &nbsp;&nbsp; &nbsp;width=<span style="color: #ff0000;">"400"</span> height=<span style="color: #ff0000;">"300"</span></div>
</li>
<li style="font-weight: bold;color:#26536A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; &nbsp; &nbsp;&nbsp; &nbsp;paddingLeft=<span style="color: #ff0000;">"10"</span> paddingTop=<span style="color: #ff0000;">"10"</span> paddingRight=<span style="color: #ff0000;">"10"</span> paddingBottom=<span style="color: #ff0000;">"10"</span><span style="color: #7400FF;">&gt;</span></span></div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#3A6A8B;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; </div>
</li>
<li style="font-weight: bold;color:#26536A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; <span style="color: #000000;"><span style="color: #7400FF;">&lt;fx:Declarations</span><span style="color: #7400FF;">&gt;</span></span></div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#3A6A8B;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #000000;"><span style="color: #808080; font-style: italic;">&lt;!-- Place non-visual elements (e.g., services, value objects) here --&gt;</span></span></div>
</li>
<li style="font-weight: bold;color:#26536A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; <span style="color: #000000;"><span style="color: #7400FF;">&lt;/fx:Declarations</span><span style="color: #7400FF;">&gt;</span></span></div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#3A6A8B;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; </div>
</li>
<li style="font-weight: bold;color:#26536A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; <span style="color: #000000;"><span style="color: #7400FF;">&lt;s:Button</span> label=<span style="color: #ff0000;">"Cargar Datos"</span></div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#3A6A8B;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;&nbsp; &nbsp;click=<span style="color: #ff0000;">"dispatchEvent(new Event('LOAD_DATA'))"</span><span style="color: #7400FF;">/&gt;</span></span></div>
</li>
<li style="font-weight: bold;color:#26536A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; </div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#3A6A8B;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; <span style="color: #000000;"><span style="color: #7400FF;">&lt;mx:DataGrid</span> id=<span style="color: #ff0000;">"country_dg"</span> </div>
</li>
<li style="font-weight: bold;color:#26536A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;&nbsp; width=<span style="color: #ff0000;">"100%"</span> height=<span style="color: #ff0000;">"100%"</span><span style="color: #7400FF;">&gt;</span></span></div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#3A6A8B;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #000000;"><span style="color: #7400FF;">&lt;mx:columns</span><span style="color: #7400FF;">&gt;</span></span></div>
</li>
<li style="font-weight: bold;color:#26536A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #000000;"><span style="color: #7400FF;">&lt;mx:DataGridColumn</span> headerText=<span style="color: #ff0000;">"Nombre"</span> dataField=<span style="color: #ff0000;">"name"</span><span style="color: #7400FF;">/&gt;</span></span></div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#3A6A8B;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #000000;"><span style="color: #7400FF;">&lt;mx:DataGridColumn</span> headerText=<span style="color: #ff0000;">"Codigo"</span> dataField=<span style="color: #ff0000;">"code"</span><span style="color: #7400FF;">/&gt;</span></span></div>
</li>
<li style="font-weight: bold;color:#26536A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #000000;"><span style="color: #7400FF;">&lt;/mx:columns</span><span style="color: #7400FF;">&gt;</span></span></div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#3A6A8B;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; <span style="color: #000000;"><span style="color: #7400FF;">&lt;/mx:DataGrid</span><span style="color: #7400FF;">&gt;</span></span></div>
</li>
<li style="font-weight: bold;color:#26536A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;"><span style="color: #000000;"><span style="color: #7400FF;">&lt;/s:VGroup</span><span style="color: #7400FF;">&gt;</span></span> </div>
</li>
</ol>
</div>
</div>
</div>
<p></p>
<p>Cuando se oprime el botón se despachará un evento que será atrapado por el mediador de este componente, el cual como respuesta despachará otro evento que desencadenará la ejecución de un comando.</p>
<p>Como vemos, este componente visual está totalmente desacoplado de la aplicación (no tiene enlaces –bindings- al modelo, etc.) y puede ser reutilizado y modificado sin incurrir en cambios en el código. Por supuesto que en un escenario real el componente seguramente será mucho más complejo, pero la idea es la misma.</p>
<p>El mediador será una clase que herede de la clase Mediator del framework y cuya responsabilidad será comunicarse con el resto de los actores de la aplicación e interactuar con el componente visual para actualizar su estado.</p>
<div class="igBar"><span id="lactionscript3-42"><a href="#" onclick="javascript:showPlainTxt('actionscript3-42'); return false;">PLAIN TEXT</a></span></div>
<div class="syntax_hilite"><span class="langName">Actionscript 3:</span>
<div id="actionscript3-42">
<div class="actionscript3">
<ol>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#3A6A8B;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;"><span style="color: #9900cc; font-weight: bold;">package</span> views</div>
</li>
<li style="font-weight: bold;color:#26536A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;"><span style="color: #000000;">&#123;</span></div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#3A6A8B;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; <span style="color: #0033ff; font-weight: bold;">import</span> events.CountryListEvents;</div>
</li>
<li style="font-weight: bold;color:#26536A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; </div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#3A6A8B;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; <span style="color: #0033ff; font-weight: bold;">import</span> <span style="color: #004993;">flash.events</span>.<span style="color: #004993;">Event</span>;</div>
</li>
<li style="font-weight: bold;color:#26536A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; </div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#3A6A8B;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; <span style="color: #0033ff; font-weight: bold;">import</span> model.CountryListModel;</div>
</li>
<li style="font-weight: bold;color:#26536A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; </div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#3A6A8B;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; <span style="color: #0033ff; font-weight: bold;">import</span> org.robotlegs.mvcs.Mediator;</div>
</li>
<li style="font-weight: bold;color:#26536A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; </div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#3A6A8B;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; <span style="color: #0033ff; font-weight: bold;">public</span> <span style="color: #9900cc; font-weight: bold;">class</span> CountryListMediator <span style="color: #0033ff; font-weight: bold;">extends</span> Mediator</div>
</li>
<li style="font-weight: bold;color:#26536A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; <span style="color: #000000;">&#123;</span></div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#3A6A8B;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #000000;">&#91;</span>Inject<span style="color: #000000;">&#93;</span></div>
</li>
<li style="font-weight: bold;color:#26536A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #0033ff; font-weight: bold;">public</span> <span style="color: #6699cc; font-weight: bold;">var</span> view:CountryListView;</div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#3A6A8B;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; &nbsp; &nbsp; </div>
</li>
<li style="font-weight: bold;color:#26536A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #000000;">&#91;</span>Inject<span style="color: #000000;">&#93;</span></div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#3A6A8B;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #0033ff; font-weight: bold;">public</span> <span style="color: #6699cc; font-weight: bold;">var</span> applicationModel:CountryListModel;</div>
</li>
<li style="font-weight: bold;color:#26536A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; &nbsp; &nbsp; </div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#3A6A8B;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #0033ff; font-weight: bold;">public</span> <span style="color: #339966; font-weight: bold;">function</span> CountryListMediator<span style="color: #000000;">&#40;</span><span style="color: #000000;">&#41;</span></div>
</li>
<li style="font-weight: bold;color:#26536A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #000000;">&#123;</span></div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#3A6A8B;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #0033ff; font-weight: bold;">super</span><span style="color: #000000;">&#40;</span><span style="color: #000000;">&#41;</span>;</div>
</li>
<li style="font-weight: bold;color:#26536A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #000000;">&#125;</span></div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#3A6A8B;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; &nbsp; &nbsp; </div>
</li>
<li style="font-weight: bold;color:#26536A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #0033ff; font-weight: bold;">override</span> <span style="color: #0033ff; font-weight: bold;">public</span> <span style="color: #339966; font-weight: bold;">function</span> onRegister<span style="color: #000000;">&#40;</span><span style="color: #000000;">&#41;</span>:<span style="color: #0033ff; font-weight: bold;">void</span><span style="color: #000000;">&#123;</span></div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#3A6A8B;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; addViewListener<span style="color: #000000;">&#40;</span><span style="color: #990000;">"LOAD_DATA"</span>, sendRequest<span style="color: #000000;">&#41;</span>;</div>
</li>
<li style="font-weight: bold;color:#26536A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; addContextListener<span style="color: #000000;">&#40;</span>CountryListEvents.COUNTRY_DATA_LOADED, dataLoadedHandler<span style="color: #000000;">&#41;</span>;</div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#3A6A8B;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #000000;">&#125;</span></div>
</li>
<li style="font-weight: bold;color:#26536A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; &nbsp; &nbsp; </div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#3A6A8B;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #0033ff; font-weight: bold;">private</span> <span style="color: #339966; font-weight: bold;">function</span> sendRequest<span style="color: #000000;">&#40;</span>event:<span style="color: #004993;">Event</span><span style="color: #000000;">&#41;</span>:<span style="color: #0033ff; font-weight: bold;">void</span><span style="color: #000000;">&#123;</span></div>
</li>
<li style="font-weight: bold;color:#26536A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; dispatch<span style="color: #000000;">&#40;</span><span style="color: #0033ff; font-weight: bold;">new</span> <span style="color: #004993;">Event</span><span style="color: #000000;">&#40;</span>CountryListEvents.LOAD_COUNTRY_DATA<span style="color: #000000;">&#41;</span><span style="color: #000000;">&#41;</span>;</div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#3A6A8B;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #000000;">&#125;</span></div>
</li>
<li style="font-weight: bold;color:#26536A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; &nbsp; &nbsp; </div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#3A6A8B;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #0033ff; font-weight: bold;">private</span> <span style="color: #339966; font-weight: bold;">function</span> dataLoadedHandler<span style="color: #000000;">&#40;</span>event:<span style="color: #004993;">Event</span><span style="color: #000000;">&#41;</span>:<span style="color: #0033ff; font-weight: bold;">void</span><span style="color: #000000;">&#123;</span></div>
</li>
<li style="font-weight: bold;color:#26536A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; view.country_dg.dataProvider = applicationModel.countryList;</div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#3A6A8B;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #000000;">&#125;</span></div>
</li>
<li style="font-weight: bold;color:#26536A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; <span style="color: #000000;">&#125;</span></div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#3A6A8B;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;"><span style="color: #000000;">&#125;</span> </div>
</li>
</ol>
</div>
</div>
</div>
<p></p>
<p>En el método “onRegister”, el mediador registra los escuchadores tanto para los eventos despachados por el componente visual como para los eventos despachados por el resto de los actores del framework. El metadata “[Inject]” indica que el framework suministrará a las variables “view” y “applicationModel” referencias válidas de objetos de tipo “CountryListView” y “CountryListModel” respectivamente.</p>
<p>Cuando el mediador atrapa el evento despachado por el componente visual (LOAD_DATA), despacha el evento LOAD_COUNTRY_DATA, lo cual provoca que se ejecute el método “execute” del comando asociado a ese evento.<br />
El comando, representado por la clase “LoadCountryData”, hereda de la clase Command del framework y es responsable de obtener los datos del archivo XML. Para este ejemplo se creó un servicio HTTP (CountryDataService) utilizando la funcionalidad de Data Centric Development de Flash Builder. El framework inyecta una referencia válida del servicio y el modelo cuando se crea un objeto de la clase “LoadCountryData”.</p>
<div class="igBar"><span id="lactionscript3-43"><a href="#" onclick="javascript:showPlainTxt('actionscript3-43'); return false;">PLAIN TEXT</a></span></div>
<div class="syntax_hilite"><span class="langName">Actionscript 3:</span>
<div id="actionscript3-43">
<div class="actionscript3">
<ol>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#3A6A8B;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;"><span style="color: #9900cc; font-weight: bold;">package</span> commands</div>
</li>
<li style="font-weight: bold;color:#26536A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;"><span style="color: #000000;">&#123;</span></div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#3A6A8B;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; <span style="color: #0033ff; font-weight: bold;">import</span> model.CountryListModel;</div>
</li>
<li style="font-weight: bold;color:#26536A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; </div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#3A6A8B;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; <span style="color: #0033ff; font-weight: bold;">import</span> mx.collections.ArrayCollection;</div>
</li>
<li style="font-weight: bold;color:#26536A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; <span style="color: #0033ff; font-weight: bold;">import</span> mx.rpc.CallResponder;</div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#3A6A8B;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; <span style="color: #0033ff; font-weight: bold;">import</span> mx.rpc.events.FaultEvent;</div>
</li>
<li style="font-weight: bold;color:#26536A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; <span style="color: #0033ff; font-weight: bold;">import</span> mx.rpc.events.ResultEvent;</div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#3A6A8B;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; </div>
</li>
<li style="font-weight: bold;color:#26536A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; <span style="color: #0033ff; font-weight: bold;">import</span> org.robotlegs.mvcs.Command;</div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#3A6A8B;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; </div>
</li>
<li style="font-weight: bold;color:#26536A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; <span style="color: #0033ff; font-weight: bold;">import</span> services.countrydataservice.CountryDataService;</div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#3A6A8B;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; </div>
</li>
<li style="font-weight: bold;color:#26536A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; <span style="color: #0033ff; font-weight: bold;">import</span> valueObjects.Country_list;</div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#3A6A8B;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; </div>
</li>
<li style="font-weight: bold;color:#26536A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; <span style="color: #0033ff; font-weight: bold;">public</span> <span style="color: #9900cc; font-weight: bold;">class</span> LoadCountryData <span style="color: #0033ff; font-weight: bold;">extends</span> Command</div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#3A6A8B;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; <span style="color: #000000;">&#123;</span></div>
</li>
<li style="font-weight: bold;color:#26536A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #000000;">&#91;</span>Inject<span style="color: #000000;">&#93;</span></div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#3A6A8B;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #0033ff; font-weight: bold;">public</span> <span style="color: #6699cc; font-weight: bold;">var</span> applicationModel:CountryListModel;</div>
</li>
<li style="font-weight: bold;color:#26536A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; &nbsp; &nbsp; </div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#3A6A8B;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #000000;">&#91;</span>Inject<span style="color: #000000;">&#93;</span></div>
</li>
<li style="font-weight: bold;color:#26536A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #0033ff; font-weight: bold;">public</span> <span style="color: #6699cc; font-weight: bold;">var</span> service:CountryDataService;</div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#3A6A8B;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; &nbsp; &nbsp; </div>
</li>
<li style="font-weight: bold;color:#26536A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #0033ff; font-weight: bold;">public</span> <span style="color: #339966; font-weight: bold;">function</span> LoadCountryData<span style="color: #000000;">&#40;</span><span style="color: #000000;">&#41;</span></div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#3A6A8B;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #000000;">&#123;</span></div>
</li>
<li style="font-weight: bold;color:#26536A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #0033ff; font-weight: bold;">super</span><span style="color: #000000;">&#40;</span><span style="color: #000000;">&#41;</span>;</div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#3A6A8B;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #000000;">&#125;</span></div>
</li>
<li style="font-weight: bold;color:#26536A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; &nbsp; &nbsp; </div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#3A6A8B;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #0033ff; font-weight: bold;">private</span> <span style="color: #6699cc; font-weight: bold;">var</span> responder:CallResponder = <span style="color: #0033ff; font-weight: bold;">new</span> CallResponder<span style="color: #000000;">&#40;</span><span style="color: #000000;">&#41;</span>;</div>
</li>
<li style="font-weight: bold;color:#26536A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; &nbsp; &nbsp; </div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#3A6A8B;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #0033ff; font-weight: bold;">override</span> <span style="color: #0033ff; font-weight: bold;">public</span> <span style="color: #339966; font-weight: bold;">function</span> execute<span style="color: #000000;">&#40;</span><span style="color: #000000;">&#41;</span>:<span style="color: #0033ff; font-weight: bold;">void</span><span style="color: #000000;">&#123;</span></div>
</li>
<li style="font-weight: bold;color:#26536A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; &nbsp; &nbsp; </div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#3A6A8B;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; responder.<span style="color: #004993;">addEventListener</span><span style="color: #000000;">&#40;</span>ResultEvent.RESULT, resultHandler<span style="color: #000000;">&#41;</span>;</div>
</li>
<li style="font-weight: bold;color:#26536A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; responder.token = service.getCountryData<span style="color: #000000;">&#40;</span><span style="color: #000000;">&#41;</span>;</div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#3A6A8B;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #000000;">&#125;</span></div>
</li>
<li style="font-weight: bold;color:#26536A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; &nbsp; &nbsp; </div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#3A6A8B;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #0033ff; font-weight: bold;">private</span> <span style="color: #339966; font-weight: bold;">function</span> resultHandler<span style="color: #000000;">&#40;</span>event:ResultEvent<span style="color: #000000;">&#41;</span>:<span style="color: #0033ff; font-weight: bold;">void</span><span style="color: #000000;">&#123;</span></div>
</li>
<li style="font-weight: bold;color:#26536A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; applicationModel.countryList = <span style="color: #000000;">&#40;</span>responder.lastResult <span style="color: #0033ff; font-weight: bold;">as</span> Country_list<span style="color: #000000;">&#41;</span>.country;</div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#3A6A8B;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #000000;">&#125;</span></div>
</li>
<li style="font-weight: bold;color:#26536A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; &nbsp; &nbsp; </div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#3A6A8B;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; <span style="color: #000000;">&#125;</span></div>
</li>
<li style="font-weight: bold;color:#26536A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;"><span style="color: #000000;">&#125;</span> </div>
</li>
</ol>
</div>
</div>
</div>
<p></p>
<p>Cuando el servicio retorna (en el método “resultHandler”) se actualiza la lista de países en el modelo, lo cual provoca que se despache el evento COUNTRY_DATA_LOADED, el cual es atrapado por el mediador y este, en respuesta, actualiza el componente visual.</p>
<p>El modelo está representado en la clase “CountryListModel”, que almacena los datos de la aplicación, ésta hereda de la clase Actor del framework, la cual añade la funcionalidad básica para comunicarse con el resto de los actores.</p>
<div class="igBar"><span id="lactionscript3-44"><a href="#" onclick="javascript:showPlainTxt('actionscript3-44'); return false;">PLAIN TEXT</a></span></div>
<div class="syntax_hilite"><span class="langName">Actionscript 3:</span>
<div id="actionscript3-44">
<div class="actionscript3">
<ol>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#3A6A8B;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;"><span style="color: #9900cc; font-weight: bold;">package</span> model</div>
</li>
<li style="font-weight: bold;color:#26536A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;"><span style="color: #000000;">&#123;</span></div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#3A6A8B;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; <span style="color: #0033ff; font-weight: bold;">import</span> events.CountryListEvents;</div>
</li>
<li style="font-weight: bold;color:#26536A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; </div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#3A6A8B;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; <span style="color: #0033ff; font-weight: bold;">import</span> <span style="color: #004993;">flash.events</span>.<span style="color: #004993;">Event</span>;</div>
</li>
<li style="font-weight: bold;color:#26536A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; </div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#3A6A8B;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; <span style="color: #0033ff; font-weight: bold;">import</span> mx.collections.ArrayCollection;</div>
</li>
<li style="font-weight: bold;color:#26536A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; </div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#3A6A8B;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; <span style="color: #0033ff; font-weight: bold;">import</span> org.robotlegs.mvcs.Actor;</div>
</li>
<li style="font-weight: bold;color:#26536A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; </div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#3A6A8B;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; <span style="color: #0033ff; font-weight: bold;">public</span> <span style="color: #9900cc; font-weight: bold;">class</span> CountryListModel <span style="color: #0033ff; font-weight: bold;">extends</span> Actor</div>
</li>
<li style="font-weight: bold;color:#26536A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; <span style="color: #000000;">&#123;</span></div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#3A6A8B;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #0033ff; font-weight: bold;">public</span> <span style="color: #339966; font-weight: bold;">function</span> CountryListModel<span style="color: #000000;">&#40;</span><span style="color: #000000;">&#41;</span></div>
</li>
<li style="font-weight: bold;color:#26536A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #000000;">&#123;</span></div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#3A6A8B;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #0033ff; font-weight: bold;">super</span><span style="color: #000000;">&#40;</span><span style="color: #000000;">&#41;</span>;</div>
</li>
<li style="font-weight: bold;color:#26536A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #000000;">&#125;</span></div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#3A6A8B;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; &nbsp; &nbsp; </div>
</li>
<li style="font-weight: bold;color:#26536A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #0033ff; font-weight: bold;">private</span> <span style="color: #6699cc; font-weight: bold;">var</span> _countryList:ArrayCollection;</div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#3A6A8B;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp;</div>
</li>
<li style="font-weight: bold;color:#26536A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #0033ff; font-weight: bold;">public</span> <span style="color: #339966; font-weight: bold;">function</span> <span style="color: #0033ff; font-weight: bold;">get</span> countryList<span style="color: #000000;">&#40;</span><span style="color: #000000;">&#41;</span>:ArrayCollection</div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#3A6A8B;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #000000;">&#123;</span></div>
</li>
<li style="font-weight: bold;color:#26536A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #0033ff; font-weight: bold;">return</span> _countryList;</div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#3A6A8B;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #000000;">&#125;</span></div>
</li>
<li style="font-weight: bold;color:#26536A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp;</div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#3A6A8B;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #0033ff; font-weight: bold;">public</span> <span style="color: #339966; font-weight: bold;">function</span> <span style="color: #0033ff; font-weight: bold;">set</span> countryList<span style="color: #000000;">&#40;</span><span style="color: #004993;">value</span>:ArrayCollection<span style="color: #000000;">&#41;</span>:<span style="color: #0033ff; font-weight: bold;">void</span></div>
</li>
<li style="font-weight: bold;color:#26536A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #000000;">&#123;</span></div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#3A6A8B;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; _countryList = <span style="color: #004993;">value</span>;</div>
</li>
<li style="font-weight: bold;color:#26536A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; dispatch<span style="color: #000000;">&#40;</span><span style="color: #0033ff; font-weight: bold;">new</span> <span style="color: #004993;">Event</span><span style="color: #000000;">&#40;</span>CountryListEvents.COUNTRY_DATA_LOADED<span style="color: #000000;">&#41;</span><span style="color: #000000;">&#41;</span>;</div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#3A6A8B;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #000000;">&#125;</span></div>
</li>
<li style="font-weight: bold;color:#26536A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp;</div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#3A6A8B;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; <span style="color: #000000;">&#125;</span></div>
</li>
<li style="font-weight: bold;color:#26536A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;"><span style="color: #000000;">&#125;</span> </div>
</li>
</ol>
</div>
</div>
</div>
<p></p>
<p>Nótese que cuando se modifica la variable “countryList”, que almacena la lista de países, se despacha un evento (COUNTRY_DATA_LOADED), que es atrapado por el mediador, el cual en respuesta, actualiza el componente visual.</p>
<p>En este ejemplo, por razones de simplicidad, los eventos utilizados son de la clase “Event” de Flex, pero en un escenario real, lo más conveniente sería crear eventos personalizados que llevaran una carga útil de interés para la aplicación. </p>
<p>Finalmente el actor responsable de orquestar todo este trabajo es el contexto, representado por la clase “CountryListContext”, que hereda de la clase “Context” del framework.</p>
<div class="igBar"><span id="lactionscript3-45"><a href="#" onclick="javascript:showPlainTxt('actionscript3-45'); return false;">PLAIN TEXT</a></span></div>
<div class="syntax_hilite"><span class="langName">Actionscript 3:</span>
<div id="actionscript3-45">
<div class="actionscript3">
<ol>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#3A6A8B;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;"><span style="color: #9900cc; font-weight: bold;">package</span></div>
</li>
<li style="font-weight: bold;color:#26536A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;"><span style="color: #000000;">&#123;</span></div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#3A6A8B;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; <span style="color: #0033ff; font-weight: bold;">import</span> commands.LoadCountryData;</div>
</li>
<li style="font-weight: bold;color:#26536A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; </div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#3A6A8B;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; <span style="color: #0033ff; font-weight: bold;">import</span> events.CountryListEvents;</div>
</li>
<li style="font-weight: bold;color:#26536A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; </div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#3A6A8B;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; <span style="color: #0033ff; font-weight: bold;">import</span> <span style="color: #004993;">flash.display</span>.<span style="color: #004993;">DisplayObjectContainer</span>;</div>
</li>
<li style="font-weight: bold;color:#26536A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; </div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#3A6A8B;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; <span style="color: #0033ff; font-weight: bold;">import</span> model.CountryListModel;</div>
</li>
<li style="font-weight: bold;color:#26536A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; </div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#3A6A8B;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; <span style="color: #0033ff; font-weight: bold;">import</span> org.robotlegs.mvcs.Context;</div>
</li>
<li style="font-weight: bold;color:#26536A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; </div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#3A6A8B;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; <span style="color: #0033ff; font-weight: bold;">import</span> services.countrydataservice.CountryDataService;</div>
</li>
<li style="font-weight: bold;color:#26536A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; </div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#3A6A8B;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; <span style="color: #0033ff; font-weight: bold;">import</span> views.CountryListMediator;</div>
</li>
<li style="font-weight: bold;color:#26536A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; <span style="color: #0033ff; font-weight: bold;">import</span> views.CountryListView;</div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#3A6A8B;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; </div>
</li>
<li style="font-weight: bold;color:#26536A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; <span style="color: #0033ff; font-weight: bold;">public</span> <span style="color: #9900cc; font-weight: bold;">class</span> CountryListContext <span style="color: #0033ff; font-weight: bold;">extends</span> Context</div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#3A6A8B;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; <span style="color: #000000;">&#123;</span></div>
</li>
<li style="font-weight: bold;color:#26536A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #0033ff; font-weight: bold;">public</span> <span style="color: #339966; font-weight: bold;">function</span> CountryListContext<span style="color: #000000;">&#40;</span>contextView:<span style="color: #004993;">DisplayObjectContainer</span>=<span style="color: #0033ff; font-weight: bold;">null</span>, autoStartup:<span style="color: #004993;">Boolean</span>=<span style="color: #0033ff; font-weight: bold;">true</span><span style="color: #000000;">&#41;</span></div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#3A6A8B;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #000000;">&#123;</span></div>
</li>
<li style="font-weight: bold;color:#26536A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #0033ff; font-weight: bold;">super</span><span style="color: #000000;">&#40;</span>contextView, autoStartup<span style="color: #000000;">&#41;</span>;</div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#3A6A8B;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #000000;">&#125;</span></div>
</li>
<li style="font-weight: bold;color:#26536A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; &nbsp; &nbsp; </div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#3A6A8B;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #0033ff; font-weight: bold;">override</span> <span style="color: #0033ff; font-weight: bold;">public</span> <span style="color: #339966; font-weight: bold;">function</span> startup<span style="color: #000000;">&#40;</span><span style="color: #000000;">&#41;</span>:<span style="color: #0033ff; font-weight: bold;">void</span><span style="color: #000000;">&#123;</span></div>
</li>
<li style="font-weight: bold;color:#26536A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; </div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#3A6A8B;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; injector.mapSingleton<span style="color: #000000;">&#40;</span>CountryListModel<span style="color: #000000;">&#41;</span>;</div>
</li>
<li style="font-weight: bold;color:#26536A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; injector.mapSingleton<span style="color: #000000;">&#40;</span>CountryDataService<span style="color: #000000;">&#41;</span>;</div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#3A6A8B;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; </div>
</li>
<li style="font-weight: bold;color:#26536A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; commandMap.mapEvent<span style="color: #000000;">&#40;</span>CountryListEvents.LOAD_COUNTRY_DATA, LoadCountryData<span style="color: #000000;">&#41;</span>;</div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#3A6A8B;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; mediatorMap.mapView<span style="color: #000000;">&#40;</span>CountryListView, CountryListMediator<span style="color: #000000;">&#41;</span>;</div>
</li>
<li style="font-weight: bold;color:#26536A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #000000;">&#125;</span></div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#3A6A8B;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; <span style="color: #000000;">&#125;</span></div>
</li>
<li style="font-weight: bold;color:#26536A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;"><span style="color: #000000;">&#125;</span> </div>
</li>
</ol>
</div>
</div>
</div>
<p></p>
<p>En el método “startup”, invocado cuando el dueño de este contexto se añade al stage, se realiza el trabajo de enlazar las diferentes partes de la aplicación.</p>
<p>En este caso, primeramente se indica al mecanismo de inyección que cree un singleton de las clases “CountryListModel” (el modelo) y “CountryDataService” (el servicio), cuyas referencias serán inyectadas en las clases “LoadCountryData” y “CountryListMediator” según sea necesario.</p>
<p>Luego se indica que para el evento LOAD_COUNTRY_DATA se registre el comando LoadCountryData. Esto hará que cuando algún actor del framework (en este ejemplo el mediador) despache un evento de ese tipo, se creará un objeto de tipo “LoadCountryData”, se inyectarán todas sus dependencias y se invocará el método execute.</p>
<p>Por último se indica que se registre como mediador del componente visual CountryListView la clase CountryListMediator. Esto provocará que cuando se añada el componente visual al stage, se creará una instancia de la clase “CountryListMediator”, se inyectarán sus dependencias y se invocará el método “onRegister”.</p>
<p>Finalmente se crea el contexto en la clase Application:</p>
<div class="igBar"><span id="lmxml-46"><a href="#" onclick="javascript:showPlainTxt('mxml-46'); return false;">PLAIN TEXT</a></span></div>
<div class="syntax_hilite"><span class="langName">MXML:</span>
<div id="mxml-46">
<div class="mxml">
<ol>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#3A6A8B;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;"><span style="color: #000000;">&lt;?xml version=<span style="color: #ff0000;">"1.0"</span> encoding=<span style="color: #ff0000;">"utf-8"</span>?<span style="color: #7400FF;">&gt;</span></span></div>
</li>
<li style="font-weight: bold;color:#26536A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;"><span style="color: #000000;"><span style="color: #7400FF;">&lt;s:Application</span> xmlns:fx=<span style="color: #ff0000;">"http://ns.adobe.com/mxml/2009"</span> </div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#3A6A8B;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;&nbsp; &nbsp; xmlns:s=<span style="color: #ff0000;">"library://ns.adobe.com/flex/spark"</span> </div>
</li>
<li style="font-weight: bold;color:#26536A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;&nbsp; &nbsp; xmlns:mx=<span style="color: #ff0000;">"library://ns.adobe.com/flex/mx"</span> </div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#3A6A8B;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;&nbsp; &nbsp; minWidth=<span style="color: #ff0000;">"955"</span> minHeight=<span style="color: #ff0000;">"600"</span> xmlns:views=<span style="color: #ff0000;">"views.*"</span> </div>
</li>
<li style="font-weight: bold;color:#26536A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;&nbsp; &nbsp; xmlns:local=<span style="color: #ff0000;">"*"</span><span style="color: #7400FF;">&gt;</span></span></div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#3A6A8B;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; </div>
</li>
<li style="font-weight: bold;color:#26536A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; <span style="color: #000000;"><span style="color: #7400FF;">&lt;fx:Declarations</span><span style="color: #7400FF;">&gt;</span></span></div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#3A6A8B;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #000000;"><span style="color: #7400FF;">&lt;local:CountryListContext</span> contextView=<span style="color: #ff0000;">"{this}"</span><span style="color: #7400FF;">/&gt;</span></span></div>
</li>
<li style="font-weight: bold;color:#26536A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; <span style="color: #000000;"><span style="color: #7400FF;">&lt;/fx:Declarations</span><span style="color: #7400FF;">&gt;</span></span></div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#3A6A8B;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; </div>
</li>
<li style="font-weight: bold;color:#26536A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; <span style="color: #000000;"><span style="color: #7400FF;">&lt;views:CountryListView</span><span style="color: #7400FF;">/&gt;</span></span></div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#3A6A8B;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;"><span style="color: #000000;"><span style="color: #7400FF;">&lt;/s:Application</span><span style="color: #7400FF;">&gt;</span></span> </div>
</li>
</ol>
</div>
</div>
</div>
<p></p>
<p>Cuando ejecutamos la aplicación se obtiene lo siguiente:</p>
<p><a href="http://www.madeinflex.com/wp-content/uploads/2010/07/4.jpg"><img src="http://www.madeinflex.com/wp-content/uploads/2010/07/4.jpg" alt="4" title="4" width="396" height="294" class="aligncenter size-full wp-image-1511" /></a></p>
<p>El archivo XML con los datos se encuentra en la carpeta “data” del proyecto, el que se puede descargar de <a href='http://www.madeinflex.com/wp-content/uploads/2010/07/RobotlegsDemo.zip'>aquí</a>.</p>
<h4 id="toc-conclusiones">Conclusiones</h4>
<p>Robotlegs es un framework muy simple y compacto que ofrece una implementación de referencia del patrón MVC+S, nos permite crear aplicaciones Flex con bajo nivel de acoplamiento, componentes reutilizables y con una estructura que en proyectos grandes resulta de gran utilidad,  nos permite aprovechar los beneficios de la Inversión de Control en nuestros proyectos.</p>]]></content:encoded>
			<wfw:commentRss>http://www.madeinflex.com/2010/07/13/utilizando-robotlegs-para-el-desarrollo-de-aplicaciones-flex/feed/</wfw:commentRss>
		<slash:comments>7</slash:comments>
		</item>
		<item>
		<title>Usando Data Centric Development (DCD) en proyectos Flex/Java con WTP</title>
		<link>http://www.madeinflex.com/2010/05/30/usando-data-centric-development-dcd-en-proyectos-flexjava-con-wtp/</link>
		<comments>http://www.madeinflex.com/2010/05/30/usando-data-centric-development-dcd-en-proyectos-flexjava-con-wtp/#comments</comments>
		<pubDate>Sun, 30 May 2010 12:12:22 +0000</pubDate>
		<dc:creator>Nono F. Carballo Escalona</dc:creator>
				<category><![CDATA[Artículos]]></category>
		<category><![CDATA[Tutoriales]]></category>

		<guid isPermaLink="false">http://www.madeinflex.com/?p=1417</guid>
		<description><![CDATA[<!-- matched  --><!-- final 0 -->Introducción
El problema
La solución
Conclusiones


La instalación de Flash Builder 4 plug-in incluye el paquete Ganymede de Eclipse, pero podemos optar por instalarlo sobre una distribución de eclipse alternativa (y mas reciente), como el paquete Galileo del Eclipse IDE for Java EE Developers, el cual incluye Web Tools Platform (http://www.eclipse.org/home/categories/index.php?category=enterprise).
Introducción
Instalar Flash Builder 4 como plug-in del paquete Galileo [...]]]></description>
			<content:encoded><![CDATA[<!-- matched  --><!-- final 0 --><p><span id="more-1417"></span><br />
<!--noteaser--></p>
<div class="toc">
<ol>
<li><a href="http://www.madeinflex.com/2010/05/30/usando-data-centric-development-dcd-en-proyectos-flexjava-con-wtp/#toc-introduccion">Introducción</a></li>
<li><a href="http://www.madeinflex.com/2010/05/30/usando-data-centric-development-dcd-en-proyectos-flexjava-con-wtp/#toc-el-problema">El problema</a></li>
<li><a href="http://www.madeinflex.com/2010/05/30/usando-data-centric-development-dcd-en-proyectos-flexjava-con-wtp/#toc-la-solucion">La solución</a></li>
<li><a href="http://www.madeinflex.com/2010/05/30/usando-data-centric-development-dcd-en-proyectos-flexjava-con-wtp/#toc-conclusiones">Conclusiones</a></li>
</ol>
</div>
<p>La instalación de Flash Builder 4 plug-in incluye el paquete Ganymede de Eclipse, pero podemos optar por instalarlo sobre una distribución de eclipse alternativa (y mas reciente), como el paquete Galileo del Eclipse IDE for Java EE Developers, el cual incluye Web Tools Platform (<a href="http://www.eclipse.org/home/categories/index.php?category=enterprise">http://www.eclipse.org/home/categories/index.php?category=enterprise</a>).</p>
<h4 id="toc-introduccion">Introducción</h4>
<p>Instalar Flash Builder 4 como plug-in del paquete Galileo nos permite crear proyectos Flex y Java combinados, esto es, en un mismo proyecto tendremos el código fuente de la capa de presentación (Flex) y de la capa de negocios (Java), sin necesidad de dos proyectos por separado.</p>
<h4 id="toc-el-problema">El problema</h4>
<p>Al parecer existe un bug en la creación de un proyecto Flex/Java en cuanto al uso de las macros web.context y web.content que provoca que la los parámetros "serverContextRoot" y "serverRootURL" no tomen los valores adecuados y que funcionalidad DCD no funcione.</p>
<p>Al crear un proyecto Flex aparece la opción de crear un proyecto combinado Flex/Java<br />
<div id="attachment_1420" class="wp-caption alignnone" style="width: 419px"><a href="http://www.madeinflex.com/wp-content/uploads/2010/05/1.jpg"><img src="http://www.madeinflex.com/wp-content/uploads/2010/05/1.jpg" alt="Creación de proyecto Flex/Java con WTP" title="Creación de proyecto Flex/Java con WTP" width="409" height="477" class="size-full wp-image-1420" /></a><p class="wp-caption-text">Creación de proyecto Flex/Java con WTP</p></div><br />
Al seleccionar la opción y oprimir “Next” pasamos a configurar el servidor J2EE. Si es la primera vez que creamos un proyecto de este tipo en el Workspace, debemos definir un nuevo servidor oprimiendo “New” y seguir los pasos del asistente. En caso contrario seleccionamos un servidor existente.</p>
<p>El valor del campo “Content Folder” (donde se almacenará la aplicación a desplegar luego en Tomcat) por defecto es “WebContent”, dejaremos este valor y luego veremos el efecto que trae. Debemos también indicar el lugar donde se encuentra el archivo “blazeds.war”, en este caso usamos el que viene en el paquete “blazeds-bin-4.0.0.14931.zip” (<a href="https://www.adobe.com/cfusion/entitlement/index.cfm?e=lc_blazeds">https://www.adobe.com/cfusion/entitlement/index.cfm?e=lc_blazeds</a>). Oprimimos “Next” y luego “Finish”. Terminaremos con un proyecto con una estructura como esta:<br />
<div id="attachment_1427" class="wp-caption alignnone" style="width: 246px"><a href="http://www.madeinflex.com/wp-content/uploads/2010/05/2.jpg"><img src="http://www.madeinflex.com/wp-content/uploads/2010/05/2.jpg" alt="Estructura de un proyecto Flex/Java" title="2" width="236" height="360" class="size-full wp-image-1427" /></a><p class="wp-caption-text">Estructura de un proyecto Flex/Java</p></div><br />
Notemos que la carpeta “WebContent” tiene la estructura de una aplicación J2EE, como la que se despliega en Tomcat. Intentemos ahora utilizar la funcionalidad de DCD en este proyecto. Lo que haremos será crear una clase Java con un método público y la expondremos como destino remoto, configuraremos el servlet RDSDispatchServlet (encargado de descubrir las clases expuestas como destinos remotos y los métodos que éstas contienen) y veremos si Flash Builder 4 es capaz de encontrarlo.</p>
<p>La clase Java puede ser una como ésta:</p>
<div class="igBar"><span id="ljava-52"><a href="#" onclick="javascript:showPlainTxt('java-52'); return false;">PLAIN TEXT</a></span></div>
<div class="syntax_hilite"><span class="langName">JAVA:</span>
<div id="java-52">
<div class="java">
<ol>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#3A6A8B;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">package com.<span style="color: #006600;">flexwtp</span>.<span style="color: #006600;">service</span>;</div>
</li>
<li style="font-weight: bold;color:#26536A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp;</div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#3A6A8B;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;"><span style="color: #000000; font-weight: bold;">public</span> <span style="color: #000000; font-weight: bold;">class</span> FlexWTPService <span style="color: #66cc66;">&#123;</span></div>
</li>
<li style="font-weight: bold;color:#26536A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp;</div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#3A6A8B;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; <span style="color: #000000; font-weight: bold;">public</span> <a href="http://www.google.com/search?q=allinurl%3AString+java.sun.com&amp;bntl=1"><span style="color: #aaaadd; font-weight: bold;">String</span></a><span style="color: #66cc66;">&#91;</span><span style="color: #66cc66;">&#93;</span> getAll<span style="color: #66cc66;">&#40;</span><span style="color: #66cc66;">&#41;</span><span style="color: #66cc66;">&#123;</span></div>
</li>
<li style="font-weight: bold;color:#26536A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #000000; font-weight: bold;">return</span> <span style="color: #000000; font-weight: bold;">new</span> <a href="http://www.google.com/search?q=allinurl%3AString+java.sun.com&amp;bntl=1"><span style="color: #aaaadd; font-weight: bold;">String</span></a><span style="color: #66cc66;">&#91;</span><span style="color: #66cc66;">&#93;</span><span style="color: #66cc66;">&#123;</span><span style="color: #ff0000;">"Uno"</span>,<span style="color: #ff0000;">"Dos"</span>,<span style="color: #ff0000;">"Tres"</span><span style="color: #66cc66;">&#125;</span>;</div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#3A6A8B;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; <span style="color: #66cc66;">&#125;</span></div>
</li>
<li style="font-weight: bold;color:#26536A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;"><span style="color: #66cc66;">&#125;</span> </div>
</li>
</ol>
</div>
</div>
</div>
<p></p>
<p>Para hacerla disponible como destino remoto añadimos al archivo WebContent/WEB-INF/flex/remoting-config.xml lo siguiente:</p>
<div class="igBar"><span id="lxml-53"><a href="#" onclick="javascript:showPlainTxt('xml-53'); return false;">PLAIN TEXT</a></span></div>
<div class="syntax_hilite"><span class="langName">XML:</span>
<div id="xml-53">
<div class="xml">
<ol>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#3A6A8B;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;"><span style="color: #009900;"><span style="font-weight: bold; color: black;">&lt;destination</span> <span style="color: #000066;">id</span>=<span style="color: #ff0000;">"FlexWTPService"</span><span style="font-weight: bold; color: black;">&gt;</span></span></div>
</li>
<li style="font-weight: bold;color:#26536A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; <span style="color: #009900;"><span style="font-weight: bold; color: black;">&lt;properties<span style="font-weight: bold; color: black;">&gt;</span></span></span></div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#3A6A8B;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #009900;"><span style="font-weight: bold; color: black;">&lt;source<span style="font-weight: bold; color: black;">&gt;</span></span></span>com.flexwtp.service.FlexWTPService<span style="color: #009900;"><span style="font-weight: bold; color: black;">&lt;/source<span style="font-weight: bold; color: black;">&gt;</span></span></span></div>
</li>
<li style="font-weight: bold;color:#26536A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; <span style="color: #009900;"><span style="font-weight: bold; color: black;">&lt;/properties<span style="font-weight: bold; color: black;">&gt;</span></span></span></div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#3A6A8B;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;"><span style="color: #009900;"><span style="font-weight: bold; color: black;">&lt;/destination<span style="font-weight: bold; color: black;">&gt;</span></span></span> </div>
</li>
</ol>
</div>
</div>
</div>
<p></p>
<p>Finalmente para configurar el RDSDispatchServlet añadimos lo siguiente al archivo WebContent/WEB-INF/web.xml</p>
<div class="igBar"><span id="lxml-54"><a href="#" onclick="javascript:showPlainTxt('xml-54'); return false;">PLAIN TEXT</a></span></div>
<div class="syntax_hilite"><span class="langName">XML:</span>
<div id="xml-54">
<div class="xml">
<ol>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#3A6A8B;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;"><span style="color: #009900;"><span style="font-weight: bold; color: black;">&lt;servlet<span style="font-weight: bold; color: black;">&gt;</span></span></span></div>
</li>
<li style="font-weight: bold;color:#26536A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;"><span style="color: #009900;"><span style="font-weight: bold; color: black;">&lt;servlet</span>-name<span style="font-weight: bold; color: black;">&gt;</span></span>RDSDispatchServlet<span style="color: #009900;"><span style="font-weight: bold; color: black;">&lt;/servlet</span>-name<span style="font-weight: bold; color: black;">&gt;</span></span></div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#3A6A8B;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;"><span style="color: #009900;"><span style="font-weight: bold; color: black;">&lt;display</span>-name<span style="font-weight: bold; color: black;">&gt;</span></span>RDSDispatchServlet<span style="color: #009900;"><span style="font-weight: bold; color: black;">&lt;/display</span>-name<span style="font-weight: bold; color: black;">&gt;</span></span></div>
</li>
<li style="font-weight: bold;color:#26536A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;"><span style="color: #009900;"><span style="font-weight: bold; color: black;">&lt;servlet</span>-class<span style="font-weight: bold; color: black;">&gt;</span></span>flex.rds.server.servlet.FrontEndServlet<span style="color: #009900;"><span style="font-weight: bold; color: black;">&lt;/servlet</span>-class<span style="font-weight: bold; color: black;">&gt;</span></span>&nbsp; </div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#3A6A8B;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; <span style="color: #009900;"><span style="font-weight: bold; color: black;">&lt;init</span>-param<span style="font-weight: bold; color: black;">&gt;</span></span></div>
</li>
<li style="font-weight: bold;color:#26536A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #009900;"><span style="font-weight: bold; color: black;">&lt;param</span>-name<span style="font-weight: bold; color: black;">&gt;</span></span>useAppserverSecurity<span style="color: #009900;"><span style="font-weight: bold; color: black;">&lt;/param</span>-name<span style="font-weight: bold; color: black;">&gt;</span></span></div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#3A6A8B;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #009900;"><span style="font-weight: bold; color: black;">&lt;param</span>-value<span style="font-weight: bold; color: black;">&gt;</span></span>false<span style="color: #009900;"><span style="font-weight: bold; color: black;">&lt;/param</span>-value<span style="font-weight: bold; color: black;">&gt;</span></span></div>
</li>
<li style="font-weight: bold;color:#26536A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; <span style="color: #009900;"><span style="font-weight: bold; color: black;">&lt;/init</span>-param<span style="font-weight: bold; color: black;">&gt;</span></span>&nbsp; &nbsp; </div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#3A6A8B;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; <span style="color: #009900;"><span style="font-weight: bold; color: black;">&lt;load</span>-on-startup<span style="font-weight: bold; color: black;">&gt;</span></span>10<span style="color: #009900;"><span style="font-weight: bold; color: black;">&lt;/load</span>-on-startup<span style="font-weight: bold; color: black;">&gt;</span></span></div>
</li>
<li style="font-weight: bold;color:#26536A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;"><span style="color: #009900;"><span style="font-weight: bold; color: black;">&lt;/servlet<span style="font-weight: bold; color: black;">&gt;</span></span></span></div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#3A6A8B;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp;</div>
</li>
<li style="font-weight: bold;color:#26536A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;"><span style="color: #009900;"><span style="font-weight: bold; color: black;">&lt;servlet</span>-mapping <span style="color: #000066;">id</span>=<span style="color: #ff0000;">"RDS_DISPATCH_MAPPING"</span><span style="font-weight: bold; color: black;">&gt;</span></span></div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#3A6A8B;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; <span style="color: #009900;"><span style="font-weight: bold; color: black;">&lt;servlet</span>-name<span style="font-weight: bold; color: black;">&gt;</span></span>RDSDispatchServlet<span style="color: #009900;"><span style="font-weight: bold; color: black;">&lt;/servlet</span>-name<span style="font-weight: bold; color: black;">&gt;</span></span></div>
</li>
<li style="font-weight: bold;color:#26536A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; <span style="color: #009900;"><span style="font-weight: bold; color: black;">&lt;url</span>-pattern<span style="font-weight: bold; color: black;">&gt;</span></span>/CFIDE/main/ide.cfm<span style="color: #009900;"><span style="font-weight: bold; color: black;">&lt;/url</span>-pattern<span style="font-weight: bold; color: black;">&gt;</span></span></div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#3A6A8B;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;"><span style="color: #009900;"><span style="font-weight: bold; color: black;">&lt;/servlet</span>-mapping<span style="font-weight: bold; color: black;">&gt;</span></span> </div>
</li>
</ol>
</div>
</div>
</div>
<p></p>
<p>Compilamos el proyecto y desplegamos la aplicación (el contenido de WebContent) en Tomcat (el que tenemos en el WorkSpace u otro externo) y cuando en la vista “Data/Services” de la perspectiva “Flash Development” tratamos de conectarnos a un servicio/datos de tipo BlazeDS sin usar autenticación:</p>
<div id="attachment_1434" class="wp-caption aligncenter" style="width: 469px"><a href="http://www.madeinflex.com/wp-content/uploads/2010/05/3.jpg"><img src="http://www.madeinflex.com/wp-content/uploads/2010/05/3.jpg" alt="Conexión a un servicio/dato de tipo BlazeDS" title="3" width="459" height="398" class="size-full wp-image-1434" /></a><p class="wp-caption-text">Conexión a un servicio/dato de tipo BlazeDS</p></div>
<p>Obtenemos el siguiente error:</p>
<div id="attachment_1436" class="wp-caption aligncenter" style="width: 451px"><a href="http://www.madeinflex.com/wp-content/uploads/2010/05/4.jpg"><img src="http://www.madeinflex.com/wp-content/uploads/2010/05/4.jpg" alt="Error en la conexión al servlet  RDSDispatchServlet" title="4" width="441" height="279" class="size-full wp-image-1436" /></a><p class="wp-caption-text">Error en la conexión al servlet  RDSDispatchServlet</p></div>
<p>Luego de verificar que lo que se indica en los puntos 1, 2 y 3 está correcto sólo nos queda verificar la configuración del proyecto.<br />
La configuración del servidor para el proyecto según como se definió en la creación del mismo queda de la siguiente manera:</p>
<div id="attachment_1437" class="wp-caption aligncenter" style="width: 485px"><a href="http://www.madeinflex.com/wp-content/uploads/2010/05/5.jpg"><img src="http://www.madeinflex.com/wp-content/uploads/2010/05/5.jpg" alt="Propiedades del proyecto Flex/Java" title="5" width="475" height="425" class="size-full wp-image-1437" /></a><p class="wp-caption-text">Propiedades del proyecto Flex/Java</p></div>
<p>Pero al examinar el contenido del archivo “.flexProperties” que se encuentra en la raíz del proyecto notamos que el parámetro “serverContextRoot” está definido cómo </p>
<div class="igBar"><span id="lcode-55"><a href="#" onclick="javascript:showPlainTxt('code-55'); return false;">PLAIN TEXT</a></span></div>
<div class="syntax_hilite"><span class="langName">CODE:</span>
<div id="code-55">
<div class="code">
<ol>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#3A6A8B;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">serverContextRoot=<span style="color:#CC0000;">"/WebContent"</span> </div>
</li>
</ol>
</div>
</div>
</div>
<p></p>
<p>Sin embargo el parámetro “serverRootURL” tiene el valor:</p>
<div class="igBar"><span id="lcode-56"><a href="#" onclick="javascript:showPlainTxt('code-56'); return false;">PLAIN TEXT</a></span></div>
<div class="syntax_hilite"><span class="langName">CODE:</span>
<div id="code-56">
<div class="code">
<ol>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#3A6A8B;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">serverRootURL=<span style="color:#CC0000;">"http://localhost:8080/FlexWTPProject"</span> </div>
</li>
</ol>
</div>
</div>
</div>
<p></p>
<p>De esa manera el servlet “RDSDispatchServlet” no podrá encontrar la clase que hemos definido como destino remoto, el parámetro “serverContextRoot” debe contener el nombre de la aplicación desplegada en Tomcat, en este caso “FlexWTPProject” (la última parte del url, sin el slash final).</p>
<p>Cuando se crea el proyecto, “serverContextRoot” toma el valor del campo “Content Folder”, y no hay modo de cambiar su valor luego en las propiedades del proyecto. Se pudiera modificar manualmente en el archivo “.flexProperties”, pero éste se genera nuevamente cuando se modifica alguna propiedad del proyecto y se perderían los cambios.</p>
<h4 id="toc-la-solucion">La solución</h4>
<p>La solución es asignar al campo “Content Folder”, durante la creación del proyecto, el valor del nombre del proyecto, que a su vez forma parte del parámetro “serverRootURL”.</p>
<div id="attachment_1439" class="wp-caption aligncenter" style="width: 577px"><a href="http://www.madeinflex.com/wp-content/uploads/2010/05/6.jpg"><img src="http://www.madeinflex.com/wp-content/uploads/2010/05/6.jpg" alt="Configuración del servidor JEE en un proyecto Flex/Java" title="6" width="567" height="315" class="size-full wp-image-1439" /></a><p class="wp-caption-text">Configuración del servidor JEE en un proyecto Flex/Java</p></div>
<p>De esta manera, una vez desplegada la aplicación, cuando intentemos conectarnos a un servicio/dato a través de la vista “Data/Services” obtendremos lo siguiente:</p>
<div id="attachment_1440" class="wp-caption aligncenter" style="width: 579px"><a href="http://www.madeinflex.com/wp-content/uploads/2010/05/7.jpg"><img src="http://www.madeinflex.com/wp-content/uploads/2010/05/7.jpg" alt="Resultado de la conexión a un servicio/dato de tipo BlazeDS" title="7" width="569" height="339" class="size-full wp-image-1440" /></a><p class="wp-caption-text">Resultado de la conexión a un servicio/dato de tipo BlazeDS</p></div>
<p>Lo cual nos indica que el servlet “RDSDispatchServlet” ha encontrado la clase java que hemos definido como destino remoto. Seleccionamos el destino, indicamos el nombre de los paquetes y al oprimir “Finish” el asistente generará el código correspondiente (en este ejemplo en particular no se genera ningún valueObject ya que el tipo de dato de retorno del método es String, el cual es soportado nativamente por ActionScript). </p>
<div id="attachment_1442" class="wp-caption alignleft" style="width: 287px"><a href="http://www.madeinflex.com/wp-content/uploads/2010/05/8.jpg"><img src="http://www.madeinflex.com/wp-content/uploads/2010/05/8.jpg" alt="Código generado por el asistente." title="8" width="277" height="129" class="size-full wp-image-1442" /></a><p class="wp-caption-text">Código generado por el asistente.</p></div><br />
<div id="attachment_1443" class="wp-caption alignright" style="width: 230px"><a href="http://www.madeinflex.com/wp-content/uploads/2010/05/9.jpg"><img src="http://www.madeinflex.com/wp-content/uploads/2010/05/9.jpg" alt="Vista Data/Services luego de la generación de código" title="9" width="220" height="169" class="size-full wp-image-1443" /></a><p class="wp-caption-text">Vista Data/Services luego de la generación de código</p></div>
<p>La opción de nombrar al proyecto “WebContent” y aceptar el valor inicial propuesto para el campo “Content Folder” ni siquiera se contempla, por razones obvias <img src='http://www.madeinflex.com/wp-includes/images/smilies/icon_wink.gif' alt=';-)' class='wp-smiley' /> </p>
<h4 id="toc-conclusiones">Conclusiones</h4>
<p>Siguiendo los pasos que hemos explicado en este artículo podremos crear proyectos Flex/Java con WTP y explotar la funcionalidad del Data Centric Development introducido en Flash Builder 4, la cual representa sin dudas un gran paso hacia el objetivo de lograr un entorno de trabajo altamente productivo para el desarrollo de RIA con Adobe Flex y Java.</p>]]></content:encoded>
			<wfw:commentRss>http://www.madeinflex.com/2010/05/30/usando-data-centric-development-dcd-en-proyectos-flexjava-con-wtp/feed/</wfw:commentRss>
		<slash:comments>3</slash:comments>
		</item>
		<item>
		<title>Fx4 III: FXG 1.0</title>
		<link>http://www.madeinflex.com/2009/07/18/fx4-iii-fxg-10/</link>
		<comments>http://www.madeinflex.com/2009/07/18/fx4-iii-fxg-10/#comments</comments>
		<pubDate>Sat, 18 Jul 2009 15:12:57 +0000</pubDate>
		<dc:creator>Joan Garnet</dc:creator>
				<category><![CDATA[Artículos]]></category>
		<category><![CDATA[Flex 4]]></category>
		<category><![CDATA[Tutoriales]]></category>

		<guid isPermaLink="false">http://www.madeinflex.com/2009/07/18/fx4-iii-fxg-10/</guid>
		<description><![CDATA[<!-- matched  --><!-- final 0 -->En esta cuarta versión de Flex se han producido cambios considerables en la arquitectura de componentes así como en el lenguaje MXML. Esto se ha hecho para potenciar varios aspectos como son la productividad, facilitar el workflow designer / developer o la integración con herramientas externas.
En esta entrada se verá qué es FXG dentro del [...]]]></description>
			<content:encoded><![CDATA[<!-- matched  --><!-- final 0 --><p>En esta cuarta versión de Flex se han producido cambios considerables en la arquitectura de componentes así como en el lenguaje MXML. Esto se ha hecho para potenciar varios aspectos como son la productividad, facilitar el workflow designer / developer o la integración con herramientas externas.<br />
En esta entrada se verá qué es FXG dentro del contexto Flex 4. FXG es la especificación del nuevo formato de intercambio de gráficos para el Flash Player.</p>
<p><span id="more-866"></span></p>
<div class="toc">
<ol>
<li><a href="http://www.madeinflex.com/2009/07/18/fx4-iii-fxg-10/#toc-introduccion">Introducción</a></li>
<li><a href="http://www.madeinflex.com/2009/07/18/fx4-iii-fxg-10/#toc-documentos-fxg">Documentos FXG</a></li>
<li><a href="http://www.madeinflex.com/2009/07/18/fx4-iii-fxg-10/#toc-fxg-o-flex-fxg">¿FXG o Flex FXG?</a></li>
<li><a href="http://www.madeinflex.com/2009/07/18/fx4-iii-fxg-10/#toc-implementacion-fxg-en-flex">Implementación FXG en Flex</a>
<ol>
<li><a href="http://www.madeinflex.com/2009/07/18/fx4-iii-fxg-10/#toc-formas">Formas</a>
<ol>
<li><a href="http://www.madeinflex.com/2009/07/18/fx4-iii-fxg-10/#toc-fill">fill</a></li>
<li><a href="http://www.madeinflex.com/2009/07/18/fx4-iii-fxg-10/#toc-stroke">stroke</a></li>
<li><a href="http://www.madeinflex.com/2009/07/18/fx4-iii-fxg-10/#toc-spark-primitives-rect">spark.primitives.Rect</a></li>
<li><a href="http://www.madeinflex.com/2009/07/18/fx4-iii-fxg-10/#toc-spark-primitives-ellipse">spark.primitives.Ellipse</a></li>
<li><a href="http://www.madeinflex.com/2009/07/18/fx4-iii-fxg-10/#toc-spark-primitives-line">spark.primitives.Line</a></li>
<li><a href="http://www.madeinflex.com/2009/07/18/fx4-iii-fxg-10/#toc-spark-primitives-path">spark.primitives.Path</a></li>
</ol>
</li>
<li><a href="http://www.madeinflex.com/2009/07/18/fx4-iii-fxg-10/#toc-spark-primitives-bitmapimage">spark.primitives.BitmapImage</a></li>
<li><a href="http://www.madeinflex.com/2009/07/18/fx4-iii-fxg-10/#toc-texto">Texto</a></li>
<li><a href="http://www.madeinflex.com/2009/07/18/fx4-iii-fxg-10/#toc-spark-components-group">spark.components.Group</a></li>
</ol>
</li>
<li><a href="http://www.madeinflex.com/2009/07/18/fx4-iii-fxg-10/#toc-library">Library</a></li>
<li><a href="http://www.madeinflex.com/2009/07/18/fx4-iii-fxg-10/#toc-conclusion">Conclusión</a></li>
</ol>
</div>
<h2 id="toc-introduccion">Introducción</h2>
<p><acronym title="Flash XML Graphics">FXG</acronym> (Flash XML Graphics) es un lenguaje basado en XML que expone toda la capacidad de renderizado del Flash Player de forma declarativa. La especificación de FXG se ha creado para ofrecer un formato de intercambio de gráficos entre aplicaciones de edición gráfica y el Flash Player que sea fácil de utilizar y a la vez ofrezca un control total del resultado final y de la optimización del mismo.<br />
En la especificación de FXG encontramos un conjunto de elementos gráficos, texto, filtros, etc.. con los cuales se puede crear, agrupar, transformar y modificar formas vectoriales, bitmaps y texto.</p>
<h2 id="toc-documentos-fxg">Documentos FXG</h2>
<p>En una aplicación Flex podemos utilizar FXG en línea dentro de un documento *.MXML de la misma forma que utilizamos otros componentes Flex o bien auto contenido como componente en un archivo *.FXG o *.MXML externo.<br />
Aunque en ambos casos podamos obtener el mismo resultado internamente las cosas son ciertamente diferentes. En el caso de utilizar FXG en línea dentro de un archivo MXML lo que estamos haciendo es utilizar la implementación de FXG que el SDK de Flex nos proporciona, es decir, obtenemos instancias de clases que están dentro de la cadena de herencia del SDK de Flex.<br />
En el caso de utilizar un FXG como componente desde un archivo externo lo que obtenemos en el momento de compilación es un recurso gráfico muy optimizado en cuanto a uso de memoria y que hereda de <code>spark.core.SpriteVisualElement</code>, una clase de mucho más bajo nivel y por lo tanto mucho más ligera.</p>
<h2 id="toc-fxg-o-flex-fxg">¿FXG o Flex FXG?</h2>
<p>Entonces, ¿cuándo utilizar una u otra opción? Si necesitamos elementos gráficos que soporten el ciclo de vida del sdk de Flex y que nos proporcionen toda la interactividad del framework (eventos, data binding, etc...) entonces debemos utilizar la implementación de FXG que nos proporciona Flex a través de Spark, de lo contrario lo mejor es externalizar en forma de componente FXG para sacar partido de las optimizaciones que el compilador nos brinda.<br />
Debemos tener en cuenta que dentro de un comonente FXG no se pueden utilizar las funcionalidades del SDK, tampoco tipos nativos del Flash Player o en definitiva lógica alguna. El componente es puramente un descriptor de un elemento gráfico.</p>
<h2 id="toc-implementacion-fxg-en-flex">Implementación FXG en Flex</h2>
<p>Flex contiene una implementación FXG completa en el espacio de nombres Spark. En esta entrada vamos a aprender a utilizar FXG a través de dicha implementación.<br />
A continuación vamos a revisar los distintos elementos FXG de los que disponemos en Flex.</p>
<h3 id="toc-formas">Formas</h3>
<p>Las formas vectoriales se componen de los puntos que la definen, un relleno y un trazo.</p>
<h4 id="toc-fill">fill</h4>
<p>	El relleno de cualquer forma se declara mediante la propiedad <code>fill</code>.<br />
	Esta propiedad acepta implementaciones de <code>IFill</code>:</p>
<ul>
<li>mx.graphics.BitmapFill</li>
<li>mx.graphics.LinearGradient</li>
<li>mx.graphics.RadialGradient</li>
<li>mx.graphics.SolidColor</li>
</ul>
<h4 id="toc-stroke">stroke</h4>
<p>	El trazo que define una forma se declara mediante la propiedad <code>stroke</code>.<br />
	Esta propiedad acepta implementaciones de <code>IStroke</code>:</p>
<ul>
<li>mx.graphics.LinearGradientStroke</li>
<li>mx.graphics.RadialGradientStroke</li>
<li>mx.graphics.SolidColorStroke</li>
</ul>
<h4 id="toc-spark-primitives-rect">spark.primitives.Rect</h4>
<h4 id="toc-spark-primitives-ellipse">spark.primitives.Ellipse</h4>
<h4 id="toc-spark-primitives-line">spark.primitives.Line</h4>
<p>	Estas primitivas declaran respectivamente una forma rectangular, una elipse y una línea.<br />
	Un ejemplo de uso:</p>
<div class="igBar"><span id="lmxml-63"><a href="#" onclick="javascript:showPlainTxt('mxml-63'); return false;">PLAIN TEXT</a></span></div>
<div class="syntax_hilite"><span class="langName">MXML:</span>
<div id="mxml-63">
<div class="mxml">
<ol>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#3A6A8B;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;"><span style="color: #000000;">&lt;?xml version=<span style="color: #ff0000;">"1.0"</span> encoding=<span style="color: #ff0000;">"utf-8"</span>?<span style="color: #7400FF;">&gt;</span></span></div>
</li>
<li style="font-weight: bold;color:#26536A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;"><span style="color: #000000;"><span style="color: #7400FF;">&lt;s:Application</span> </div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#3A6A8B;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; xmlns:fx=<span style="color: #ff0000;">"http://ns.adobe.com/mxml/2009"</span> </div>
</li>
<li style="font-weight: bold;color:#26536A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; xmlns:s=<span style="color: #ff0000;">"library://ns.adobe.com/flex/spark"</span> </div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#3A6A8B;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; xmlns:mx=<span style="color: #ff0000;">"library://ns.adobe.com/flex/halo"</span><span style="color: #7400FF;">&gt;</span></span></div>
</li>
<li style="font-weight: bold;color:#26536A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; </div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#3A6A8B;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; <span style="color: #000000;"><span style="color: #7400FF;">&lt;s:Rect</span> width=<span style="color: #ff0000;">"150"</span> height=<span style="color: #ff0000;">"100"</span> x=<span style="color: #ff0000;">"100"</span> y=<span style="color: #ff0000;">"100"</span><span style="color: #7400FF;">&gt;</span></span></div>
</li>
<li style="font-weight: bold;color:#26536A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #000000;"><span style="color: #7400FF;">&lt;s:stroke</span><span style="color: #7400FF;">&gt;</span></span></div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#3A6A8B;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #000000;"><span style="color: #7400FF;">&lt;mx:SolidColorStroke</span> color=<span style="color: #ff0000;">"#FF0000"</span> weight=<span style="color: #ff0000;">"5"</span><span style="color: #7400FF;">/&gt;</span></span></div>
</li>
<li style="font-weight: bold;color:#26536A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #000000;"><span style="color: #7400FF;">&lt;/s:stroke</span><span style="color: #7400FF;">&gt;</span></span></div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#3A6A8B;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #000000;"><span style="color: #7400FF;">&lt;s:fill</span><span style="color: #7400FF;">&gt;</span></span></div>
</li>
<li style="font-weight: bold;color:#26536A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #000000;"><span style="color: #7400FF;">&lt;mx:SolidColor</span> color=<span style="color: #ff0000;">"#000000"</span><span style="color: #7400FF;">/&gt;</span></span></div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#3A6A8B;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #000000;"><span style="color: #7400FF;">&lt;/s:fill</span><span style="color: #7400FF;">&gt;</span></span></div>
</li>
<li style="font-weight: bold;color:#26536A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; <span style="color: #000000;"><span style="color: #7400FF;">&lt;/s:Rect</span><span style="color: #7400FF;">&gt;</span></span></div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#3A6A8B;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; </div>
</li>
<li style="font-weight: bold;color:#26536A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; <span style="color: #000000;"><span style="color: #7400FF;">&lt;s:Ellipse</span> width=<span style="color: #ff0000;">"100"</span> height=<span style="color: #ff0000;">"150"</span> x=<span style="color: #ff0000;">"50"</span> y=<span style="color: #ff0000;">"50"</span><span style="color: #7400FF;">&gt;</span></span></div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#3A6A8B;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #000000;"><span style="color: #7400FF;">&lt;s:fill</span><span style="color: #7400FF;">&gt;</span></span></div>
</li>
<li style="font-weight: bold;color:#26536A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #000000;"><span style="color: #7400FF;">&lt;mx:RadialGradient</span><span style="color: #7400FF;">&gt;</span></span></div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#3A6A8B;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #000000;"><span style="color: #7400FF;">&lt;mx:GradientEntry</span> color=<span style="color: #ff0000;">"#FF0000"</span> alpha=<span style="color: #ff0000;">"0.5"</span><span style="color: #7400FF;">/&gt;</span></span></div>
</li>
<li style="font-weight: bold;color:#26536A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #000000;"><span style="color: #7400FF;">&lt;mx:GradientEntry</span> color=<span style="color: #ff0000;">"#00FF00"</span> alpha=<span style="color: #ff0000;">"1"</span><span style="color: #7400FF;">/&gt;</span></span></div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#3A6A8B;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #000000;"><span style="color: #7400FF;">&lt;/mx:RadialGradient</span><span style="color: #7400FF;">&gt;</span></span></div>
</li>
<li style="font-weight: bold;color:#26536A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #000000;"><span style="color: #7400FF;">&lt;/s:fill</span><span style="color: #7400FF;">&gt;</span></span></div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#3A6A8B;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; <span style="color: #000000;"><span style="color: #7400FF;">&lt;/s:Ellipse</span><span style="color: #7400FF;">&gt;</span></span></div>
</li>
<li style="font-weight: bold;color:#26536A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; </div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#3A6A8B;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; <span style="color: #000000;"><span style="color: #7400FF;">&lt;s:Line</span> xFrom=<span style="color: #ff0000;">"100"</span> xTo=<span style="color: #ff0000;">"250"</span> yFrom=<span style="color: #ff0000;">"100"</span> yTo=<span style="color: #ff0000;">"250"</span><span style="color: #7400FF;">&gt;</span></span></div>
</li>
<li style="font-weight: bold;color:#26536A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #000000;"><span style="color: #7400FF;">&lt;s:stroke</span><span style="color: #7400FF;">&gt;</span></span></div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#3A6A8B;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #000000;"><span style="color: #7400FF;">&lt;mx:SolidColorStroke</span> color=<span style="color: #ff0000;">"#0000FF"</span> weight=<span style="color: #ff0000;">"10"</span><span style="color: #7400FF;">/&gt;</span></span></div>
</li>
<li style="font-weight: bold;color:#26536A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #000000;"><span style="color: #7400FF;">&lt;/s:stroke</span><span style="color: #7400FF;">&gt;</span></span></div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#3A6A8B;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; <span style="color: #000000;"><span style="color: #7400FF;">&lt;/s:Line</span><span style="color: #7400FF;">&gt;</span></span></div>
</li>
<li style="font-weight: bold;color:#26536A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; </div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#3A6A8B;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;"><span style="color: #000000;"><span style="color: #7400FF;">&lt;/s:Application</span><span style="color: #7400FF;">&gt;</span></span> </div>
</li>
</ol>
</div>
</div>
</div>
<p>
<img src='http://www.madeinflex.com/wp-content/uploads/2009/07/picture-1.png' alt='Formas vectoriales' /></p>
<h4 id="toc-spark-primitives-path">spark.primitives.Path</h4>
<p>	Esta primitiva permite declarar libremente cualquier forma.<br />
	Con <code>Path</code> podemos definir una secuencia de segmentos rectos o circulares para que conformen el perímetro de una forma. Dichos segmentos se asignan desde el atributo <code>segments:Array</code> y pueden ser de los siguientes tipos:</p>
<ul>
<li>spark.primitives.pathSegments.LineSegment</li>
<li>spark.primitives.pathSegments.CubicBezierSegment</li>
<li>spark.primitives.pathSegments.QuadraticBezierSegment</li>
</ul>
<p>	Adicionalmente disponemos de la clase <code>spark.primitives.pathSegments.MoveSegment</code> para mover el punto desde el que se empieza a dibujar.<br />
	Además de poder definir declarativamente la secuencia de segmentos disponemos del atributo <code>data</code>, el cual nos permite pasar un String con notación SVG para que defina dicha secuencia de segmentos.<br />
	Con toda esta versatilidad, la clase <code>Path</code> nos permite obtener el mismo resultado que con las primitivas que se muestran anteriormente y más<br />
	Un ejemplo de uso:</p>
<div class="igBar"><span id="lmxml-64"><a href="#" onclick="javascript:showPlainTxt('mxml-64'); return false;">PLAIN TEXT</a></span></div>
<div class="syntax_hilite"><span class="langName">MXML:</span>
<div id="mxml-64">
<div class="mxml">
<ol>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#3A6A8B;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;"><span style="color: #000000;">&lt;?xml version=<span style="color: #ff0000;">"1.0"</span> encoding=<span style="color: #ff0000;">"utf-8"</span>?<span style="color: #7400FF;">&gt;</span></span></div>
</li>
<li style="font-weight: bold;color:#26536A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;"><span style="color: #000000;"><span style="color: #7400FF;">&lt;s:Application</span> </div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#3A6A8B;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; xmlns:fx=<span style="color: #ff0000;">"http://ns.adobe.com/mxml/2009"</span> </div>
</li>
<li style="font-weight: bold;color:#26536A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; xmlns:mx=<span style="color: #ff0000;">"library://ns.adobe.com/flex/halo"</span> </div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#3A6A8B;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; xmlns:s=<span style="color: #ff0000;">"library://ns.adobe.com/flex/spark"</span><span style="color: #7400FF;">&gt;</span></span></div>
</li>
<li style="font-weight: bold;color:#26536A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp;</div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#3A6A8B;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; <span style="color: #000000;"><span style="color: #7400FF;">&lt;s:Path</span><span style="color: #7400FF;">&gt;</span></span></div>
</li>
<li style="font-weight: bold;color:#26536A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #000000;"><span style="color: #7400FF;">&lt;s:segments</span><span style="color: #7400FF;">&gt;</span></span></div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#3A6A8B;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #000000;"><span style="color: #7400FF;">&lt;s:MoveSegment</span> x=<span style="color: #ff0000;">"100"</span> y=<span style="color: #ff0000;">"100"</span><span style="color: #7400FF;">/&gt;</span></span></div>
</li>
<li style="font-weight: bold;color:#26536A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #000000;"><span style="color: #7400FF;">&lt;s:LineSegment</span> x=<span style="color: #ff0000;">"200"</span> y=<span style="color: #ff0000;">"100"</span><span style="color: #7400FF;">/&gt;</span></span></div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#3A6A8B;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #000000;"><span style="color: #7400FF;">&lt;s:LineSegment</span> x=<span style="color: #ff0000;">"200"</span> y=<span style="color: #ff0000;">"200"</span><span style="color: #7400FF;">/&gt;</span></span></div>
</li>
<li style="font-weight: bold;color:#26536A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #000000;"><span style="color: #7400FF;">&lt;s:LineSegment</span> x=<span style="color: #ff0000;">"100"</span> y=<span style="color: #ff0000;">"200"</span><span style="color: #7400FF;">/&gt;</span></span></div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#3A6A8B;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #000000;"><span style="color: #7400FF;">&lt;s:CubicBezierSegment</span> control1X=<span style="color: #ff0000;">"50"</span> control1Y=<span style="color: #ff0000;">"175"</span> control2X=<span style="color: #ff0000;">"50"</span> control2Y=<span style="color: #ff0000;">"125"</span> x=<span style="color: #ff0000;">"100"</span> y=<span style="color: #ff0000;">"100"</span><span style="color: #7400FF;">/&gt;</span></span></div>
</li>
<li style="font-weight: bold;color:#26536A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #000000;"><span style="color: #7400FF;">&lt;/s:segments</span><span style="color: #7400FF;">&gt;</span></span></div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#3A6A8B;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #000000;"><span style="color: #7400FF;">&lt;s:stroke</span><span style="color: #7400FF;">&gt;</span></span></div>
</li>
<li style="font-weight: bold;color:#26536A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #000000;"><span style="color: #7400FF;">&lt;s:Stroke</span> color=<span style="color: #ff0000;">"0x888888"</span><span style="color: #7400FF;">/&gt;</span></span></div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#3A6A8B;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #000000;"><span style="color: #7400FF;">&lt;/s:stroke</span><span style="color: #7400FF;">&gt;</span></span></div>
</li>
<li style="font-weight: bold;color:#26536A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; <span style="color: #000000;"><span style="color: #7400FF;">&lt;/s:Path</span><span style="color: #7400FF;">&gt;</span></span></div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#3A6A8B;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp;</div>
</li>
<li style="font-weight: bold;color:#26536A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; <span style="color: #000000;"><span style="color: #7400FF;">&lt;s:Path</span><span style="color: #7400FF;">&gt;</span></span></div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#3A6A8B;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #000000;"><span style="color: #7400FF;">&lt;s:data</span><span style="color: #7400FF;">&gt;</span></span></div>
</li>
<li style="font-weight: bold;color:#26536A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; M 50 50</div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#3A6A8B;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; L 150 50</div>
</li>
<li style="font-weight: bold;color:#26536A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; L 150 150</div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#3A6A8B;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; L 50 150</div>
</li>
<li style="font-weight: bold;color:#26536A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; C 0 125 0 75 50 50</div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#3A6A8B;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #000000;"><span style="color: #7400FF;">&lt;/s:data</span><span style="color: #7400FF;">&gt;</span></span></div>
</li>
<li style="font-weight: bold;color:#26536A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #000000;"><span style="color: #7400FF;">&lt;s:stroke</span><span style="color: #7400FF;">&gt;</span></span></div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#3A6A8B;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #000000;"><span style="color: #7400FF;">&lt;s:Stroke</span> color=<span style="color: #ff0000;">"0xFF0000"</span> weight=<span style="color: #ff0000;">"10"</span><span style="color: #7400FF;">/&gt;</span></span></div>
</li>
<li style="font-weight: bold;color:#26536A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #000000;"><span style="color: #7400FF;">&lt;/s:stroke</span><span style="color: #7400FF;">&gt;</span></span></div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#3A6A8B;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; <span style="color: #000000;"><span style="color: #7400FF;">&lt;/s:Path</span><span style="color: #7400FF;">&gt;</span></span></div>
</li>
<li style="font-weight: bold;color:#26536A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; </div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#3A6A8B;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;"><span style="color: #000000;"><span style="color: #7400FF;">&lt;/s:Application</span><span style="color: #7400FF;">&gt;</span></span> </div>
</li>
</ol>
</div>
</div>
</div>
<p>
<img src='http://www.madeinflex.com/wp-content/uploads/2009/07/picture-2.png' alt='Path' /></p>
<h3 id="toc-spark-primitives-bitmapimage">spark.primitives.BitmapImage</h3>
<p>Esta primitiva nos permite cargar un bitmap en una superficie rectangular. El bitmap puede ocupar una porción, la totalidad o incluso más de la superficie disponible. Adicionalmente se puede controlar si el bitmap se escala o no y si se repite a lo largo de la superficie.<br />
Un ejemplo:</p>
<div class="igBar"><span id="lmxml-65"><a href="#" onclick="javascript:showPlainTxt('mxml-65'); return false;">PLAIN TEXT</a></span></div>
<div class="syntax_hilite"><span class="langName">MXML:</span>
<div id="mxml-65">
<div class="mxml">
<ol>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#3A6A8B;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;"><span style="color: #000000;">&lt;?xml version=<span style="color: #ff0000;">"1.0"</span> encoding=<span style="color: #ff0000;">"utf-8"</span>?<span style="color: #7400FF;">&gt;</span></span></div>
</li>
<li style="font-weight: bold;color:#26536A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;"><span style="color: #000000;"><span style="color: #7400FF;">&lt;s:Application</span> </div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#3A6A8B;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; xmlns:fx=<span style="color: #ff0000;">"http://ns.adobe.com/mxml/2009"</span> </div>
</li>
<li style="font-weight: bold;color:#26536A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; xmlns:mx=<span style="color: #ff0000;">"library://ns.adobe.com/flex/halo"</span> </div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#3A6A8B;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; xmlns:s=<span style="color: #ff0000;">"library://ns.adobe.com/flex/spark"</span><span style="color: #7400FF;">&gt;</span></span></div>
</li>
<li style="font-weight: bold;color:#26536A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp;</div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#3A6A8B;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; <span style="color: #000000;"><span style="color: #7400FF;">&lt;s:Graphic</span> x=<span style="color: #ff0000;">"10"</span> y=<span style="color: #ff0000;">"10"</span><span style="color: #7400FF;">&gt;</span></span>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;</div>
</li>
<li style="font-weight: bold;color:#26536A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #000000;"><span style="color: #7400FF;">&lt;s:BitmapImage</span> source=<span style="color: #ff0000;">"@Embed('/mif_logo.png')"</span><span style="color: #7400FF;">/&gt;</span></span></div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#3A6A8B;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; <span style="color: #000000;"><span style="color: #7400FF;">&lt;/s:Graphic</span><span style="color: #7400FF;">&gt;</span></span></div>
</li>
<li style="font-weight: bold;color:#26536A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp;&nbsp; &nbsp; </div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#3A6A8B;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; <span style="color: #000000;"><span style="color: #7400FF;">&lt;s:Graphic</span> x=<span style="color: #ff0000;">"10"</span> y=<span style="color: #ff0000;">"101"</span><span style="color: #7400FF;">&gt;</span></span></div>
</li>
<li style="font-weight: bold;color:#26536A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #000000;"><span style="color: #7400FF;">&lt;s:BitmapImage</span> source=<span style="color: #ff0000;">"@Embed('/mif_logo.png')"</span> width=<span style="color: #ff0000;">"600"</span> height=<span style="color: #ff0000;">"100"</span> resizeMode=<span style="color: #ff0000;">"scale"</span> alpha=<span style="color: #ff0000;">"0.8"</span><span style="color: #7400FF;">/&gt;</span></span></div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#3A6A8B;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; <span style="color: #000000;"><span style="color: #7400FF;">&lt;/s:Graphic</span><span style="color: #7400FF;">&gt;</span></span></div>
</li>
<li style="font-weight: bold;color:#26536A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; </div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#3A6A8B;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; <span style="color: #000000;"><span style="color: #7400FF;">&lt;s:Graphic</span> x=<span style="color: #ff0000;">"10"</span> y=<span style="color: #ff0000;">"211"</span><span style="color: #7400FF;">&gt;</span></span></div>
</li>
<li style="font-weight: bold;color:#26536A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #000000;"><span style="color: #7400FF;">&lt;s:BitmapImage</span> source=<span style="color: #ff0000;">"@Embed('/mif_logo.png')"</span> width=<span style="color: #ff0000;">"432"</span> height=<span style="color: #ff0000;">"162"</span> repeat=<span style="color: #ff0000;">"true"</span> alpha=<span style="color: #ff0000;">"0.5"</span><span style="color: #7400FF;">/&gt;</span></span></div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#3A6A8B;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; <span style="color: #000000;"><span style="color: #7400FF;">&lt;/s:Graphic</span><span style="color: #7400FF;">&gt;</span></span></div>
</li>
<li style="font-weight: bold;color:#26536A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp;</div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#3A6A8B;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;"><span style="color: #000000;"><span style="color: #7400FF;">&lt;/s:Application</span><span style="color: #7400FF;">&gt;</span></span> </div>
</li>
</ol>
</div>
</div>
</div>
<p>
<img src='http://www.madeinflex.com/wp-content/uploads/2009/07/picture-3.png' alt='BitmapImage' /></p>
<h3 id="toc-texto">Texto</h3>
<p>	FXG proporciona dos primitivas para tratar zonas de contenido textual:</p>
<ul>
<li>spark.primitives.RichText</li>
<li>spark.primitives.SimpleText</li>
</ul>
<p>	<code>RichText</code> es para definir texto rico, en el cuál se pueden renderizar distintos tipos de formatos a la vez, distintos tipos de elementos como imágenes, texto, etc...<br />
	Esta clase saca partido del <acronym title="Flash Text Engine">FTE</acronym> (Flash Text Engine) a través del <acronym title="Text Layout Framework">TLF</acronym> (<a href="http://labs.adobe.com/technologies/textlayout/">Text Layout Framework</a>). El <acronym title="Flash Text Engine">FTE</acronym> es un conjunto de componentes de bajo nivel existentes en el Flash Player 10 que, a través de sus APIs ActionScript permiten crear por encima implementaciones listas para ser utilizadas como campos de texto, como el <acronym title="Text Layout Framework">TLF</acronym>.<br />
	A través de la propiedad <code>content</code> de <code>RichText</code> se pueden intercalar elementos de texto mezclados con distintos tags que permiten desde asignar formatos a grupos de caracteres hasta intercalar imágenes entre otros grupos de caracteres, etc..<br />
	Estos son los tags soportados:</p>
<ul>
<li>div</li>
<li>p</li>
<li>span</li>
<li>a</li>
<li>img</li>
<li>br</li>
<li>tab</li>
<li>tcy</li>
</ul>
<p>	Cada uno de ellos sopora un conjunto de atributos y permite realizar una serie de operaciones determinadas. Toda esta potencia es, sin duda, un paso de gigante en lo que a renderizado de bloques de texto se refiere.<br />
	<code>SimpleText</code> soporta un solo formato que se aplica a todo el texto. Esta clase ofrece una funcionalidad parecida a la clase <code>mx:Label</code> de la versión 3 de Flex pero con soporte multiline.<br />
	Un ejemplo:</p>
<div class="igBar"><span id="lmxml-66"><a href="#" onclick="javascript:showPlainTxt('mxml-66'); return false;">PLAIN TEXT</a></span></div>
<div class="syntax_hilite"><span class="langName">MXML:</span>
<div id="mxml-66">
<div class="mxml">
<ol>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#3A6A8B;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;"><span style="color: #000000;">&lt;?xml version=<span style="color: #ff0000;">"1.0"</span> encoding=<span style="color: #ff0000;">"utf-8"</span>?<span style="color: #7400FF;">&gt;</span></span></div>
</li>
<li style="font-weight: bold;color:#26536A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;"><span style="color: #000000;"><span style="color: #7400FF;">&lt;s:Application</span> </div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#3A6A8B;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; xmlns:fx=<span style="color: #ff0000;">"http://ns.adobe.com/mxml/2009"</span> </div>
</li>
<li style="font-weight: bold;color:#26536A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; xmlns:mx=<span style="color: #ff0000;">"library://ns.adobe.com/flex/halo"</span> </div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#3A6A8B;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; xmlns:s=<span style="color: #ff0000;">"library://ns.adobe.com/flex/spark"</span><span style="color: #7400FF;">&gt;</span></span></div>
</li>
<li style="font-weight: bold;color:#26536A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; </div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#3A6A8B;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; <span style="color: #000000;"><span style="color: #7400FF;">&lt;s:RichText</span> x=<span style="color: #ff0000;">"100"</span> y=<span style="color: #ff0000;">"100"</span> fontFamily=<span style="color: #ff0000;">"Arial"</span> fontSize=<span style="color: #ff0000;">"16"</span> width=<span style="color: #ff0000;">"200"</span><span style="color: #7400FF;">&gt;</span></span></div>
</li>
<li style="font-weight: bold;color:#26536A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #000000;"><span style="color: #7400FF;">&lt;s:content</span><span style="color: #7400FF;">&gt;</span></span></div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#3A6A8B;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; Lorem <span style="color: #000000;"><span style="color: #7400FF;">&lt;s:span</span> fontWeight=<span style="color: #ff0000;">"bold"</span> color=<span style="color: #ff0000;">"#FF0000"</span><span style="color: #7400FF;">&gt;</span></span>Ipsum<span style="color: #000000;"><span style="color: #7400FF;">&lt;/s:span</span><span style="color: #7400FF;">&gt;</span></span> dolor sit amet, </div>
</li>
<li style="font-weight: bold;color:#26536A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #000000;"><span style="color: #7400FF;">&lt;s:img</span> source=<span style="color: #ff0000;">"@Embed('/comment.png')"</span> width=<span style="color: #ff0000;">"16"</span> height=<span style="color: #ff0000;">"16"</span><span style="color: #7400FF;">/&gt;</span></span> consectetur </div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#3A6A8B;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; adipiscing elit. Aliquam <span style="color: #000000;"><span style="color: #7400FF;">&lt;s:img</span> source=<span style="color: #ff0000;">"@Embed('/search.png')"</span> width=<span style="color: #ff0000;">"16"</span> height=<span style="color: #ff0000;">"16"</span><span style="color: #7400FF;">/&gt;</span></span></div>
</li>
<li style="font-weight: bold;color:#26536A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; sodales magna vel nisl fermentum vel gravida orci bibendum.<span style="color: #000000;"><span style="color: #7400FF;">&lt;s:br</span> <span style="color: #7400FF;">/&gt;</span></span> Quisque accumsan </div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#3A6A8B;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; ultrices lacus id <span style="color: #000000;"><span style="color: #7400FF;">&lt;s:span</span> fontStyle=<span style="color: #ff0000;">"italic"</span><span style="color: #7400FF;">&gt;</span></span>sollicitudin<span style="color: #000000;"><span style="color: #7400FF;">&lt;/s:span</span><span style="color: #7400FF;">&gt;</span></span>. Vivamus fermentum </div>
</li>
<li style="font-weight: bold;color:#26536A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; tortor a odiodapibus <span style="color: #000000;"><span style="color: #7400FF;">&lt;s:img</span> source=<span style="color: #ff0000;">"@Embed('/warning.png')"</span> width=<span style="color: #ff0000;">"16"</span> height=<span style="color: #ff0000;">"16"</span><span style="color: #7400FF;">/&gt;</span></span> </div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#3A6A8B;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; id posuere augue congue. Morbi ultricies felis a elit adipiscing dignissim.</div>
</li>
<li style="font-weight: bold;color:#26536A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #000000;"><span style="color: #7400FF;">&lt;/s:content</span><span style="color: #7400FF;">&gt;</span></span></div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#3A6A8B;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; <span style="color: #000000;"><span style="color: #7400FF;">&lt;/s:RichText</span><span style="color: #7400FF;">&gt;</span></span></div>
</li>
<li style="font-weight: bold;color:#26536A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; </div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#3A6A8B;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; <span style="color: #000000;"><span style="color: #7400FF;">&lt;s:SimpleText</span> x=<span style="color: #ff0000;">"350"</span> y=<span style="color: #ff0000;">"100"</span> width=<span style="color: #ff0000;">"200"</span> fontSize=<span style="color: #ff0000;">"12"</span> fontFamily=<span style="color: #ff0000;">"Verdana"</span><span style="color: #7400FF;">&gt;</span></span></div>
</li>
<li style="font-weight: bold;color:#26536A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #000000;"><span style="color: #7400FF;">&lt;s:text</span><span style="color: #7400FF;">&gt;</span></span><span style="color: #000000;">&lt;!<span style="color: #66cc66;">&#91;</span>CDATA<span style="color: #66cc66;">&#91;</span>Lorem ipsum dolor sit amet, <span style="color: #ff0000;">"consectetur"</span> adipiscing elit.&lt;br<span style="color: #7400FF;">/&gt;</span></span>Aliquam sodales magna vel nisl fermentum vel gravida orci bibendum.<span style="color: #000000;">&lt;br<span style="color: #7400FF;">/&gt;</span></span>Quisque accumsan ultrices lacus idsollicitudin.]]&gt;<span style="color: #000000;"><span style="color: #7400FF;">&lt;/s:text</span><span style="color: #7400FF;">&gt;</span></span></div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#3A6A8B;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; <span style="color: #000000;"><span style="color: #7400FF;">&lt;/s:SimpleText</span><span style="color: #7400FF;">&gt;</span></span></div>
</li>
<li style="font-weight: bold;color:#26536A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp;</div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#3A6A8B;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;"><span style="color: #000000;"><span style="color: #7400FF;">&lt;/s:Application</span><span style="color: #7400FF;">&gt;</span></span> </div>
</li>
</ol>
</div>
</div>
</div>
<p>
<img src='http://www.madeinflex.com/wp-content/uploads/2009/07/picture-4.png' alt='RichText y SimpleText' /></p>
<h3 id="toc-spark-components-group">spark.components.Group</h3>
<p>La clase <code>Group</code> permite agrupar elementos en un lienzo con origen de coordenadas propio. Por defecto utiliza layout de posicionamiento absoluto que puede cambiarse en tiempo de ejecución por cualquier otro tipo de layout, ya sea uno de los disponibles en Spark o uno personalizado por nosotros mismos.<br />
Se dispone de las subclases <code>VGroup</code> y <code>HGroup</code> para trabajar con layout vertical y horizontal respectivamente.</p>
<div class="igBar"><span id="lmxml-67"><a href="#" onclick="javascript:showPlainTxt('mxml-67'); return false;">PLAIN TEXT</a></span></div>
<div class="syntax_hilite"><span class="langName">MXML:</span>
<div id="mxml-67">
<div class="mxml">
<ol>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#3A6A8B;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;"><span style="color: #000000;">&lt;?xml version=<span style="color: #ff0000;">"1.0"</span> encoding=<span style="color: #ff0000;">"utf-8"</span>?<span style="color: #7400FF;">&gt;</span></span></div>
</li>
<li style="font-weight: bold;color:#26536A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;"><span style="color: #000000;"><span style="color: #7400FF;">&lt;s:Application</span> </div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#3A6A8B;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; xmlns:fx=<span style="color: #ff0000;">"http://ns.adobe.com/mxml/2009"</span> </div>
</li>
<li style="font-weight: bold;color:#26536A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; xmlns:mx=<span style="color: #ff0000;">"library://ns.adobe.com/flex/halo"</span> </div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#3A6A8B;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; xmlns:s=<span style="color: #ff0000;">"library://ns.adobe.com/flex/spark"</span><span style="color: #7400FF;">&gt;</span></span></div>
</li>
<li style="font-weight: bold;color:#26536A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; </div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#3A6A8B;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; <span style="color: #000000;"><span style="color: #7400FF;">&lt;s:Group</span> x=<span style="color: #ff0000;">"100"</span> y=<span style="color: #ff0000;">"100"</span> width=<span style="color: #ff0000;">"100"</span> height=<span style="color: #ff0000;">"100"</span><span style="color: #7400FF;">&gt;</span></span></div>
</li>
<li style="font-weight: bold;color:#26536A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #000000;"><span style="color: #7400FF;">&lt;s:Rect</span> width=<span style="color: #ff0000;">"100%"</span> height=<span style="color: #ff0000;">"100%"</span><span style="color: #7400FF;">&gt;</span></span></div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#3A6A8B;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #000000;"><span style="color: #7400FF;">&lt;s:stroke</span><span style="color: #7400FF;">&gt;</span></span></div>
</li>
<li style="font-weight: bold;color:#26536A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #000000;"><span style="color: #7400FF;">&lt;mx:SolidColorStroke</span> color=<span style="color: #ff0000;">"#FF0000"</span> weight=<span style="color: #ff0000;">"5"</span><span style="color: #7400FF;">/&gt;</span></span></div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#3A6A8B;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #000000;"><span style="color: #7400FF;">&lt;/s:stroke</span><span style="color: #7400FF;">&gt;</span></span></div>
</li>
<li style="font-weight: bold;color:#26536A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #000000;"><span style="color: #7400FF;">&lt;s:fill</span><span style="color: #7400FF;">&gt;</span></span></div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#3A6A8B;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #000000;"><span style="color: #7400FF;">&lt;mx:SolidColor</span> color=<span style="color: #ff0000;">"#00FF00"</span><span style="color: #7400FF;">/&gt;</span></span></div>
</li>
<li style="font-weight: bold;color:#26536A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #000000;"><span style="color: #7400FF;">&lt;/s:fill</span><span style="color: #7400FF;">&gt;</span></span></div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#3A6A8B;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #000000;"><span style="color: #7400FF;">&lt;/s:Rect</span><span style="color: #7400FF;">&gt;</span></span></div>
</li>
<li style="font-weight: bold;color:#26536A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; <span style="color: #000000;"><span style="color: #7400FF;">&lt;/s:Group</span><span style="color: #7400FF;">&gt;</span></span></div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#3A6A8B;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; </div>
</li>
<li style="font-weight: bold;color:#26536A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; <span style="color: #000000;"><span style="color: #7400FF;">&lt;s:Group</span> x=<span style="color: #ff0000;">"150"</span> y=<span style="color: #ff0000;">"150"</span><span style="color: #7400FF;">&gt;</span></span></div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#3A6A8B;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #000000;"><span style="color: #7400FF;">&lt;s:Rect</span> width=<span style="color: #ff0000;">"150"</span> height=<span style="color: #ff0000;">"150"</span><span style="color: #7400FF;">&gt;</span></span></div>
</li>
<li style="font-weight: bold;color:#26536A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #000000;"><span style="color: #7400FF;">&lt;s:stroke</span><span style="color: #7400FF;">&gt;</span></span></div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#3A6A8B;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #000000;"><span style="color: #7400FF;">&lt;mx:SolidColorStroke</span> color=<span style="color: #ff0000;">"#000000"</span> weight=<span style="color: #ff0000;">"5"</span><span style="color: #7400FF;">/&gt;</span></span></div>
</li>
<li style="font-weight: bold;color:#26536A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #000000;"><span style="color: #7400FF;">&lt;/s:stroke</span><span style="color: #7400FF;">&gt;</span></span></div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#3A6A8B;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #000000;"><span style="color: #7400FF;">&lt;s:fill</span><span style="color: #7400FF;">&gt;</span></span></div>
</li>
<li style="font-weight: bold;color:#26536A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #000000;"><span style="color: #7400FF;">&lt;mx:SolidColor</span> color=<span style="color: #ff0000;">"#0000FF"</span><span style="color: #7400FF;">/&gt;</span></span></div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#3A6A8B;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #000000;"><span style="color: #7400FF;">&lt;/s:fill</span><span style="color: #7400FF;">&gt;</span></span></div>
</li>
<li style="font-weight: bold;color:#26536A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #000000;"><span style="color: #7400FF;">&lt;/s:Rect</span><span style="color: #7400FF;">&gt;</span></span></div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#3A6A8B;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; <span style="color: #000000;"><span style="color: #7400FF;">&lt;/s:Group</span><span style="color: #7400FF;">&gt;</span></span></div>
</li>
<li style="font-weight: bold;color:#26536A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; </div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#3A6A8B;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;"><span style="color: #000000;"><span style="color: #7400FF;">&lt;/s:Application</span><span style="color: #7400FF;">&gt;</span></span> </div>
</li>
</ol>
</div>
</div>
</div>
<p>
<img src='http://www.madeinflex.com/wp-content/uploads/2009/07/picture-5.png' alt='Group' /></p>
<h2 id="toc-library">Library</h2>
<p>El concepto de librería y símbolo no es nada nuevo dentro del mundo Flash, de hecho has sido un pilar para la evolución de la tecnología y para ayudar a introducir los coneptos de de clase e instancia de  <acronym title="Programación Orientada a Objetos">POO</acronym> a todos los usuarios no programadores de Flash.<br />
Flex 4 se sirve nuevamente de esta metáfora a través del tag <code>Library</code> que proporciona el espacio de nombres de lenguaje MXML2009.<br />
En este nodo MXML podemos anidar dentro de un tag <code>Definition</code> cualquier grupo o elemento gráfico a modo de <em>template</em> para ser usado (instanciado) en cualquier lugar del documento tantas veces como se quiera. Es importante notar que los elementos que añadimos en <code>Library</code> quedan accesibles exclusivamente dentro del ámbito del documento MXML que los declara.<br />
Para crear las instancias de cada una de las definiciones utilizaremos el atributo <code>name</code> del <code>Definition</code> que deseemos para referenciar el template de objeto.</p>
<div class="igBar"><span id="lmxml-68"><a href="#" onclick="javascript:showPlainTxt('mxml-68'); return false;">PLAIN TEXT</a></span></div>
<div class="syntax_hilite"><span class="langName">MXML:</span>
<div id="mxml-68">
<div class="mxml">
<ol>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#3A6A8B;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;"><span style="color: #000000;">&lt;?xml version=<span style="color: #ff0000;">"1.0"</span> encoding=<span style="color: #ff0000;">"utf-8"</span>?<span style="color: #7400FF;">&gt;</span></span></div>
</li>
<li style="font-weight: bold;color:#26536A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;"><span style="color: #000000;"><span style="color: #7400FF;">&lt;s:Application</span> </div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#3A6A8B;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; xmlns:fx=<span style="color: #ff0000;">"http://ns.adobe.com/mxml/2009"</span> </div>
</li>
<li style="font-weight: bold;color:#26536A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; xmlns:mx=<span style="color: #ff0000;">"library://ns.adobe.com/flex/halo"</span> </div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#3A6A8B;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; xmlns:s=<span style="color: #ff0000;">"library://ns.adobe.com/flex/spark"</span><span style="color: #7400FF;">&gt;</span></span></div>
</li>
<li style="font-weight: bold;color:#26536A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; </div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#3A6A8B;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; <span style="color: #000000;"><span style="color: #7400FF;">&lt;fx:Library</span><span style="color: #7400FF;">&gt;</span></span></div>
</li>
<li style="font-weight: bold;color:#26536A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #000000;"><span style="color: #7400FF;">&lt;fx:Definition</span> name=<span style="color: #ff0000;">"grupo"</span><span style="color: #7400FF;">&gt;</span></span></div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#3A6A8B;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; &nbsp; &nbsp;&nbsp; &nbsp; &nbsp;<span style="color: #000000;"><span style="color: #7400FF;">&lt;s:Group</span><span style="color: #7400FF;">&gt;</span></span></div>
</li>
<li style="font-weight: bold;color:#26536A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; &nbsp; &nbsp;&nbsp; &nbsp; &nbsp;&nbsp; &nbsp; <span style="color: #000000;"><span style="color: #7400FF;">&lt;s:Rect</span> width=<span style="color: #ff0000;">"150"</span> height=<span style="color: #ff0000;">"150"</span><span style="color: #7400FF;">&gt;</span></span></div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#3A6A8B;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; &nbsp; &nbsp;&nbsp; &nbsp; &nbsp;&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #000000;"><span style="color: #7400FF;">&lt;s:stroke</span><span style="color: #7400FF;">&gt;</span></span></div>
</li>
<li style="font-weight: bold;color:#26536A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; &nbsp; &nbsp;&nbsp; &nbsp; &nbsp;&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #000000;"><span style="color: #7400FF;">&lt;mx:SolidColorStroke</span> color=<span style="color: #ff0000;">"#FF0000"</span> weight=<span style="color: #ff0000;">"5"</span><span style="color: #7400FF;">/&gt;</span></span></div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#3A6A8B;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; &nbsp; &nbsp;&nbsp; &nbsp; &nbsp;&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #000000;"><span style="color: #7400FF;">&lt;/s:stroke</span><span style="color: #7400FF;">&gt;</span></span></div>
</li>
<li style="font-weight: bold;color:#26536A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; &nbsp; &nbsp;&nbsp; &nbsp; &nbsp;&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #000000;"><span style="color: #7400FF;">&lt;s:fill</span><span style="color: #7400FF;">&gt;</span></span></div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#3A6A8B;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; &nbsp; &nbsp;&nbsp; &nbsp; &nbsp;&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #000000;"><span style="color: #7400FF;">&lt;mx:SolidColor</span> color=<span style="color: #ff0000;">"#00FF00"</span><span style="color: #7400FF;">/&gt;</span></span></div>
</li>
<li style="font-weight: bold;color:#26536A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; &nbsp; &nbsp;&nbsp; &nbsp; &nbsp;&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #000000;"><span style="color: #7400FF;">&lt;/s:fill</span><span style="color: #7400FF;">&gt;</span></span></div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#3A6A8B;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; &nbsp; &nbsp;&nbsp; &nbsp; &nbsp;&nbsp; &nbsp; <span style="color: #000000;"><span style="color: #7400FF;">&lt;/s:Rect</span><span style="color: #7400FF;">&gt;</span></span></div>
</li>
<li style="font-weight: bold;color:#26536A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; &nbsp; &nbsp;&nbsp; &nbsp; &nbsp;&nbsp; &nbsp; <span style="color: #000000;"><span style="color: #7400FF;">&lt;s:Ellipse</span> width=<span style="color: #ff0000;">"150"</span> height=<span style="color: #ff0000;">"150"</span><span style="color: #7400FF;">&gt;</span></span></div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#3A6A8B;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #000000;"><span style="color: #7400FF;">&lt;s:stroke</span><span style="color: #7400FF;">&gt;</span></span></div>
</li>
<li style="font-weight: bold;color:#26536A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #000000;"><span style="color: #7400FF;">&lt;mx:SolidColorStroke</span> color=<span style="color: #ff0000;">"#000000"</span> weight=<span style="color: #ff0000;">"5"</span><span style="color: #7400FF;">/&gt;</span></span></div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#3A6A8B;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #000000;"><span style="color: #7400FF;">&lt;/s:stroke</span><span style="color: #7400FF;">&gt;</span></span></div>
</li>
<li style="font-weight: bold;color:#26536A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #000000;"><span style="color: #7400FF;">&lt;/s:Ellipse</span><span style="color: #7400FF;">&gt;</span></span></div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#3A6A8B;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #000000;"><span style="color: #7400FF;">&lt;/s:Group</span><span style="color: #7400FF;">&gt;</span></span></div>
</li>
<li style="font-weight: bold;color:#26536A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #000000;"><span style="color: #7400FF;">&lt;/fx:Definition</span><span style="color: #7400FF;">&gt;</span></span></div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#3A6A8B;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; <span style="color: #000000;"><span style="color: #7400FF;">&lt;/fx:Library</span><span style="color: #7400FF;">&gt;</span></span></div>
</li>
<li style="font-weight: bold;color:#26536A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; </div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#3A6A8B;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; <span style="color: #000000;"><span style="color: #7400FF;">&lt;fx:grupo</span> x=<span style="color: #ff0000;">"100"</span> y=<span style="color: #ff0000;">"100"</span><span style="color: #7400FF;">/&gt;</span></span></div>
</li>
<li style="font-weight: bold;color:#26536A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; <span style="color: #000000;"><span style="color: #7400FF;">&lt;fx:grupo</span> x=<span style="color: #ff0000;">"150"</span> y=<span style="color: #ff0000;">"150"</span> alpha=<span style="color: #ff0000;">"0.5"</span><span style="color: #7400FF;">/&gt;</span></span></div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#3A6A8B;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; &nbsp; &nbsp; </div>
</li>
<li style="font-weight: bold;color:#26536A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;"><span style="color: #000000;"><span style="color: #7400FF;">&lt;/s:Application</span><span style="color: #7400FF;">&gt;</span></span> </div>
</li>
</ol>
</div>
</div>
</div>
<p>
<img src='http://www.madeinflex.com/wp-content/uploads/2009/07/picture-6.png' alt='Library' /></p>
<h2 id="toc-conclusion">Conclusión</h2>
<p>FXG es una especificación muy potente que ofrece a la plataforma Flash una herramienta a medida para intercambiar gráficos entre distintas aplicaciones. Además, a través de la implementación que Flex 4 lleva en el espacio de nom bres Spark, proporciona una versatilidad nunca vista antes ( bueno si.. ver <a href="http://www.degrafa.org/">Degrafa</a> <img src='http://www.madeinflex.com/wp-includes/images/smilies/icon_smile.gif' alt=':)' class='wp-smiley' />  ) a la hora de declarar interfaces.<br />
Gracias a FXG el workflow designer/developer nunca más va a ser un obstáculo para llevar la tecnología a los más altos niveles de perfección gráfica.</p>]]></content:encoded>
			<wfw:commentRss>http://www.madeinflex.com/2009/07/18/fx4-iii-fxg-10/feed/</wfw:commentRss>
		<slash:comments>5</slash:comments>
		</item>
		<item>
		<title>Flex y SEO</title>
		<link>http://www.madeinflex.com/2009/06/29/flex-y-seo/</link>
		<comments>http://www.madeinflex.com/2009/06/29/flex-y-seo/#comments</comments>
		<pubDate>Mon, 29 Jun 2009 12:44:34 +0000</pubDate>
		<dc:creator>Carlos Rovira</dc:creator>
				<category><![CDATA[Artículos]]></category>
		<category><![CDATA[Eventos]]></category>
		<category><![CDATA[Recursos]]></category>
		<category><![CDATA[Tutoriales]]></category>

		<guid isPermaLink="false">http://www.madeinflex.com/2009/06/29/flex-y-seo/</guid>
		<description><![CDATA[<!-- matched  --><!-- final 0 -->A continuación la presentación sobre Flex + SEO que Gonzalo Pezzi y yo dimos es la última reunión de MIF en Barcelona con motivo del Adobe Global Tour 2009.
La presentación trata sobre como tener los mismos beneficios que ya disfrutábamos con webs HTML tradicionales aplicados a una web Flex. Es decir, que el contenido sea [...]]]></description>
			<content:encoded><![CDATA[<!-- matched  --><!-- final 0 --><p>A continuación la presentación sobre <a href='http://www.madeinflex.com/wp-content/uploads/2009/06/flexsearchfriendly_preso.pdf' title='Flex y SEO'>Flex + SEO</a> que <strong>Gonzalo Pezzi</strong> y yo dimos es la última reunión de <strong>MIF</strong> en Barcelona con motivo del <strong>Adobe Global Tour 2009</strong>.</p>
<p>La presentación trata sobre como tener los mismos beneficios que ya disfrutábamos con webs HTML tradicionales aplicados a una web Flex. Es decir, que el contenido sea indexable por buscadores, enlaces de profundidad ha contenidos, que tengamos habilitados los botones del navegador para ir adelante o atrás por las páginas de la web Flex y otros temas adicionales como es el multidioma, por poner un ejemplo.</p>
<p>La presentación se basa en la nueva web de <a href="http://www.codeoscopic.com">Codeoscopic</a> donde se implementan todos estos conceptos y que todavía estamos terminando de completar pero que ya vuestra a nivel técnico todas estas posibilidades.</p>
<p>También y como se anunció al final de la charla, pretendemos hacer la base de esta plataforma Open Source de forma que Codeoscopic empiece a realizar aportes a la comunidad dentro del ámbito OS.</p>
<div align="center"><a href='http://www.madeinflex.com/wp-content/uploads/2009/06/flexsearchfriendly_preso.pdf' title='Flex y SEO'><img src='http://www.madeinflex.com/wp-content/uploads/2009/06/flexseo.jpg' alt='Flex + SEO' /></a></div>]]></content:encoded>
			<wfw:commentRss>http://www.madeinflex.com/2009/06/29/flex-y-seo/feed/</wfw:commentRss>
		<slash:comments>2</slash:comments>
		</item>
		<item>
		<title>Fx4 I: Espacios de nombre</title>
		<link>http://www.madeinflex.com/2009/06/28/fx4-i-espacios-de-nombre/</link>
		<comments>http://www.madeinflex.com/2009/06/28/fx4-i-espacios-de-nombre/#comments</comments>
		<pubDate>Sun, 28 Jun 2009 14:13:24 +0000</pubDate>
		<dc:creator>Joan Garnet</dc:creator>
				<category><![CDATA[Flex 4]]></category>
		<category><![CDATA[Tutoriales]]></category>

		<guid isPermaLink="false">http://www.madeinflex.com/2009/06/28/fx4-i-espacios-de-nombre/</guid>
		<description><![CDATA[<!-- matched  --><!-- final 0 -->En esta cuarta versión de Flex se han producido cambios considerables en la arquitectura de componentes así como en el lenguaje MXML. Esto se ha hecho para potenciar varios aspectos como son la productividad, facilitar el workflow designer / developer o la integración con herramientas externas.
En esta entrada se hará una introducción a los espacios [...]]]></description>
			<content:encoded><![CDATA[<!-- matched  --><!-- final 0 --><p>En esta cuarta versión de Flex se han producido cambios considerables en la arquitectura de componentes así como en el lenguaje MXML. Esto se ha hecho para potenciar varios aspectos como son la productividad, facilitar el workflow designer / developer o la integración con herramientas externas.<br />
En esta entrada se hará una introducción a los espacios de nombres de Flex 4.</p>
<p><span id="more-850"></span></p>
<div class="toc">
<ol>
<li><a href="http://www.madeinflex.com/2009/06/28/fx4-i-espacios-de-nombre/#toc-espacios-de-nombre">Espacios de nombre</a></li>
<li><a href="http://www.madeinflex.com/2009/06/28/fx4-i-espacios-de-nombre/#toc-espacios-de-nombre-en-mxml">Espacios de nombre en mxml</a></li>
<li><a href="http://www.madeinflex.com/2009/06/28/fx4-i-espacios-de-nombre/#toc-xmlnsfx-mxml-2009">xmlns:fx: MXML 2009</a></li>
<li><a href="http://www.madeinflex.com/2009/06/28/fx4-i-espacios-de-nombre/#toc-xmlnss-spark">xmlns:s: Spark</a></li>
<li><a href="http://www.madeinflex.com/2009/06/28/fx4-i-espacios-de-nombre/#toc-xmlnsmx-halo">xmlns:mx: Halo</a></li>
<li><a href="http://www.madeinflex.com/2009/06/28/fx4-i-espacios-de-nombre/#toc-mxml-2006">MXML 2006</a></li>
</ol>
</div>
<p>Antes de empezar es interesante aclarar qué es exactamente Flex 4.<br />
Flex 4 no es ni implica una nueva versión de ActionScript o del Flash Player, "simplemente" se ha mejorado la librería Flex y el compilador (y el debugger y el profiler y seguro que otras cosas que no menciono).<br />
Cuando empecemos a trabajar con Flex 4 lo haremos con el mismo runtime; el Flash Player y lenguaje (AS3) que utilizamos en Flex 3. Eso si, mientras que en el caso de Flex 3 podemos optar por trabajar con Flash Player >= 9, con Flex 4 solo podemos trabajar con Flash Player >= 10. Esto es debido a que Flex 4 saca partido de forma generalizada de las nuevas características de Flash Player 10.</p>
<h2 id="toc-espacios-de-nombre">Espacios de nombre</h2>
<p>Un espacio de nombre no es nada nuevo, muchos lenguajes sacan provecho de este concepto de distintas formas. Sin ir más lejos ActionScript 3 tiene dos formas de definir espacios de nombre, una mediante la palabra clave <code>package</code> y otra mediante la palabra clave <code>namespace</code>. Esta última es quizás la más obvia ya que la traducción literal es precisamente "espacio de nombre".<br />
Entonces, ¿qué es un espacio de nombre? pues no es más que un mecanismo de organización que nos permite evitar colisiones entre identificadores. Es gracias a los espacios de nombre que podemos tener una clase llamada <code>miEspacioDeNombre.String</code> sin que colisione con la clase <code>String</code> nativa de ActionScript.</p>
<h2 id="toc-espacios-de-nombre-en-mxml">Espacios de nombre en mxml</h2>
<p>MXML soporta espacios de nombre, de hecho es una característica que en versiones anteriores de Flex ya se utilizaba, aunque en la versión 4 su uso y comprensión son obligados ya que vamos a tener que utilizarlos concienzudamente desde el primer momento.</p>
<p>Cuando creamos un proyecto con Flash Builder 4, el archivo principal tiene este aspecto:</p>
<div class="igBar"><span id="lmxml-70"><a href="#" onclick="javascript:showPlainTxt('mxml-70'); return false;">PLAIN TEXT</a></span></div>
<div class="syntax_hilite"><span class="langName">MXML:</span>
<div id="mxml-70">
<div class="mxml">
<ol>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#3A6A8B;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;"><span style="color: #000000;">&lt;?xml version=<span style="color: #ff0000;">"1.0"</span> encoding=<span style="color: #ff0000;">"utf-8"</span>?<span style="color: #7400FF;">&gt;</span></span></div>
</li>
<li style="font-weight: bold;color:#26536A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;"><span style="color: #000000;"><span style="color: #7400FF;">&lt;s:Application</span> </div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#3A6A8B;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; xmlns:fx=<span style="color: #ff0000;">"http://ns.adobe.com/mxml/2009"</span> </div>
</li>
<li style="font-weight: bold;color:#26536A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; xmlns:s=<span style="color: #ff0000;">"library://ns.adobe.com/flex/spark"</span> </div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#3A6A8B;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; xmlns:mx=<span style="color: #ff0000;">"library://ns.adobe.com/flex/halo"</span><span style="color: #7400FF;">&gt;</span></span></div>
</li>
<li style="font-weight: bold;color:#26536A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; </div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#3A6A8B;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;"><span style="color: #000000;"><span style="color: #7400FF;">&lt;/s:Application</span><span style="color: #7400FF;">&gt;</span></span> </div>
</li>
</ol>
</div>
</div>
</div>
<p>
Este código se diferencia del que se generaba en versiones anteriores en que por defecto utiliza tres declaraciones de espacios de nombre distintas:</p>
<ul>
<li>xmlns:fx="http://ns.adobe.com/mxml/2009"</li>
<li>xmlns:s="library://ns.adobe.com/flex/spark"</li>
<li>xmlns:mx="library://ns.adobe.com/flex/halo"</li>
</ul>
<p>En la gran mayoría de proyectos Flex 4 vamos a utilizar estos tres espacios de nombre, es por eso que están los tres declarados desde los mismos templates de proyecto de Flash Builder.</p>
<h2 id="toc-xmlnsfx-mxml-2009">xmlns:fx: MXML 2009</h2>
<p>Este es un espacio de nombres de lenguaje con el que podremos instanciar tipos nativos del Flash Player como <code>Date</code>, <code>String</code>, <code>Array</code>, etc.. además de poder declarar tags específicos de MXML como <code>Declarations</code>, <code>Metadata</code>, <code>Script</code>, <code>Binding</code>, etc... En este espacio de nombres no encontraremos ningún componente.</p>
<h2 id="toc-xmlnss-spark">xmlns:s: Spark</h2>
<p>Spark es el nombre que se le ha dado al nuevo set de componentes de Flex 4. Spark implica un nuevo set de componentes pero también una nueva arquitectura que, entre otras cosas, es mucho más modular. En este espacio de nombres encontraremos todos los tipos correspondientes a los nuevos componentes como <code>Button</code>, <code>Group</code>, <code>VerticalLayout</code>, etc... Se debe tener en cuenta que no todos los componentes de Flex 3 se han migrado a Flex 4, este trabajo está en proceso todavía, pero como veremos más adelante si nos hace falta no es problema mezclar componentes Spark y componentes Halo (Flex < 4).</p>
<h2 id="toc-xmlnsmx-halo">xmlns:mx: Halo</h2>
<p>Si en Flex 4 queremos por ejemplo utilizar un DataGrid, tendremos que recurrir a este espacio de nombres, ya que el DataGrid es uno de los componentes que no se ha migrado todavía a la arquitectura Spark. La convivencia entre Halo y Spark es uno de los objetivos principales que se marcaron a la hora de plantear esta nueva versión de Flex.</p>
<h2 id="toc-mxml-2006">MXML 2006</h2>
<p>Si queremos trabajar en Flex 4 de la misma forma que lo hacíamos en Flex 3 podemos utilizar el espacio de nombres MXML 2006 ( xmlns:mx="http://www.adobe.com/2006/mxml" ), aunque en este caso no podemos mezclarlo con s (Spark) ni fx (MXML 2009).</p>
<p>Esto es todo lo referente a espacios de nombre que debemos saber en Flex 4.</p>]]></content:encoded>
			<wfw:commentRss>http://www.madeinflex.com/2009/06/28/fx4-i-espacios-de-nombre/feed/</wfw:commentRss>
		<slash:comments>12</slash:comments>
		</item>
		<item>
		<title>Code Behind vs MXML Script Block vs View Helper. Conclusiones de los patrones de presentación</title>
		<link>http://www.madeinflex.com/2009/06/10/code-behind-vs-mxml-script-block-vs-view-helper-conclusiones-de-los-patrones-de-presentacion/</link>
		<comments>http://www.madeinflex.com/2009/06/10/code-behind-vs-mxml-script-block-vs-view-helper-conclusiones-de-los-patrones-de-presentacion/#comments</comments>
		<pubDate>Wed, 10 Jun 2009 08:59:07 +0000</pubDate>
		<dc:creator>Sergi Dote Teixidor</dc:creator>
				<category><![CDATA[Artículos]]></category>
		<category><![CDATA[Tutoriales]]></category>

		<guid isPermaLink="false">http://www.madeinflex.com/2009/06/10/code-behind-vs-mxml-script-block-vs-view-helper-conclusiones-de-los-patrones-de-presentacion/</guid>
		<description><![CDATA[<!-- matched  --><!-- final 0 -->Sobre la pregunta de donde colocar el código relacionado a un fichero MXML, seguramente, las tres soluciones más utilizadas en el mundo Flex son code behind, script blocks o view helper.

Un script block es la parte de código ActionScript que se coloca entre los tags .
Ya hemos visto la definición de view helper, pero para [...]]]></description>
			<content:encoded><![CDATA[<!-- matched  --><!-- final 0 --><p>Sobre la pregunta de donde colocar el código relacionado a un fichero MXML, seguramente, las tres soluciones más utilizadas en el mundo Flex son code behind, script blocks o view helper.</p>
<p><span id="more-820"></span></p>
<p>Un script block es la parte de código ActionScript que se coloca entre los tags <mx:Script></mx:Script>.</p>
<p>Ya hemos visto la definición de view helper, pero para resumir podemos decir que es una clase ActionScript a la que un fichero MXML puede llamar y escuchar directamente. Normalmente contiene código relacionado con el fichero MXML y funcionalidades que si no estuviera esta clase irían en el fichero MXML en script blocks. </p>
<p>Code behind también lo hemos visto con anterioridad, pero para dar un resumen de este patrón, podemos decir que es una manera sencilla y rápida de organizar la funcionalidad.  Si movemos el código de un script block a una clase code behind, estamos cambiando la localización de éste y ensuciando la sintaxis para acceder a este código. </p>
<p>Es adecuado poner el código en una clase ActionScript externa, cuando este código no contiene referencias a vistas.<br />
Lo más adecuado es extraer el código a clases que tengan reglas OOP, así serán fáciles de testear y fáciles de acceder. Si cargamos las vistas de funcionalidades, estaremos sobrecargando estas vistas con responsabilidades que no le atañen, y seguramente duplicando código.</p>
<p>La meta es no cargar las vistas con código que no le pertenece o código excesivo.</p>
<p>Ã¢â‚¬Æ’<br />
<strong>CONCLUSIONES</strong></p>
<p>Está comprobado que Flex es capaz de soportar la implementación de cualquiera de los seis patrones presentados. Dicho esto, algunos patrones usan mejor las características de Flex que otros. Tanto Presentation Model  como Supervising Presenter combinan el refactoring de extracción de clase con un uso elegante de los bindings de MXML y los event handlers declarativos. Passive View y Code Behind sacrifican estas características en el beneficio de lograr una mayor separación entre ActionScript / MXML.</p>]]></content:encoded>
			<wfw:commentRss>http://www.madeinflex.com/2009/06/10/code-behind-vs-mxml-script-block-vs-view-helper-conclusiones-de-los-patrones-de-presentacion/feed/</wfw:commentRss>
		<slash:comments>2</slash:comments>
		</item>
	</channel>
</rss>

