<?xml version="1.0" encoding="UTF-8"?>
<?xml-stylesheet type="text/xsl" media="screen" href="/~d/styles/rss2spanishfull.xsl"?><?xml-stylesheet type="text/css" media="screen" href="http://feeds.feedburner.com/~d/styles/itemcontent.css"?><rss 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/" version="2.0">

<channel>
	<title>Desarrollo en Web</title>
	
	<link>http://blogs.antartec.com/desarrolloweb</link>
	<description>Blog sobre desarrollo de aplicaciones web en Java, PHP y JavaScript</description>
	<lastBuildDate>Fri, 19 Mar 2010 16:49:19 +0000</lastBuildDate>
	<generator>http://wordpress.org/?v=2.9.1</generator>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
			<atom10:link xmlns:atom10="http://www.w3.org/2005/Atom" rel="self" type="application/rss+xml" href="http://feeds.feedburner.com/DesarrolloEnWeb" /><feedburner:info xmlns:feedburner="http://rssnamespace.org/feedburner/ext/1.0" uri="desarrolloenweb" /><atom10:link xmlns:atom10="http://www.w3.org/2005/Atom" rel="hub" href="http://pubsubhubbub.appspot.com/" /><feedburner:emailServiceId xmlns:feedburner="http://rssnamespace.org/feedburner/ext/1.0">DesarrolloEnWeb</feedburner:emailServiceId><feedburner:feedburnerHostname xmlns:feedburner="http://rssnamespace.org/feedburner/ext/1.0">http://feedburner.google.com</feedburner:feedburnerHostname><feedburner:feedFlare xmlns:feedburner="http://rssnamespace.org/feedburner/ext/1.0" href="http://www.newsgator.com/ngs/subscriber/subext.aspx?url=http%3A%2F%2Ffeeds.feedburner.com%2FDesarrolloEnWeb" src="http://www.newsgator.com/images/ngsub1.gif">Subscribe with NewsGator</feedburner:feedFlare><feedburner:feedFlare xmlns:feedburner="http://rssnamespace.org/feedburner/ext/1.0" href="http://www.bloglines.com/sub/http://feeds.feedburner.com/DesarrolloEnWeb" src="http://www.bloglines.com/images/sub_modern11.gif">Subscribe with Bloglines</feedburner:feedFlare><feedburner:feedFlare xmlns:feedburner="http://rssnamespace.org/feedburner/ext/1.0" href="http://fusion.google.com/add?feedurl=http%3A%2F%2Ffeeds.feedburner.com%2FDesarrolloEnWeb" src="http://buttons.googlesyndication.com/fusion/add.gif">Subscribe with Google</feedburner:feedFlare><item>
		<title>Combobox JSF con s:convertEnum</title>
		<link>http://blogs.antartec.com/desarrolloweb/2009/10/combobox-jsf-con-sconvertenum/</link>
		<comments>http://blogs.antartec.com/desarrolloweb/2009/10/combobox-jsf-con-sconvertenum/#comments</comments>
		<pubDate>Wed, 07 Oct 2009 23:24:42 +0000</pubDate>
		<dc:creator>Giancarlo Corzo</dc:creator>
				<category><![CDATA[Programación]]></category>
		<category><![CDATA[jsf]]></category>
		<category><![CDATA[Seam]]></category>

		<guid isPermaLink="false">http://blogs.antartec.com/desarrolloweb/?p=249</guid>
		<description><![CDATA[
			
				
			
		
Escribo este post para todos los que alguna vez sufrieron buscando un ejemplo claro y simple de como crear un combobox en base a un Enum en JSF y Seam.
La documentación de Seam (tan clara como el agua) nos nuestra el siguiente ejemplo:

&#60;h:selectOneMenu value=&#34;#{person.honorific}&#34;&#62;
&#60;s:selectItems value=&#34;#{honorifics}&#34; 
             [...]


Sin posts relacionados.]]></description>
			<content:encoded><![CDATA[<div class="tweetmeme_button" style="float: right; margin-left: 10px;">
			<a href="http://api.tweetmeme.com/share?url=http%3A%2F%2Fblogs.antartec.com%2Fdesarrolloweb%2F2009%2F10%2Fcombobox-jsf-con-sconvertenum%2F"><br />
				<img src="http://api.tweetmeme.com/imagebutton.gif?url=http%3A%2F%2Fblogs.antartec.com%2Fdesarrolloweb%2F2009%2F10%2Fcombobox-jsf-con-sconvertenum%2F&amp;source=giancorzo&amp;style=normal&amp;service=bit.ly" height="61" width="50" /><br />
			</a>
		</div>
<p>Escribo este post para todos los que alguna vez sufrieron buscando un ejemplo claro y simple de como crear un combobox en base a un Enum en JSF y Seam.</p>
<p>La <a href="http://docs.jboss.org/seam/2.2.0.GA/reference/en-US/html/controls.html">documentación de Seam</a> (tan clara como el agua) nos nuestra el siguiente ejemplo:</p>

<div class="wp_syntax"><div class="code"><pre class="xml" style="font-family:monospace;"><span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;h:selectOneMenu</span> <span style="color: #000066;">value</span>=<span style="color: #ff0000;">&quot;#{person.honorific}&quot;</span><span style="color: #000000; font-weight: bold;">&gt;</span></span>
<span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;s:selectItems</span> <span style="color: #000066;">value</span>=<span style="color: #ff0000;">&quot;#{honorifics}&quot;</span> </span>
<span style="color: #009900;">                       <span style="color: #000066;">var</span>=<span style="color: #ff0000;">&quot;honorific&quot;</span> </span>
<span style="color: #009900;">                       <span style="color: #000066;">label</span>=<span style="color: #ff0000;">&quot;#{honorific.label}&quot;</span> </span>
<span style="color: #009900;">                       <span style="color: #000066;">noSelectionLabel</span>=<span style="color: #ff0000;">&quot;Please select&quot;</span> <span style="color: #000000; font-weight: bold;">/&gt;</span></span>
   <span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;s:convertEnum</span> <span style="color: #000000; font-weight: bold;">/&gt;</span></span>
<span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;/h:selectOneMenu<span style="color: #000000; font-weight: bold;">&gt;</span></span></span></pre></div></div>

<p>Donde solo muestran el ejemplo puntual sin dar mayor detalle.<br />
Googleando un poco encontré la siguiente <a href="http://shrubbery.mynetgear.net/wiki/Select_lists_with_Seam">página web</a> donde se dan el trabajo de explicar de una manera sencilla como crear el combobox.</p>
<p>En esa página se  muestra el siguiente ejemplo:</p>
<p>XHTML:</p>

<div class="wp_syntax"><div class="code"><pre class="xml" style="font-family:monospace;"><span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;h:selectOneMenu</span> <span style="color: #000066;">id</span>=<span style="color: #ff0000;">&quot;marketStatus&quot;</span> </span>
<span style="color: #009900;">                 <span style="color: #000066;">value</span>=<span style="color: #ff0000;">&quot;#{person.status}&quot;</span></span>
<span style="color: #009900;">                 <span style="color: #000066;">required</span>=<span style="color: #ff0000;">&quot;true&quot;</span><span style="color: #000000; font-weight: bold;">&gt;</span></span>
    <span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;s:selectItems</span> <span style="color: #000066;">value</span>=<span style="color: #ff0000;">&quot;#{enumLists.statusArray}&quot;</span> </span>
<span style="color: #009900;">                   <span style="color: #000066;">var</span>=<span style="color: #ff0000;">&quot;status&quot;</span></span>
<span style="color: #009900;">                   <span style="color: #000066;">label</span>=<span style="color: #ff0000;">&quot;#{status}&quot;</span></span>
<span style="color: #009900;">                   <span style="color: #000066;">noSelectionLabel</span>=<span style="color: #ff0000;">&quot;Select a status...&quot;</span><span style="color: #000000; font-weight: bold;">/&gt;</span></span>
    <span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;s:convertEnum</span><span style="color: #000000; font-weight: bold;">/&gt;</span></span>
<span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;/h:selectOneMenu<span style="color: #000000; font-weight: bold;">&gt;</span></span></span></pre></div></div>

<p>ENUM:</p>

<div class="wp_syntax"><div class="code"><pre class="java" style="font-family:monospace;">@<span style="color: #003399;">Name</span><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">&quot;enumLists&quot;</span><span style="color: #009900;">&#41;</span>
@Scope<span style="color: #009900;">&#40;</span>ScopeType.<span style="color: #006633;">STATELESS</span><span style="color: #009900;">&#41;</span>
<span style="color: #000000; font-weight: bold;">public</span> <span style="color: #000000; font-weight: bold;">class</span> EnumLists <span style="color: #009900;">&#123;</span>
   <span style="color: #000000; font-weight: bold;">public</span> Status<span style="color: #009900;">&#91;</span><span style="color: #009900;">&#93;</span> getStatusArray<span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
     <span style="color: #000000; font-weight: bold;">return</span> Status.<span style="color: #006633;">values</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
   <span style="color: #009900;">&#125;</span>
<span style="color: #009900;">&#125;</span></pre></div></div>

<p>Como se puede ver en el ejemplo han expuesto el Enum como un Seam bean stateless y retornando la lista de valores con status.values().<br />
Para poner un label a cada opción utilizan el toString() del Enum dado que en label colocan label=&#8221;#{status}&#8221;</p>
<p>Como pueden ver hacer un combobox basado en un Enum es bastante sencillo y útil.</p>


<p>Sin posts relacionados.</p><div class="feedflare">
<a href="http://feeds.feedburner.com/~ff/DesarrolloEnWeb?a=wMBpkKpya14:oyGW9qsfzk4:yIl2AUoC8zA"><img src="http://feeds.feedburner.com/~ff/DesarrolloEnWeb?d=yIl2AUoC8zA" border="0"></img></a> <a href="http://feeds.feedburner.com/~ff/DesarrolloEnWeb?a=wMBpkKpya14:oyGW9qsfzk4:qj6IDK7rITs"><img src="http://feeds.feedburner.com/~ff/DesarrolloEnWeb?d=qj6IDK7rITs" border="0"></img></a>
</div>]]></content:encoded>
			<wfw:commentRss>http://blogs.antartec.com/desarrolloweb/2009/10/combobox-jsf-con-sconvertenum/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>BlogDay 2009: Desarrollo Web recomienda</title>
		<link>http://blogs.antartec.com/desarrolloweb/2009/08/blogday-2009/</link>
		<comments>http://blogs.antartec.com/desarrolloweb/2009/08/blogday-2009/#comments</comments>
		<pubDate>Mon, 31 Aug 2009 22:20:50 +0000</pubDate>
		<dc:creator>Giancarlo Corzo</dc:creator>
				<category><![CDATA[Sin categoría]]></category>
		<category><![CDATA[Blog Day 2009]]></category>

		<guid isPermaLink="false">http://blogs.antartec.com/desarrolloweb/?p=236</guid>
		<description><![CDATA[
			
				
			
		
El día de hoy se celebra el día mundial del blog, esto a raíz del parecido entre la fecha 31 de agosto (3108) y la palabra Blog. El movimiento de los blogs ha ido creciendo año tras año y con el tiempo los bloggers se han sumado a publicar sus sitios preferidos.
Es por ello que [...]


Sin posts relacionados.]]></description>
			<content:encoded><![CDATA[<div class="tweetmeme_button" style="float: right; margin-left: 10px;">
			<a href="http://api.tweetmeme.com/share?url=http%3A%2F%2Fblogs.antartec.com%2Fdesarrolloweb%2F2009%2F08%2Fblogday-2009%2F"><br />
				<img src="http://api.tweetmeme.com/imagebutton.gif?url=http%3A%2F%2Fblogs.antartec.com%2Fdesarrolloweb%2F2009%2F08%2Fblogday-2009%2F&amp;source=giancorzo&amp;style=normal&amp;service=bit.ly" height="61" width="50" /><br />
			</a>
		</div>
<p>El día de hoy se celebra el día mundial del blog, esto a raíz del parecido entre la fecha 31 de agosto (3108) y la palabra Blog. El movimiento de los blogs ha ido creciendo año tras año y con el tiempo los bloggers se han sumado a publicar sus sitios preferidos.</p>
<p>Es por ello que el día de hoy el equipo que escribe en Desarrollo Web ha dedicado unas cuantas horas a seleccionar y publicar nuestros blogs preferidos. Es así como -siguiendo la tendencia- nos gustaría contribuir con un listado.</p>
<p>Algunas de estas publicaciones son de Desarrollo Web, otras son de temas genéricos pero a la vez recomendables.</p>
<ul>
<li><a href="http://www.joelonsoftware.com">joelonsoftware</a> de Joel Spolsky.<br />
Tiene muy buenos posts sobre el desarrollo en general y últimamente sobre sus proyectos personales.</li>
<li><a href="http://www.cssblog.es/">CSSBlog</a> de Pedro Corchero Murga.<br />
Lo encontramos hace poco y nos ha ayudado muchísimo ahora que algunos de los miembros del equipo están revisando temas avanzados de CSS.</li>
<li><a href="http://www.codinghorror.com/">Coding horror</a> de Jeff Atwood.<br />
Sus posts más recientes hacen alusión frecuente a la psicología de los programadores.</li>
<li><a href="http://sinergiasincontrol.blogspot.com/">Sinergia sin control</a> de Ender Wiggins.<br />
Es un blog de un comic para frikis muy divertido.</li>
<li><a href="http://onstartups.com">On Startups</a> de Dharmesh Shah.<br />
Lo llevamos seguimos hace un tiempo y consideramos que se trata de un buen blog sobre negocios.</li>
</ul>
<p>Si desean compartir otros blogs que suelen visitar pueden hacer comentarios sobre sus blogs preferidos.</p>


<p>Sin posts relacionados.</p><div class="feedflare">
<a href="http://feeds.feedburner.com/~ff/DesarrolloEnWeb?a=NcSFJRN3hS0:2tHEWHEP0Ik:yIl2AUoC8zA"><img src="http://feeds.feedburner.com/~ff/DesarrolloEnWeb?d=yIl2AUoC8zA" border="0"></img></a> <a href="http://feeds.feedburner.com/~ff/DesarrolloEnWeb?a=NcSFJRN3hS0:2tHEWHEP0Ik:qj6IDK7rITs"><img src="http://feeds.feedburner.com/~ff/DesarrolloEnWeb?d=qj6IDK7rITs" border="0"></img></a>
</div>]]></content:encoded>
			<wfw:commentRss>http://blogs.antartec.com/desarrolloweb/2009/08/blogday-2009/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Frameworks para iPhone</title>
		<link>http://blogs.antartec.com/desarrolloweb/2009/08/frameworks-para-iphone/</link>
		<comments>http://blogs.antartec.com/desarrolloweb/2009/08/frameworks-para-iphone/#comments</comments>
		<pubDate>Tue, 04 Aug 2009 14:41:04 +0000</pubDate>
		<dc:creator>Giancarlo Corzo</dc:creator>
				<category><![CDATA[Frameworks]]></category>
		<category><![CDATA[iphone]]></category>
		<category><![CDATA[jsf]]></category>
		<category><![CDATA[Seam]]></category>
		<category><![CDATA[ui]]></category>

		<guid isPermaLink="false">http://blogs.antartec.com/desarrolloweb/?p=223</guid>
		<description><![CDATA[
			
				
			
		
Hace algunas semanas en Antartec se nos encargó desarrollar una aplicación web piloto, ésto no tendría mucha novedad y/o relevancia como para escribir un post sobre ello, sin embargo el objetivo planteado lo hizo particularmente interesante.
El reto en esta aplicación fue desarrollar una web que se comporte como una aplicación nativa de iPhone y que le [...]


Sin posts relacionados.]]></description>
			<content:encoded><![CDATA[<div class="tweetmeme_button" style="float: right; margin-left: 10px;">
			<a href="http://api.tweetmeme.com/share?url=http%3A%2F%2Fblogs.antartec.com%2Fdesarrolloweb%2F2009%2F08%2Fframeworks-para-iphone%2F"><br />
				<img src="http://api.tweetmeme.com/imagebutton.gif?url=http%3A%2F%2Fblogs.antartec.com%2Fdesarrolloweb%2F2009%2F08%2Fframeworks-para-iphone%2F&amp;source=giancorzo&amp;style=normal&amp;service=bit.ly" height="61" width="50" /><br />
			</a>
		</div>
<p>Hace algunas semanas en <a href="http://www.antartec.com">Antartec</a> se nos encargó desarrollar una aplicación web piloto, ésto no tendría mucha novedad y/o relevancia como para escribir un post sobre ello, sin embargo el objetivo planteado lo hizo particularmente interesante.</p>
<p>El reto en esta aplicación fue desarrollar una web que se comporte como una aplicación nativa de iPhone y que le permita a los usuarios ingresar información en tiempo real al sistema sin encontrarse frente a un computador.</p>
<p>Nuestros esfuerzos se concentraron en expandir nuestro actual framework basado en JSF y SEAM para que soporte el formato iPhone; nuestras investigaciones preliminares dieron frutos y encontramos varios frameworks para simular la apariencia de interfaces nativas en iPhone tales como <a href="http://code.google.com/p/iui">iUI</a> y <a href="http://code.google.com/p/iphone-universal/">UiUI (Universal)</a>.<br />
<span id="more-223"></span><br />
<a href="http://code.google.com/p/iui">iUI</a> desarrollado por Joe Hewitt es un framework bastante maduro que agiliza la construcción de aplicaciones al manejar las vistas, eventos, peticiones y estilos; sin embargo tiene algunas cosas que no son de mi agrado, como por ejemplo:</p>
<ul>
<li>Su funcionamiento está dado por el intercambio de vistas o pseudo páginas que se encuentran definidas en un solo documento HTML y mediante manipulación DOM se muestran o se ocultan, para el caso particular de cargar una vista dinámica ésta tiene que ser obtenida por AJAX y reemplazada en la vista apropiada (Ésto no tiene nada de malo pero no se ajusta 100% al ciclo de vida natural de JSF).</li>
<li>La simulación de las transiciones entre vistas que se utilizan en las aplicaciones nativas de iPhone se muestran con saltos bastante antinaturales, ésto se debe a que utiliza los efectos de CSS3 para realizar las transiciones. Es una lástima que en el Safari para  iPhone estas transiciones se vean bastante mal debido probablemente a la velocidad del procesador de video del equipo.</li>
<li>Para programar para iUI tienes que aprender la manera en que define vistas, cabeceras, botones etc. Para un proyecto corto, en donde no hay mucho tiempo para aprender, ésto se vuelve un impedimento mas que un beneficio (mi opinión es que mantener un esquema de programación conocido facilita la adopción de la tecnología).</li>
</ul>
<p><a href="http://code.google.com/p/iphone-universal/">iPhone Universal UI</a> fue otro framework que evaluamos. Desarrollado por Diego Lafuente, se basa en una serie de CSS que simulan la apariencia de las aplicaciones nativas.</p>
<p>Al respetar las convenciones web <a href="http://code.google.com/p/iphone-universal/">UiUI</a> se perfilaba como uno de los mejores prospectos para nuestro proyecto dado que podía ser adaptado fácilmente al desarrollo de aplicaciones JSF. Sin embargo, a mi modo de ver tiene una gran desventaja para que sea aceptado por las empresas, tiene una licencia GNU Affero General Public License (GNU AGPL 3) en vez de LGPL que no permite utilizarlo para proyectos con fines comerciales.</p>
<p>Dadas estas circunstancias, decidimos crear nuestro propio framework visual para iPhone que utilice todo el poder de los componentes JSF y el templating de Facelets. En una próxima entrega hablaremos más en profundidad sobre los pormenores del framework.</p>


<p>Sin posts relacionados.</p><div class="feedflare">
<a href="http://feeds.feedburner.com/~ff/DesarrolloEnWeb?a=YtyOQN2TerU:hfQKzOq9Bo0:yIl2AUoC8zA"><img src="http://feeds.feedburner.com/~ff/DesarrolloEnWeb?d=yIl2AUoC8zA" border="0"></img></a> <a href="http://feeds.feedburner.com/~ff/DesarrolloEnWeb?a=YtyOQN2TerU:hfQKzOq9Bo0:qj6IDK7rITs"><img src="http://feeds.feedburner.com/~ff/DesarrolloEnWeb?d=qj6IDK7rITs" border="0"></img></a>
</div>]]></content:encoded>
			<wfw:commentRss>http://blogs.antartec.com/desarrolloweb/2009/08/frameworks-para-iphone/feed/</wfw:commentRss>
		<slash:comments>2</slash:comments>
		</item>
		<item>
		<title>Maven en detalle – Parte 3</title>
		<link>http://blogs.antartec.com/desarrolloweb/2009/05/maven-en-detalle-parte-3/</link>
		<comments>http://blogs.antartec.com/desarrolloweb/2009/05/maven-en-detalle-parte-3/#comments</comments>
		<pubDate>Mon, 18 May 2009 22:35:18 +0000</pubDate>
		<dc:creator>Giancarlo Corzo</dc:creator>
				<category><![CDATA[Arquitectura]]></category>
		<category><![CDATA[Maven]]></category>

		<guid isPermaLink="false">http://blogs.antartec.com/desarrolloweb/?p=197</guid>
		<description><![CDATA[
			
				
			
		
Continuando con nuestro artículo anterior hoy hablaremos sobre el manejo de las dependencias e IDEs con soporte de Maven.

Problemática
Hasta antes de la aparición de Maven el manejo de las librerías JAR que utilizaba cada proyecto se hacía de manera manual, las librerías normalmente eran almacenadas junto con el código fuente para que no se perdieran.
Muchos [...]


<strong>Enlaces relacionados</strong><ul><li><a href='http://blogs.antartec.com/desarrolloweb/2009/03/maven-en-detalle-parte-1/' rel='bookmark' title='Permanent Link: Maven en detalle &#8211; Parte 1'>Maven en detalle &#8211; Parte 1</a></li>
<li><a href='http://blogs.antartec.com/desarrolloweb/2009/04/maven-en-detalle-parte-2/' rel='bookmark' title='Permanent Link: Maven en detalle &#8211; Parte 2'>Maven en detalle &#8211; Parte 2</a></li>
</ul>]]></description>
			<content:encoded><![CDATA[<div class="tweetmeme_button" style="float: right; margin-left: 10px;">
			<a href="http://api.tweetmeme.com/share?url=http%3A%2F%2Fblogs.antartec.com%2Fdesarrolloweb%2F2009%2F05%2Fmaven-en-detalle-parte-3%2F"><br />
				<img src="http://api.tweetmeme.com/imagebutton.gif?url=http%3A%2F%2Fblogs.antartec.com%2Fdesarrolloweb%2F2009%2F05%2Fmaven-en-detalle-parte-3%2F&amp;source=giancorzo&amp;style=normal&amp;service=bit.ly" height="61" width="50" /><br />
			</a>
		</div>
<p>Continuando con nuestro <a href="http://blogs.antartec.com/desarrolloweb/2009/04/maven-en-detalle-parte-2/" target="_self">artículo anterior</a> hoy hablaremos sobre el manejo de las dependencias e IDEs con soporte de Maven.</p>
<p><span id="more-197"></span><br />
<strong>Problemática</strong></p>
<p>Hasta antes de la aparición de Maven el manejo de las librerías JAR que utilizaba cada proyecto se hacía de manera manual, las librerías normalmente eran almacenadas junto con el código fuente para que no se perdieran.</p>
<p>Muchos de los proyectos manejaban el mismo conjunto de librerías sin embargo éstas se duplicaban por seguridad y porque normalmente el arquitecto era la única persona que sabía exactamente qué versión de librerías debían ser incluidas en cada uno.</p>
<p>Maven resuelve la mayoría de los problemas de administración de las librerías (JAR) mediante un repositorio centralizado y un mecanismo para la inclusión de dependencias.</p>
<p><strong>¿Qué es una dependencia?</strong></p>
<p>Una dependencia es una referencia en el POM de la librería que se desea incluir en el proyecto. Por ejemplo si deseamos incluir la librería para el manejo de JUnit debemos declararlo de la siguiente manera:</p>

<div class="wp_syntax"><div class="code"><pre class="xml" style="font-family:monospace;"><span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;dependencies<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>
  <span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;dependency<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>
     <span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;groupId<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>junit<span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;/groupId<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>
     <span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;artifactId<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>junit<span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;/artifactId<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>
     <span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;version<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>4.5<span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;/version<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>
  <span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;/dependency<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>
<span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;/dependencies<span style="color: #000000; font-weight: bold;">&gt;</span></span></span></pre></div></div>

<p>Como vimos en el artículo anterior los objetos en el repositorio se identifican mediante 3 tags <strong>groupId:artifactId:version</strong></p>
<p><strong>¿Cómo se estructura el repositorio de Maven?</strong></p>
<p>Maven maneja 3 niveles de repositorio: local, empresarial, global.</p>
<p>El repositorio local normalmente conocido como .m2 se guarda localmente en nuestra pc (En Windows se almacena en &#8220;documents and settings&#8221; y en linux en nuestro &#8220;home&#8221;). Dentro de ella encontramos los JAR, WAR, etc en una jerarquía de carpetas que siguen el mismo concepto <strong>groupId:artifactId:version</strong>.</p>
<p>Veamos un ejemplo de un repositorio local estándar:</p>
<p><img src="http://blogs.antartec.com/desarrolloweb/files/2009/05/maven3.gif" alt="Repositorio M2" /></p>
<p>El repositorio Empresarial tiene la misma estructura que el repositorio local con la diferencia que almacena librerías de uso compartido a nivel de red. Los repositorios empresariales normalmente se utilizan cuando se maneja un equipo de desarrolladores que trabaja sobre un conjunto variado de proyectos, los cuales normalmente tienen interdependencia entre ellos y sus librerías.</p>
<p>Los repositorios globales son repositorios públicos que almacenan librerías de uso compartido, como por ejemplo el repositorio mismo de Maven o el repositorio público de JBoss o maven central.</p>
<p>Cuando el proceso de compilación busca las dependencias del proyecto lo primero que hace es buscarlas en el repositorio local, si no las encuentra recurre a sus repositorios empresariales (definido en un archivo .settings.xml) o de red y en caso de no encontrar ahí los JAR necesarios los busca en los repositorios globales.</p>
<p>Es importante notar que una vez ubicado un JAR en alguno de los repositorios externos Maven inmediatamente lo descarga al repositorio local por lo que si uno desea que siempre se actualice el JAR de los repositorios externos debe incluir –U en el comando (ejemplo mvn clean install –U ).</p>
<p>El uso de repositorios Empresariales está íntimamente ligado al uso de la metodología de integración continua por lo que les recomiendo leer la entrada <a href="http://blogs.antartec.com/desarrolloweb/2008/12/integracion-continua-en-proyectos-de-desarrollo/" target="_self">Integración continua</a>.</p>
<p><strong>Ámbito de las dependencias</strong></p>
<p>Existen seis ámbitos en los que una dependencia puede ser declarada limitando así su transitividad:<br />
<strong>Compile</strong>,  es el ámbito por defecto. Las dependencias están disponibles en el proyecto y en sus proyectos dependientes.<br />
<strong>Provided</strong>, se espera que el JDK, la aplicación o el contenedor provea la dependencia.<br />
<strong>Runtime</strong>, la dependencia no es requerida en tiempo de compilación pero sí para la ejecución.<br />
<strong>Test</strong>, son dependencias que son requeridas solo cuando se compila y ejecuta los test.<br />
<strong>System</strong>, similar a provided pero se le debe indicar el jar que contiene la dependencia<br />
<strong>Import</strong>, (a partir a la version 2.0.9) solo es usado en una dependencia del tipo POM en la sección . Indica que el POM utilizado debe ser remplazado con las dependencias que éste tenga en su sección</p>
<p><strong>Cómo usar maven en Netbeans</strong></p>
<p>En Antartec usamos Netbeans como la plataforma por defecto para el desarrollo de aplicaciones web al proveer de manera integrada la mayoría de componentes necesarios para nuestro trabajo.</p>
<p>Pasos para trabajar en Netbeans con Maven</p>
<p>1.	Instalar Netbeans (Lo pueden desargar de <a href="http://www.netbeans.org" target="_blank">www.netbeans.org</a>)<br />
2.	En el menú seleccionar Herramientas – plugins<br />
3.	En la sección &#8220;Plugins disponibles&#8221; seleccionar el plugin Maven y hacer clic en Instalar.<br />
4.	Reiniciar el netbeans, con eso netbeans reconoce y permite crear proyectos maven desde cero.</p>


<p><strong>Enlaces relacionados</strong><ul><li><a href='http://blogs.antartec.com/desarrolloweb/2009/03/maven-en-detalle-parte-1/' rel='bookmark' title='Permanent Link: Maven en detalle &#8211; Parte 1'>Maven en detalle &#8211; Parte 1</a></li>
<li><a href='http://blogs.antartec.com/desarrolloweb/2009/04/maven-en-detalle-parte-2/' rel='bookmark' title='Permanent Link: Maven en detalle &#8211; Parte 2'>Maven en detalle &#8211; Parte 2</a></li>
</ul></p><div class="feedflare">
<a href="http://feeds.feedburner.com/~ff/DesarrolloEnWeb?a=hkcn_RqjxeI:2IRJfMhoxuA:yIl2AUoC8zA"><img src="http://feeds.feedburner.com/~ff/DesarrolloEnWeb?d=yIl2AUoC8zA" border="0"></img></a> <a href="http://feeds.feedburner.com/~ff/DesarrolloEnWeb?a=hkcn_RqjxeI:2IRJfMhoxuA:qj6IDK7rITs"><img src="http://feeds.feedburner.com/~ff/DesarrolloEnWeb?d=qj6IDK7rITs" border="0"></img></a>
</div>]]></content:encoded>
			<wfw:commentRss>http://blogs.antartec.com/desarrolloweb/2009/05/maven-en-detalle-parte-3/feed/</wfw:commentRss>
		<slash:comments>3</slash:comments>
		</item>
		<item>
		<title>Maven en detalle – Parte 2</title>
		<link>http://blogs.antartec.com/desarrolloweb/2009/04/maven-en-detalle-parte-2/</link>
		<comments>http://blogs.antartec.com/desarrolloweb/2009/04/maven-en-detalle-parte-2/#comments</comments>
		<pubDate>Fri, 24 Apr 2009 19:44:20 +0000</pubDate>
		<dc:creator>Giancarlo Corzo</dc:creator>
				<category><![CDATA[Arquitectura]]></category>
		<category><![CDATA[Maven]]></category>
		<category><![CDATA[pom]]></category>

		<guid isPermaLink="false">http://blogs.antartec.com/desarrolloweb/?p=166</guid>
		<description><![CDATA[
			
				
			
		
Continuando con nuestro artículo anterior analizaremos la estructura del proyecto y el POM, base de todo proyecto Maven.
La estructura del Proyecto
Dependiendo del tipo de proyecto se pueden tener diferentes estructuras, sin embargo las estructuras más conocidas son la JAR y la WAR.

Veamos la estructura de una aplicación JAR:

Veamos la estructura de una aplicación WAR:

Como puede [...]


<strong>Enlaces relacionados</strong><ul><li><a href='http://blogs.antartec.com/desarrolloweb/2009/03/maven-en-detalle-parte-1/' rel='bookmark' title='Permanent Link: Maven en detalle &#8211; Parte 1'>Maven en detalle &#8211; Parte 1</a></li>
<li><a href='http://blogs.antartec.com/desarrolloweb/2009/05/maven-en-detalle-parte-3/' rel='bookmark' title='Permanent Link: Maven en detalle &#8211; Parte 3'>Maven en detalle &#8211; Parte 3</a></li>
</ul>]]></description>
			<content:encoded><![CDATA[<div class="tweetmeme_button" style="float: right; margin-left: 10px;">
			<a href="http://api.tweetmeme.com/share?url=http%3A%2F%2Fblogs.antartec.com%2Fdesarrolloweb%2F2009%2F04%2Fmaven-en-detalle-parte-2%2F"><br />
				<img src="http://api.tweetmeme.com/imagebutton.gif?url=http%3A%2F%2Fblogs.antartec.com%2Fdesarrolloweb%2F2009%2F04%2Fmaven-en-detalle-parte-2%2F&amp;source=giancorzo&amp;style=normal&amp;service=bit.ly" height="61" width="50" /><br />
			</a>
		</div>
<p>Continuando con nuestro <a href="http://blogs.antartec.com/desarrolloweb/2009/03/maven-en-detalle-parte-1/">artículo anterior</a> analizaremos la estructura del proyecto y el POM, base de todo proyecto Maven.</p>
<p><strong>La estructura del Proyecto</strong></p>
<p>Dependiendo del tipo de proyecto se pueden tener diferentes estructuras, sin embargo las estructuras más conocidas son la JAR y la WAR.<br />
<span id="more-166"></span><br />
Veamos la estructura de una aplicación JAR:</p>
<p><img src="http://blogs.antartec.com/desarrolloweb/files/2009/03/app-test-1.jpg" alt="" /></p>
<p>Veamos la estructura de una aplicación WAR:</p>
<p><img src="http://blogs.antartec.com/desarrolloweb/files/2009/03/app-test-2.jpg" alt="" /></p>
<p>Como puede verse las estructuras son parecidas con la diferencia que la estructura WAR tiene la sección webapp donde irán todos los files jsp, xhtml, html, etc.</p>
<p>En el directorio resources van files de configuración así como el messages.properties.</p>
<p><strong>El POM (Project Object Model)</strong></p>
<p>El POM file es el archivo XML de configuración de cualquier proyecto Maven, en él podemos encontrar información sobre la versión y las dependencias del proyecto así como cualquier otra configuración personalizada para ese proyecto.</p>
<p>El contenido del POM generado después de ejecutar el comando lo podemos ver a continuación:</p>

<div class="wp_syntax"><div class="code"><pre class="xml" style="font-family:monospace;"><span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;project</span> <span style="color: #000066;">xmlns</span>=<span style="color: #ff0000;">&quot;http://maven.apache.org/POM/4.0.0&quot;</span> <span style="color: #000066;">xmlns:xsi</span>=<span style="color: #ff0000;">&quot;http://www.w3.org/2001/XMLSchema-instance&quot;</span></span>
<span style="color: #009900;"><span style="color: #000066;">xsi:schemaLocation</span>=<span style="color: #ff0000;">&quot;http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd&quot;</span><span style="color: #000000; font-weight: bold;">&gt;</span></span>
   <span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;modelVersion<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>4.0.0<span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;/modelVersion<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>
   <span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;groupId<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>com.antartec.app<span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;/groupId<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>
   <span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;artifactId<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>my-test<span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;/artifactId<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>
   <span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;packaging<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>jar<span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;/packaging<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>
   <span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;version<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>1.0-SNAPSHOT<span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;/version<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>
   <span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;name<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>Maven Quick Start Archetype<span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;/name<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>
   <span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;url<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>http://maven.apache.org<span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;/url<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>
   <span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;dependencies<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>
      <span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;dependency<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>
           <span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;groupId<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>junit<span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;/groupId<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>
           <span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;artifactId<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>junit<span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;/artifactId<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>
           <span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;version<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>3.8.1<span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;/version<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>
           <span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;scope<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>test<span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;/scope<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>
      <span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;/dependency<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>
   <span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;/dependencies<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>
<span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;/project<span style="color: #000000; font-weight: bold;">&gt;</span></span></span></pre></div></div>

<p>Veamos los tags más importantes:</p>
<p><strong>&lt;groupId&gt;</strong> El id del grupo al que pertenece el proyecto.<br />
<strong>&lt;artifactId&gt;</strong> El id del artifact o proyecto (en la mayoría de los casos el nombre del proyecto).<br />
<strong>&lt;version&gt;</strong> La versión del artifact en el grupo especificado.<br />
<strong>&lt;dependency&gt;</strong> Aquí se colocarán todas las dependencias del proyecto.</p>
<p>El POM requiere que estos valores estén definidos ya que ésta es la manera en que Maven los identifica dentro de su repositorio.</p>
<p><strong>Ej. groupId:artifactId:version   com.antartec.app:my-test:1.0-SNAPSHOT</strong></p>
<p>Si no se especifica algunos de los tags (packaging,  name,  url) maven usan los valores por defecto heredados del super POM del cual heredan todos los proyectos (hablaremos sobre la herencia más adelante).</p>
<p><strong>Construyamos el proyecto</strong></p>
<p>Ejecutando el siguiente comando se construye el proyecto:</p>

<div class="wp_syntax"><div class="code"><pre class="bash" style="font-family:monospace;">mvn clean <span style="color: #c20cb9; font-weight: bold;">install</span></pre></div></div>

<p>A diferencia del comando archetype:create este comando es de una sola palabra que especifica la fase que debe ejecutarse. Una fase corresponde a un paso del ciclo de vida de maven. Por ejemplo</p>

<div class="wp_syntax"><div class="code"><pre class="bash" style="font-family:monospace;">mvn compile</pre></div></div>

<p>Ejecutará las siguientes fases:</p>

<div class="wp_syntax"><div class="code"><pre class="bash" style="font-family:monospace;">validate
generate-sources
process-sources
generate-resources
process-resources
compile</pre></div></div>

<p>Existe muchas fases en Maven sin embargo listo las más utilizadas a continuación:</p>
<ul>
<li><strong>validate</strong> – valida que el proyecto es correcto y tiene toda la información necesaria.</li>
<li><strong>compile</strong> – compila el código fuente.</li>
<li><strong>test</strong> – compila el código y ejecuta los unit test correspondientes. Sin embargo no es requisito para que el proyecto sea desplegado.</li>
<li><strong>package</strong> – toma el código compilado y lo empaqueta en un formato distribuible como JAR o WAR.</li>
<li><strong>integration-test</strong> – Despliega el proyecto si es necesario en ambiente de pruebas donde se puedan correr pruebas de integración.</li>
<li><strong>verify</strong> – ejecuta cualquier verificación para cumplir los parámetros de calidad.</li>
<li><strong>install</strong> – instala el jar o war en el repositorio local para que otras aplicaciones locales la puedan usar.</li>
<li><strong>deploy</strong> – copia el jar o war a un repositorio remoto para que pueda ser usado por otro desarrollador o proyecto.</li>
</ul>
<p>Si desean ver la lista completa de fase las pueden encontrar en <a href="http://maven.apache.org/guides/introduction/introduction-to-the-lifecycle.html#Lifecycle_Reference" target="_blank">lifecycle</a></p>
<p>Para un desarrollo local bastará con utilizar <strong>mvn clean install</strong>.</p>
<p>En nuestra siguiente entrega hablaremos sobre el manejo de las dependencias y como usar el proyecto junto con nuestro IDE favorito.</p>


<p><strong>Enlaces relacionados</strong><ul><li><a href='http://blogs.antartec.com/desarrolloweb/2009/03/maven-en-detalle-parte-1/' rel='bookmark' title='Permanent Link: Maven en detalle &#8211; Parte 1'>Maven en detalle &#8211; Parte 1</a></li>
<li><a href='http://blogs.antartec.com/desarrolloweb/2009/05/maven-en-detalle-parte-3/' rel='bookmark' title='Permanent Link: Maven en detalle &#8211; Parte 3'>Maven en detalle &#8211; Parte 3</a></li>
</ul></p><div class="feedflare">
<a href="http://feeds.feedburner.com/~ff/DesarrolloEnWeb?a=A_gPZciTk4o:k6-2xntKj18:yIl2AUoC8zA"><img src="http://feeds.feedburner.com/~ff/DesarrolloEnWeb?d=yIl2AUoC8zA" border="0"></img></a> <a href="http://feeds.feedburner.com/~ff/DesarrolloEnWeb?a=A_gPZciTk4o:k6-2xntKj18:qj6IDK7rITs"><img src="http://feeds.feedburner.com/~ff/DesarrolloEnWeb?d=qj6IDK7rITs" border="0"></img></a>
</div>]]></content:encoded>
			<wfw:commentRss>http://blogs.antartec.com/desarrolloweb/2009/04/maven-en-detalle-parte-2/feed/</wfw:commentRss>
		<slash:comments>5</slash:comments>
		</item>
		<item>
		<title>Uso de RichFaces tabPanel con JavaScript</title>
		<link>http://blogs.antartec.com/desarrolloweb/2009/04/uso-de-richfaces-tabpanel-con-javascript/</link>
		<comments>http://blogs.antartec.com/desarrolloweb/2009/04/uso-de-richfaces-tabpanel-con-javascript/#comments</comments>
		<pubDate>Tue, 07 Apr 2009 22:52:38 +0000</pubDate>
		<dc:creator>Otto Theo</dc:creator>
				<category><![CDATA[Frameworks]]></category>
		<category><![CDATA[javascript]]></category>
		<category><![CDATA[RichFaces]]></category>

		<guid isPermaLink="false">http://blogs.antartec.com/desarrolloweb/?p=132</guid>
		<description><![CDATA[
			
				
			
		
En esta ocasión trataré sobre el uso del componente tabPanel de RichFaces usándolo con funciones JavaScript para dos casos en particular:

Hacer el cambio de tabs.
Verificar si un tab está activo.

El tabPanel presenta 3 maneras para realizar el cambio de un tab a otro mediante el atributo switchType:

client (se carga la información de todos los tabs).
ajax [...]


Sin posts relacionados.]]></description>
			<content:encoded><![CDATA[<div class="tweetmeme_button" style="float: right; margin-left: 10px;">
			<a href="http://api.tweetmeme.com/share?url=http%3A%2F%2Fblogs.antartec.com%2Fdesarrolloweb%2F2009%2F04%2Fuso-de-richfaces-tabpanel-con-javascript%2F"><br />
				<img src="http://api.tweetmeme.com/imagebutton.gif?url=http%3A%2F%2Fblogs.antartec.com%2Fdesarrolloweb%2F2009%2F04%2Fuso-de-richfaces-tabpanel-con-javascript%2F&amp;source=giancorzo&amp;style=normal&amp;service=bit.ly" height="61" width="50" /><br />
			</a>
		</div>
<p>En esta ocasión trataré sobre el uso del componente tabPanel de RichFaces usándolo con funciones JavaScript para dos casos en particular:</p>
<ul>
<li>Hacer el cambio de tabs.</li>
<li>Verificar si un tab está activo.</li>
</ul>
<p>El tabPanel presenta 3 maneras para realizar el cambio de un tab a otro mediante el atributo switchType:</p>
<ul>
<li><strong><em>client</em></strong> (se carga la información de todos los tabs).</li>
<li><strong><em>ajax</em></strong> (se carga la información mediante ajax, cada vez que se entra al tab).</li>
<li><strong><em>server</em></strong> (se carga la información cada vez que se entra al tab, actualizando toda la página).</li>
</ul>
<p><span id="more-132"></span><br />
Antes de comenzar, como nota importante, he probado esta forma de usar el tabPanel con las versiones <em><span style="text-decoration: underline">3.2.1</span></em> y la <em><span style="text-decoration: underline">3.3.0.GA</span><span style="font-style: normal"> de RichFaces.</span></em></p>
<p>Para todos los ejemplos utilizaré el código siguiente:</p>

<div class="wp_syntax"><div class="code"><pre class="xml" style="font-family:monospace;"><span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;h:form</span> <span style="color: #000066;">id</span>=<span style="color: #ff0000;">&quot;miFormulario&quot;</span> <span style="color: #000000; font-weight: bold;">&gt;</span></span>
&nbsp;
  <span style="color: #808080; font-style: italic;">&lt;!-- para los casos ajax y server switchType tendrá los valores 'ajax' y 'server' respectivamente --&gt;</span>
  <span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;rich:tabPanel</span> <span style="color: #000066;">id</span>=<span style="color: #ff0000;">&quot;testTabPanel&quot;</span> <span style="color: #000066;">switchType</span>=<span style="color: #ff0000;">&quot;client&quot;</span> <span style="color: #000000; font-weight: bold;">&gt;</span></span>
&nbsp;
    <span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;rich:tab</span> <span style="color: #000066;">id</span>=<span style="color: #ff0000;">&quot;tabUno&quot;</span> <span style="color: #000066;">label</span>=<span style="color: #ff0000;">&quot;Tab Uno&quot;</span> <span style="color: #000000; font-weight: bold;">&gt;</span></span>
      <span style="color: #808080; font-style: italic;">&lt;!-- contenido del tab uno --&gt;</span>
    <span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;/rich:tab<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>
&nbsp;
    <span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;rich:tab</span> <span style="color: #000066;">id</span>=<span style="color: #ff0000;">&quot;tabDos&quot;</span> <span style="color: #000066;">label</span>=<span style="color: #ff0000;">&quot;Tab Dos&quot;</span> <span style="color: #000000; font-weight: bold;">&gt;</span></span>
      <span style="color: #808080; font-style: italic;">&lt;!-- contenido del tab dos --&gt;</span>
    <span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;/rich:tab<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>
&nbsp;
  <span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;/rich:tabPanel<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>
&nbsp;
<span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;/h:form<span style="color: #000000; font-weight: bold;">&gt;</span></span></span></pre></div></div>

<p><strong>1. </strong><span style="text-decoration: underline"><strong>Cambio de tabs</strong></span><strong>:</strong></p>
<p>Para realizar el cambio de tabs, se obtendrá mediante JavaScript el elemento cuyo id tenga la foma &lt;id del tab&gt;_shifted, así:</p>

<div class="wp_syntax"><div class="code"><pre class="javascript" style="font-family:monospace;"><span style="color: #003366; font-weight: bold;">function</span> irAlTabUno<span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
  <span style="color: #006600; font-style: italic;">// se obtiene el elemento:</span>
  <span style="color: #003366; font-weight: bold;">var</span> tabUno <span style="color: #339933;">=</span> document.<span style="color: #660066;">getElementById</span><span style="color: #009900;">&#40;</span><span style="color: #3366CC;">'miFormulario:tabUno_shifted'</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
  <span style="color: #006600; font-style: italic;">// esta es la línea que realizará el cambio de tab</span>
  <span style="color: #006600; font-style: italic;">// si el tab se encuentra activo entonces no hará nada:</span>
  tabUno.<span style="color: #660066;">onclick</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
<span style="color: #009900;">&#125;</span>
&nbsp;
<span style="color: #003366; font-weight: bold;">function</span> irAlTabDos<span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
  document.<span style="color: #660066;">getElementById</span><span style="color: #009900;">&#40;</span><span style="color: #3366CC;">'miFormulario:tabDos_shifted'</span><span style="color: #009900;">&#41;</span>.<span style="color: #660066;">onclick</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
<span style="color: #009900;">&#125;</span></pre></div></div>

<p>El &#8216;truco&#8217; es obtener mediante JavaScript el elemento correcto (al cual hacerle onclick), lo que hace RichFaces es crear un HTML &lt;table&gt; dentro de la celda que contiene la pestaña con el mismo id que le dimos al tab pero concatenándole &#8216;_shifted&#8217;.</p>
<p>Existe una manera en particular para hacer el cambio pero <span style="text-decoration: underline">sólo</span> si se encuentra en modo <span style="text-decoration: underline">&#8216;client&#8217;</span>, la cual es usando una de las funciones del archivo tabPanel.js de RichFaces:</p>

<div class="wp_syntax"><div class="code"><pre class="javascript" style="font-family:monospace;"><span style="color: #003366; font-weight: bold;">function</span> irAlTabUno<span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
  RichFaces.<span style="color: #660066;">switchTab</span><span style="color: #009900;">&#40;</span><span style="color: #3366CC;">'miFormulario:testTabPanel'</span><span style="color: #339933;">,</span> <span style="color: #3366CC;">'miFormulario:tabUno'</span><span style="color: #339933;">,</span> <span style="color: #3366CC;">'Tab Uno'</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
<span style="color: #009900;">&#125;</span>
&nbsp;
<span style="color: #003366; font-weight: bold;">function</span> irAlTabDos<span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
  RichFaces.<span style="color: #660066;">switchTab</span><span style="color: #009900;">&#40;</span><span style="color: #3366CC;">'miFormulario:testTabPanel'</span><span style="color: #339933;">,</span> <span style="color: #3366CC;">'miFormulario:tabDos'</span><span style="color: #339933;">,</span> <span style="color: #3366CC;">'Tab Dos'</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
<span style="color: #009900;">&#125;</span></pre></div></div>

<p>O usando <a href="http://blogs.antartec.com/desarrolloweb/2009/03/richelement-una-forma-de-obtener-componentes-jsf-sin-preocuparse-por-los-id/" target="_blank">rich:clientId()</a></p>

<div class="wp_syntax"><div class="code"><pre class="javascript" style="font-family:monospace;"><span style="color: #003366; font-weight: bold;">function</span> irAlTabUno<span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
  RichFaces.<span style="color: #660066;">switchTab</span><span style="color: #009900;">&#40;</span><span style="color: #3366CC;">'#{rich:clientId('</span>testTabPanel<span style="color: #3366CC;">')}'</span><span style="color: #339933;">,</span> <span style="color: #3366CC;">'#{rich:clientId('</span>tabUno<span style="color: #3366CC;">')}'</span><span style="color: #339933;">,</span> <span style="color: #3366CC;">'Tab Uno'</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
<span style="color: #009900;">&#125;</span>
&nbsp;
<span style="color: #003366; font-weight: bold;">function</span> irAlTabDos<span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
  RichFaces.<span style="color: #660066;">switchTab</span><span style="color: #009900;">&#40;</span><span style="color: #3366CC;">'#{rich:clientId('</span>testTabPanel<span style="color: #3366CC;">')}'</span> <span style="color: #339933;">,</span><span style="color: #3366CC;">'#{rich:clientId('</span>tabDos<span style="color: #3366CC;">')}'</span><span style="color: #339933;">,</span> <span style="color: #3366CC;">'Tab Dos'</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
<span style="color: #009900;">&#125;</span></pre></div></div>

<p>Donde la función <span style="color: #0000ff">RichFaces.switchTab()</span> recibe 3 parámetros: el id del tabPanel, el id del tab al cual queremos ir, y el label del mismo tab destino.</p>
<p><strong>2. </strong><span style="text-decoration: underline"><strong>Verificar si un tab está activo</strong></span><strong>:</strong></p>
<p>Aquí también usaremos una de las funciones del archivo tabPanel.js de RichFaces:</p>

<div class="wp_syntax"><div class="code"><pre class="javascript" style="font-family:monospace;"><span style="color: #003366; font-weight: bold;">function</span> estaActivoTabUno<span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
  <span style="color: #000066; font-weight: bold;">return</span> RichFaces.<span style="color: #660066;">isTabActive</span><span style="color: #009900;">&#40;</span><span style="color: #3366CC;">'miFormulario:tabUno_lbl'</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
<span style="color: #009900;">&#125;</span>
&nbsp;
<span style="color: #003366; font-weight: bold;">function</span> estaActivoTabDos<span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
  <span style="color: #000066; font-weight: bold;">return</span> RichFaces.<span style="color: #660066;">isTabActive</span><span style="color: #009900;">&#40;</span><span style="color: #3366CC;">'miFormulario:tabDos_lbl'</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
<span style="color: #009900;">&#125;</span></pre></div></div>

<p>Igual que en el caso anterior de cambio de tabs, el &#8216;truco&#8217; es usar el HTML &lt;td&gt; que crea RichFaces con el mismo id que le dimos al tab pero concatenándole &#8216;_lbl&#8217;. Entonces llamamos a la función <span style="color: #0000ff">RichFaces.isTabActive()</span> que recibe como parámetro este id.</p>
<p><strong>Conclusión</strong><strong>:</strong></p>
<p>Normalmente cambiar de tab es tan sencillo como hacer clic en el tab al cual queremos cambiar, y conocer el tab activo se realiza mediante el atributo &#8217;selectedTab&#8217; del rich:tabPanel (con un backing bean de por medio). Por eso esta manera de hacer ambas cosas mediante JavaScript es para casos muy particulares como por ejemplo, verificar que no se realice el cambio de tabs sin antes haber validado/guardado la información de cada tab independiente (cada tab posee un formulario), previa pregunta de confirmación al usuario con un javascript:confirm(&#8216;&#8230;&#8217;).</p>


<p>Sin posts relacionados.</p><div class="feedflare">
<a href="http://feeds.feedburner.com/~ff/DesarrolloEnWeb?a=QpYsCKmUAPs:wTmpHIDlO98:yIl2AUoC8zA"><img src="http://feeds.feedburner.com/~ff/DesarrolloEnWeb?d=yIl2AUoC8zA" border="0"></img></a> <a href="http://feeds.feedburner.com/~ff/DesarrolloEnWeb?a=QpYsCKmUAPs:wTmpHIDlO98:qj6IDK7rITs"><img src="http://feeds.feedburner.com/~ff/DesarrolloEnWeb?d=qj6IDK7rITs" border="0"></img></a>
</div>]]></content:encoded>
			<wfw:commentRss>http://blogs.antartec.com/desarrolloweb/2009/04/uso-de-richfaces-tabpanel-con-javascript/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Maven en detalle – Parte 1</title>
		<link>http://blogs.antartec.com/desarrolloweb/2009/03/maven-en-detalle-parte-1/</link>
		<comments>http://blogs.antartec.com/desarrolloweb/2009/03/maven-en-detalle-parte-1/#comments</comments>
		<pubDate>Tue, 31 Mar 2009 22:49:40 +0000</pubDate>
		<dc:creator>Giancarlo Corzo</dc:creator>
				<category><![CDATA[Arquitectura]]></category>
		<category><![CDATA[Maven]]></category>

		<guid isPermaLink="false">http://blogs.antartec.com/desarrolloweb/?p=127</guid>
		<description><![CDATA[
			
				
			
		
Comenzamos la saga Maven compuesta por una serie de artículos en donde detallaremos como instalar, construir, desplegar un pequeño proyecto piloto.
En artículos anteriores hemos hablado sobre las ventajas de Maven y como es que éste encaja dentro la de estructura de integración continua en el desarrollo de proyectos por lo que pasaremos directamente a los [...]


<strong>Enlaces relacionados</strong><ul><li><a href='http://blogs.antartec.com/desarrolloweb/2009/04/maven-en-detalle-parte-2/' rel='bookmark' title='Permanent Link: Maven en detalle &#8211; Parte 2'>Maven en detalle &#8211; Parte 2</a></li>
<li><a href='http://blogs.antartec.com/desarrolloweb/2009/05/maven-en-detalle-parte-3/' rel='bookmark' title='Permanent Link: Maven en detalle &#8211; Parte 3'>Maven en detalle &#8211; Parte 3</a></li>
</ul>]]></description>
			<content:encoded><![CDATA[<div class="tweetmeme_button" style="float: right; margin-left: 10px;">
			<a href="http://api.tweetmeme.com/share?url=http%3A%2F%2Fblogs.antartec.com%2Fdesarrolloweb%2F2009%2F03%2Fmaven-en-detalle-parte-1%2F"><br />
				<img src="http://api.tweetmeme.com/imagebutton.gif?url=http%3A%2F%2Fblogs.antartec.com%2Fdesarrolloweb%2F2009%2F03%2Fmaven-en-detalle-parte-1%2F&amp;source=giancorzo&amp;style=normal&amp;service=bit.ly" height="61" width="50" /><br />
			</a>
		</div>
<p>Comenzamos la saga <a href="http://maven.apache.org/">Maven</a> compuesta por una serie de artículos en donde detallaremos como instalar, construir, desplegar un pequeño proyecto piloto.</p>
<p>En artículos anteriores hemos hablado sobre las ventajas de <a href="http://blogs.antartec.com/opensource/2008/11/antartec-open-source-maven/" target="_blank">Maven</a> y como es que éste encaja dentro la de estructura de <a href="http://blogs.antartec.com/desarrolloweb/2008/12/integracion-continua-en-proyectos-de-desarrollo/" target="_blank">integración continua en el desarrollo de proyectos</a> por lo que pasaremos directamente a los detalles.</p>
<p><span id="more-127"></span><br />
<strong>Empecemos por instalar Maven</strong></p>
<p>Tenemos que ir al sitio web de la Maven y descargar la última versión (<a href="http://maven.apache.org/download.html" target="_blank">http://maven.apache.org/download.html</a>),  es necesario contar con el JDK previamente instalado.</p>
<p>Seguimos las instrucciones de la página para configurar las variables de entorno correspondientes para máquinas con Windows o Linux.</p>
<p><strong>Una vez instalado, construiremos nuestro primer proyecto</strong></p>
<p>Una vez instalado maven en nuestro computador podemos empezar por construir nuestro primer proyecto de prueba al cual llamaremos <strong>app-test</strong>.</p>
<p>Ejecutamos el siguiente “Archetype” para crear un jar en la línea de comandos:</p>

<div class="wp_syntax"><div class="code"><pre class="bash" style="font-family:monospace;">mvn archetype:create
<span style="color: #660033;">-DarchetypeGroupId</span>=org.apache.maven.archetypes
<span style="color: #660033;">-DgroupId</span>=com.antartec
<span style="color: #660033;">-DartifactId</span>=app-test</pre></div></div>

<p>Los archetype son simples plugins de maven, uno de ellos es el archetype create, el cual permite crear un proyecto base al proporcionar la plantilla del mismo.</p>
<p>El archetype create recibe una serie de parámetros los cuales son:</p>
<ul>
<li><strong>archetypeGroupId</strong>, usar este parámetro es una manera abreviada de crear un proyecto de tipo jar, sin embargo cuando se usan archetypes creados por uno mismo se tiene que especificar los tres parámetros de todo archetype (groupId, artifactId,version) de la siguiente manera.</li>
</ul>

<div class="wp_syntax"><div class="code"><pre class="bash" style="font-family:monospace;">mvn archetype:create
<span style="color: #660033;">-DarchetypeGroupId</span>=<span style="color: #000000; font-weight: bold;">&lt;</span>archetype-groupId<span style="color: #000000; font-weight: bold;">&gt;</span>
<span style="color: #660033;">-DarchetypeArtifactId</span>=<span style="color: #000000; font-weight: bold;">&lt;</span>archetype-artifactId<span style="color: #000000; font-weight: bold;">&gt;</span>
<span style="color: #660033;">-DarchetypeVersion</span>=<span style="color: #000000; font-weight: bold;">&lt;</span>archetype-version<span style="color: #000000; font-weight: bold;">&gt;</span>
<span style="color: #660033;">-DgroupId</span>=<span style="color: #000000; font-weight: bold;">&lt;</span>my.groupid<span style="color: #000000; font-weight: bold;">&gt;</span>
<span style="color: #660033;">-DartifactId</span>=<span style="color: #000000; font-weight: bold;">&lt;</span>my-artifactId<span style="color: #000000; font-weight: bold;">&gt;</span></pre></div></div>

<ul>
<li><strong>groupId</strong>, es usado como identificador del conjunto de librerías en este caso hemos usado <strong>com.antartec</strong> como  nombre para nuestro paquete de librerías.</li>
<li><strong>artifactId</strong>, es usado como identificador particular de una librería en particular.</li>
</ul>
<p>Si es la primera vez que se ejecuta un comando Maven éste tomará algo de tiempo pues Maven creará el repositorio inicial .m2 y descargará todas las librerías necesarias para construir el proyecto.</p>
<p>Si deseamos crear un proyecto war en vez de un jar ejecutaremos el siguiente “Archetype” en la línea de comandos:</p>

<div class="wp_syntax"><div class="code"><pre class="bash" style="font-family:monospace;">mvn archetype:create
<span style="color: #660033;">-DarchetypeArtifactId</span>=maven-archetype-webapp
<span style="color: #660033;">-DgroupId</span>=com.antartec.app
<span style="color: #660033;">-DartifactId</span>=webapp-test</pre></div></div>

<p>En este caso hemos ejecutado un archetype distinto que contiene la plantilla de un proyecto web.</p>
<p>En el siguiente artículo analizaremos la estructura del POM generado, base de cualquier proyecto Maven.</p>


<p><strong>Enlaces relacionados</strong><ul><li><a href='http://blogs.antartec.com/desarrolloweb/2009/04/maven-en-detalle-parte-2/' rel='bookmark' title='Permanent Link: Maven en detalle &#8211; Parte 2'>Maven en detalle &#8211; Parte 2</a></li>
<li><a href='http://blogs.antartec.com/desarrolloweb/2009/05/maven-en-detalle-parte-3/' rel='bookmark' title='Permanent Link: Maven en detalle &#8211; Parte 3'>Maven en detalle &#8211; Parte 3</a></li>
</ul></p><div class="feedflare">
<a href="http://feeds.feedburner.com/~ff/DesarrolloEnWeb?a=u3Xm9YaW3T4:9bJX2KjkWhk:yIl2AUoC8zA"><img src="http://feeds.feedburner.com/~ff/DesarrolloEnWeb?d=yIl2AUoC8zA" border="0"></img></a> <a href="http://feeds.feedburner.com/~ff/DesarrolloEnWeb?a=u3Xm9YaW3T4:9bJX2KjkWhk:qj6IDK7rITs"><img src="http://feeds.feedburner.com/~ff/DesarrolloEnWeb?d=qj6IDK7rITs" border="0"></img></a>
</div>]]></content:encoded>
			<wfw:commentRss>http://blogs.antartec.com/desarrolloweb/2009/03/maven-en-detalle-parte-1/feed/</wfw:commentRss>
		<slash:comments>2</slash:comments>
		</item>
		<item>
		<title>rich:element una forma de obtener componentes jsf sin preocuparse por los id</title>
		<link>http://blogs.antartec.com/desarrolloweb/2009/03/richelement-una-forma-de-obtener-componentes-jsf-sin-preocuparse-por-los-id/</link>
		<comments>http://blogs.antartec.com/desarrolloweb/2009/03/richelement-una-forma-de-obtener-componentes-jsf-sin-preocuparse-por-los-id/#comments</comments>
		<pubDate>Wed, 04 Mar 2009 17:17:48 +0000</pubDate>
		<dc:creator>Giancarlo Corzo</dc:creator>
				<category><![CDATA[Frameworks]]></category>
		<category><![CDATA[rich faces jsf element]]></category>

		<guid isPermaLink="false">http://blogs.antartec.com/desarrolloweb/?p=121</guid>
		<description><![CDATA[
			
				
			
		
Cuando trabajamos con JSF tenemos que tener cuidado con los ids que asignamos a cada componente, dado que estos deben ser únicos.
JSF y otras librerías, para prevenir problemas en este sentido, siguen las siguientes reglas:

Cuando no se asigna un id de manera explícita a un elemento se le genera un client id único.
 A todos [...]


Sin posts relacionados.]]></description>
			<content:encoded><![CDATA[<div class="tweetmeme_button" style="float: right; margin-left: 10px;">
			<a href="http://api.tweetmeme.com/share?url=http%3A%2F%2Fblogs.antartec.com%2Fdesarrolloweb%2F2009%2F03%2Frichelement-una-forma-de-obtener-componentes-jsf-sin-preocuparse-por-los-id%2F"><br />
				<img src="http://api.tweetmeme.com/imagebutton.gif?url=http%3A%2F%2Fblogs.antartec.com%2Fdesarrolloweb%2F2009%2F03%2Frichelement-una-forma-de-obtener-componentes-jsf-sin-preocuparse-por-los-id%2F&amp;source=giancorzo&amp;style=normal&amp;service=bit.ly" height="61" width="50" /><br />
			</a>
		</div>
<p>Cuando trabajamos con JSF tenemos que tener cuidado con los ids que asignamos a cada componente, dado que estos deben ser únicos.</p>
<p>JSF y otras librerías, para prevenir problemas en este sentido, siguen las siguientes reglas:</p>
<ol>
<li>Cuando no se asigna un id de manera explícita a un elemento se le genera un client id único.</li>
<li> A todos los client ids (autogenerados o fijos) le antepone los client ids de los componentes padres, por ejemplo un inputText que se encuentre dentro de un form tendría un client id de la siguiente forma: nombreForm:nombreInputText.</li>
<li>Componentes como a4j:repeat van incluso más alla,  generando client ids  con esta estructura nombreForm:nombreRepeat:indice:componente.</li>
</ol>
<p>Antes de la última versión de rich faces (<a href="rgb(#{statusBarBean.getRBG(completeTasks,(completeTasks+notMasteredTasks+skippedTasks+notCompleteTasks),rgbRed,255)},#{statusBarBean.getRBG(completeTasks,(completeTasks+notMasteredTasks+skippedTasks+notCompleteTasks),rgbGreen,255)},#{statusBarBean.getRBG(completeTasks,(completeTasks+notMasteredTasks+skippedTasks+notCompleteTasks),rgbBlue,255)})" target="_blank">http://www.jboss.org/jbossrichfaces/downloads/</a>) teníamos el problema de tener que estar pendientes de los client id, por ejemplo para obtener un elemento teníamos que escribir algo como esto:</p>

<div class="wp_syntax"><div class="code"><pre class="javascript" style="font-family:monospace;">document.<span style="color: #660066;">getElementById</span><span style="color: #009900;">&#40;</span>“formName<span style="color: #339933;">:</span>elementName”<span style="color: #009900;">&#41;</span></pre></div></div>

<p>Sin embargo rich proporciona ahora 4 métodos muy interesantes para obtener referencias a los componentes desde javascript:</p>
<ul>
<li>rich:clientId(&#8216;id&#8217;) retorna el client id compuesto del componente JSF</li>
<li>rich:element(&#8216;id&#8217;) es una contracción de document.getElementById(#{rich:clientId(&#8216;id&#8217;)})</li>
<li>rich:component(&#8216;id&#8217;) es una contracción de #{rich:clientId(&#8216;id&#8217;)}.component</li>
<li>rich:findComponent(&#8216;id&#8217;) devuelve una instancia de UIComponent tomando el id como parámetro.</li>
</ul>
<p>Veamos un ejemplo:</p>

<div class="wp_syntax"><div class="code"><pre class="javascript" style="font-family:monospace;"><span style="color: #339933;">&lt;</span>script<span style="color: #339933;">&gt;</span>
<span style="color: #003366; font-weight: bold;">function</span> getLinkAndDoClick<span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
#<span style="color: #009900;">&#123;</span>rich<span style="color: #339933;">:</span>element<span style="color: #009900;">&#40;</span><span style="color: #3366CC;">'linkid'</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#125;</span> .<span style="color: #660066;">onclick</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
<span style="color: #009900;">&#125;</span>
<span style="color: #339933;">&lt;/</span>script<span style="color: #339933;">&gt;</span>
&nbsp;
<span style="color: #339933;">&lt;</span>h<span style="color: #339933;">:</span>form<span style="color: #339933;">&gt;</span>
<span style="color: #339933;">&lt;</span>a4j<span style="color: #339933;">:</span>commandLink id<span style="color: #339933;">=</span>”linkid” value<span style="color: #339933;">=</span>”Haz click aqui” action<span style="color: #339933;">=</span>”#<span style="color: #009900;">&#123;</span>somebean.<span style="color: #660066;">someAction</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#125;</span>”<span style="color: #339933;">/&gt;</span>
<span style="color: #339933;">&lt;/</span>h<span style="color: #339933;">:</span>form<span style="color: #339933;">&gt;</span></pre></div></div>

<p>De esta manera se puede obtener referencias a los componentes JSF sin tener que estar preocupándose cómo sus client id son generados.</p>


<p>Sin posts relacionados.</p><div class="feedflare">
<a href="http://feeds.feedburner.com/~ff/DesarrolloEnWeb?a=8yILFsqDRmo:MIwV1q74rPE:yIl2AUoC8zA"><img src="http://feeds.feedburner.com/~ff/DesarrolloEnWeb?d=yIl2AUoC8zA" border="0"></img></a> <a href="http://feeds.feedburner.com/~ff/DesarrolloEnWeb?a=8yILFsqDRmo:MIwV1q74rPE:qj6IDK7rITs"><img src="http://feeds.feedburner.com/~ff/DesarrolloEnWeb?d=qj6IDK7rITs" border="0"></img></a>
</div>]]></content:encoded>
			<wfw:commentRss>http://blogs.antartec.com/desarrolloweb/2009/03/richelement-una-forma-de-obtener-componentes-jsf-sin-preocuparse-por-los-id/feed/</wfw:commentRss>
		<slash:comments>1</slash:comments>
		</item>
		<item>
		<title>Performance: Uso de @Create</title>
		<link>http://blogs.antartec.com/desarrolloweb/2009/02/seam_uso_de_create/</link>
		<comments>http://blogs.antartec.com/desarrolloweb/2009/02/seam_uso_de_create/#comments</comments>
		<pubDate>Fri, 13 Feb 2009 22:11:47 +0000</pubDate>
		<dc:creator>Giancarlo Corzo</dc:creator>
				<category><![CDATA[Arquitectura]]></category>
		<category><![CDATA[Frameworks]]></category>
		<category><![CDATA[Seam]]></category>

		<guid isPermaLink="false">http://blogs.antartec.com/desarrolloweb/?p=107</guid>
		<description><![CDATA[
			
				
			
		
En este post me gustaría hacer una pequeña contribución al post “Performance: ¿Por qué usar @Factory en vez de getters?” de Seam City sobre el uso de @Factory para la obtención de listas.

En el post se menciona que los valores obtenidos por EL no se guardan en cache y ésto es un problema sobre todo [...]


Sin posts relacionados.]]></description>
			<content:encoded><![CDATA[<div class="tweetmeme_button" style="float: right; margin-left: 10px;">
			<a href="http://api.tweetmeme.com/share?url=http%3A%2F%2Fblogs.antartec.com%2Fdesarrolloweb%2F2009%2F02%2Fseam_uso_de_create%2F"><br />
				<img src="http://api.tweetmeme.com/imagebutton.gif?url=http%3A%2F%2Fblogs.antartec.com%2Fdesarrolloweb%2F2009%2F02%2Fseam_uso_de_create%2F&amp;source=giancorzo&amp;style=normal&amp;service=bit.ly" height="61" width="50" /><br />
			</a>
		</div>
<p>En este post me gustaría hacer una pequeña contribución al post <a href="http://seamcity.madeinxpain.com/archives/performance-%C2%BFpor-que-usar-factory-en-vez-de-getters" target="_blank">“Performance: ¿Por qué usar @Factory en vez de getters?”</a> de Seam City sobre el uso de @Factory para la obtención de listas.<br />
<span id="more-107"></span><br />
En el post se menciona que los valores obtenidos por EL no se guardan en cache y ésto es un problema sobre todo cuando se acceden a listas que son cargadas desde la base de datos.</p>
<p>Para resolver el problema el post plantea 2 opciones:</p>
<p>Por patrón de carga lazy loading</p>

<div class="wp_syntax"><div class="code"><pre class="java" style="font-family:monospace;">@<span style="color: #003399;">Name</span><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">&quot;userManager&quot;</span><span style="color: #009900;">&#41;</span>
<span style="color: #000000; font-weight: bold;">public</span> <span style="color: #000000; font-weight: bold;">class</span> UserManager <span style="color: #009900;">&#123;</span>
  <span style="color: #000000; font-weight: bold;">private</span> <span style="color: #003399;">List</span> list<span style="color: #339933;">;</span>
&nbsp;
  <span style="color: #000000; font-weight: bold;">public</span> <span style="color: #003399;">List</span> getUserList<span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
    <span style="color: #000000; font-weight: bold;">if</span> <span style="color: #009900;">&#40;</span><span style="color: #000000; font-weight: bold;">this</span>.<span style="color: #006633;">list</span> <span style="color: #339933;">==</span> <span style="color: #000066; font-weight: bold;">null</span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
      <span style="color: #000000; font-weight: bold;">this</span>.<span style="color: #006633;">list</span> <span style="color: #339933;">=</span> createUserList<span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
    <span style="color: #009900;">&#125;</span>
    <span style="color: #000000; font-weight: bold;">return</span> list<span style="color: #339933;">;</span>
  <span style="color: #009900;">&#125;</span>
<span style="color: #009900;">&#125;</span></pre></div></div>

<p>Y una mejor manera utilizando las anotaciones @Out y @Factory</p>

<div class="wp_syntax"><div class="code"><pre class="java" style="font-family:monospace;">&nbsp;
<span style="color: #000000; font-weight: bold;">public</span> <span style="color: #000000; font-weight: bold;">class</span> UserManager <span style="color: #009900;">&#123;</span>
&nbsp;
  @Factory<span style="color: #009900;">&#40;</span>value <span style="color: #339933;">=</span> <span style="color: #0000ff;">&quot;userList&quot;</span>, scope <span style="color: #339933;">=</span> ScopeType.<span style="color: #006633;">PAGE</span><span style="color: #009900;">&#41;</span>
  <span style="color: #000000; font-weight: bold;">public</span> <span style="color: #003399;">List</span> getUserList<span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
     <span style="color: #000000; font-weight: bold;">if</span> <span style="color: #009900;">&#40;</span><span style="color: #000000; font-weight: bold;">this</span>.<span style="color: #006633;">list</span> <span style="color: #339933;">==</span> <span style="color: #000066; font-weight: bold;">null</span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
       <span style="color: #000000; font-weight: bold;">this</span>.<span style="color: #006633;">list</span> <span style="color: #339933;">=</span> createUserList<span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
     <span style="color: #009900;">&#125;</span>
     <span style="color: #000000; font-weight: bold;">return</span> list<span style="color: #339933;">;</span>
  <span style="color: #009900;">&#125;</span>
<span style="color: #009900;">&#125;</span></pre></div></div>

<p>Sin embargo existe una tercera solución que es bastante más clara y sobre todo sigue la convención con respecto a la creación de objetos y es utilizar la anotación @Create</p>
<p>El código es el siguiente:</p>

<div class="wp_syntax"><div class="code"><pre class="java" style="font-family:monospace;">&nbsp;
@<span style="color: #003399;">Name</span><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">&quot;userManager&quot;</span><span style="color: #009900;">&#41;</span>
@Scope<span style="color: #009900;">&#40;</span>ScopeType.<span style="color: #006633;">PAGE</span><span style="color: #009900;">&#41;</span>
<span style="color: #000000; font-weight: bold;">public</span> <span style="color: #000000; font-weight: bold;">class</span> UserManager <span style="color: #000000; font-weight: bold;">implements</span> <span style="color: #003399;">Serializable</span> <span style="color: #009900;">&#123;</span>
&nbsp;
  <span style="color: #000000; font-weight: bold;">private</span> List<span style="color: #339933;">&lt;</span>User<span style="color: #339933;">&gt;</span> list<span style="color: #339933;">;</span>
&nbsp;
  @Create
  <span style="color: #000000; font-weight: bold;">public</span> <span style="color: #000066; font-weight: bold;">void</span> loadInitData<span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
     <span style="color: #000000; font-weight: bold;">this</span>.<span style="color: #006633;">list</span> <span style="color: #339933;">=</span> createList<span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
  <span style="color: #009900;">&#125;</span>
&nbsp;
  <span style="color: #000000; font-weight: bold;">public</span> List<span style="color: #339933;">&lt;</span>User<span style="color: #339933;">&gt;</span> getList<span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
    <span style="color: #000000; font-weight: bold;">return</span> list<span style="color: #339933;">;</span>
  <span style="color: #009900;">&#125;</span>
&nbsp;
   <span style="color: #000000; font-weight: bold;">public</span> <span style="color: #000066; font-weight: bold;">void</span> setList<span style="color: #009900;">&#40;</span>List<span style="color: #339933;">&lt;</span>User<span style="color: #339933;">&gt;</span> list<span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
     <span style="color: #000000; font-weight: bold;">this</span>.<span style="color: #006633;">list</span> <span style="color: #339933;">=</span> list<span style="color: #339933;">;</span>
   <span style="color: #009900;">&#125;</span>
<span style="color: #009900;">&#125;</span></pre></div></div>

<p>La anotación @Create nos permite declarar que un método se ejecute al momento que un componente es creado. Momento apropiado para cargar toda la información que sólo debe ser obtenida una vez.</p>
<p>La anotación @Scope(ScopeType.PAGE) nos permite establecer un contexto para el componente de seam, en este caso que el componente exista mientras la página esta activa. Se pueden utilizar otros contextos como por ejemplo Conversation o Session, sin embargo no es recomendable usar el contexto session a menos que sea estrictamente necesario pues sin una adecuada adminstración la memoria requerida por aplicación puede dispararse.</p>
<p><strong>A modo de conclusión</strong></p>
<p>Es una buena práctica centralizar la información de carga estática en un solo método y combinado con el scope Page mejor, pues el uso de memoria en el servidor es mínimo.</p>


<p>Sin posts relacionados.</p><div class="feedflare">
<a href="http://feeds.feedburner.com/~f/DesarrolloEnWeb?a=7pVas7u9"><img src="http://feeds.feedburner.com/~f/DesarrolloEnWeb?d=41" border="0"></img></a> <a href="http://feeds.feedburner.com/~f/DesarrolloEnWeb?a=i8BjBMcn"><img src="http://feeds.feedburner.com/~f/DesarrolloEnWeb?d=52" border="0"></img></a>
</div>]]></content:encoded>
			<wfw:commentRss>http://blogs.antartec.com/desarrolloweb/2009/02/seam_uso_de_create/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Carga dinámica de combos usando JSF y richfaces</title>
		<link>http://blogs.antartec.com/desarrolloweb/2009/01/carga-dinamica-de-combos-usando-jsf-y-richfaces/</link>
		<comments>http://blogs.antartec.com/desarrolloweb/2009/01/carga-dinamica-de-combos-usando-jsf-y-richfaces/#comments</comments>
		<pubDate>Wed, 28 Jan 2009 22:36:59 +0000</pubDate>
		<dc:creator>Giancarlo Corzo</dc:creator>
				<category><![CDATA[Frameworks]]></category>
		<category><![CDATA[AJAX]]></category>
		<category><![CDATA[jsf]]></category>
		<category><![CDATA[RichFaces]]></category>

		<guid isPermaLink="false">http://blogs.antartec.com/desarrolloweb/?p=93</guid>
		<description><![CDATA[
			
				
			
		
La carga dinámica de un combo basado en la selección de un combo previo es un problema relativamente clásico y que ha sido abordado de distintas maneras a lo largo del tiempo.
En este post queremos mostrarles como es que nosotros abordamos el tema usando componentes JSF y de Richfaces para resolver el problema.

Para este ejemplo [...]


Sin posts relacionados.]]></description>
			<content:encoded><![CDATA[<div class="tweetmeme_button" style="float: right; margin-left: 10px;">
			<a href="http://api.tweetmeme.com/share?url=http%3A%2F%2Fblogs.antartec.com%2Fdesarrolloweb%2F2009%2F01%2Fcarga-dinamica-de-combos-usando-jsf-y-richfaces%2F"><br />
				<img src="http://api.tweetmeme.com/imagebutton.gif?url=http%3A%2F%2Fblogs.antartec.com%2Fdesarrolloweb%2F2009%2F01%2Fcarga-dinamica-de-combos-usando-jsf-y-richfaces%2F&amp;source=giancorzo&amp;style=normal&amp;service=bit.ly" height="61" width="50" /><br />
			</a>
		</div>
<p>La carga dinámica de un combo basado en la selección de un combo previo es un problema relativamente clásico y que ha sido abordado de distintas maneras a lo largo del tiempo.</p>
<p>En este post queremos mostrarles como es que nosotros abordamos el tema usando componentes JSF y de Richfaces para resolver el problema.</p>
<p><span id="more-93"></span><br />
Para este ejemplo usaremos 2 entidades (Ciudad y Distrito) donde una ciudad tiene múltiples distritos asociados y para el caso práctico asumiremos que ambas solo tienen un id y un nombre.</p>

<div class="wp_syntax"><div class="code"><pre class="java" style="font-family:monospace;">@<span style="color: #003399;">Entity</span>
@Table<span style="color: #009900;">&#40;</span>name <span style="color: #339933;">=</span> <span style="color: #0000ff;">&quot;CIUDAD&quot;</span><span style="color: #009900;">&#41;</span>
<span style="color: #000000; font-weight: bold;">public</span> <span style="color: #000000; font-weight: bold;">class</span> Ciudad <span style="color: #000000; font-weight: bold;">implements</span> <span style="color: #003399;">Serializable</span> <span style="color: #009900;">&#123;</span>
&nbsp;
    @Id
    @GeneratedValue<span style="color: #009900;">&#40;</span>strategy <span style="color: #339933;">=</span> GenerationType.<span style="color: #006633;">AUTO</span><span style="color: #009900;">&#41;</span>
    @Column<span style="color: #009900;">&#40;</span>name <span style="color: #339933;">=</span> <span style="color: #0000ff;">&quot;ID_CIUDAD&quot;</span>, nullable <span style="color: #339933;">=</span> <span style="color: #000066; font-weight: bold;">false</span><span style="color: #009900;">&#41;</span>
    <span style="color: #000000; font-weight: bold;">private</span> <span style="color: #003399;">Integer</span> idCiudad<span style="color: #339933;">;</span>
&nbsp;
    @Length<span style="color: #009900;">&#40;</span>max<span style="color: #339933;">=</span><span style="color: #cc66cc;">45</span><span style="color: #009900;">&#41;</span>
    @Column<span style="color: #009900;">&#40;</span>name <span style="color: #339933;">=</span> <span style="color: #0000ff;">&quot;NOMBRE&quot;</span>,length<span style="color: #339933;">=</span><span style="color: #cc66cc;">45</span><span style="color: #009900;">&#41;</span>
    <span style="color: #000000; font-weight: bold;">private</span> <span style="color: #003399;">String</span> nombre<span style="color: #339933;">;</span>
<span style="color: #009900;">&#125;</span>
&nbsp;
@<span style="color: #003399;">Entity</span>
@Table<span style="color: #009900;">&#40;</span>name <span style="color: #339933;">=</span> <span style="color: #0000ff;">&quot;DISTRITO&quot;</span><span style="color: #009900;">&#41;</span>
<span style="color: #000000; font-weight: bold;">public</span> <span style="color: #000000; font-weight: bold;">class</span> Distrito <span style="color: #000000; font-weight: bold;">implements</span> <span style="color: #003399;">Serializable</span> <span style="color: #009900;">&#123;</span>
&nbsp;
    @Id
    @GeneratedValue<span style="color: #009900;">&#40;</span>strategy <span style="color: #339933;">=</span> GenerationType.<span style="color: #006633;">AUTO</span><span style="color: #009900;">&#41;</span>
    @Column<span style="color: #009900;">&#40;</span>name <span style="color: #339933;">=</span> <span style="color: #0000ff;">&quot;ID_CIUDAD&quot;</span>, nullable <span style="color: #339933;">=</span> <span style="color: #000066; font-weight: bold;">false</span><span style="color: #009900;">&#41;</span>
    <span style="color: #000000; font-weight: bold;">private</span> <span style="color: #003399;">Integer</span> idDistrito<span style="color: #339933;">;</span>
&nbsp;
    @Length<span style="color: #009900;">&#40;</span>max<span style="color: #339933;">=</span><span style="color: #cc66cc;">45</span><span style="color: #009900;">&#41;</span>
    @Column<span style="color: #009900;">&#40;</span>name <span style="color: #339933;">=</span> <span style="color: #0000ff;">&quot;NOMBRE&quot;</span>,length<span style="color: #339933;">=</span><span style="color: #cc66cc;">45</span><span style="color: #009900;">&#41;</span>
    <span style="color: #000000; font-weight: bold;">private</span> <span style="color: #003399;">String</span> nombre<span style="color: #339933;">;</span>
<span style="color: #009900;">&#125;</span></pre></div></div>

<p>Además tendremos un managed bean de JSF llamado testBean que nos servirá para almacenar la información temporal de la página.</p>

<div class="wp_syntax"><div class="code"><pre class="java" style="font-family:monospace;">@<span style="color: #003399;">Name</span><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">&quot;testBean&quot;</span><span style="color: #009900;">&#41;</span>
@Scope<span style="color: #009900;">&#40;</span>ScopeType.<span style="color: #006633;">CONVERSATION</span><span style="color: #009900;">&#41;</span>
<span style="color: #000000; font-weight: bold;">public</span> <span style="color: #000000; font-weight: bold;">class</span> TestBean <span style="color: #000000; font-weight: bold;">implements</span> <span style="color: #003399;">Serializable</span> <span style="color: #009900;">&#123;</span>
&nbsp;
    <span style="color: #000000; font-weight: bold;">private</span> <span style="color: #003399;">Integer</span> idCiudad <span style="color: #339933;">=</span> <span style="color: #339933;">-</span><span style="color: #cc66cc;">1</span><span style="color: #339933;">;</span> <span style="color: #666666; font-style: italic;">//Omitimos sus gets y sets</span>
    <span style="color: #000000; font-weight: bold;">private</span> <span style="color: #003399;">Integer</span> idDistrito <span style="color: #339933;">=</span> <span style="color: #339933;">-</span><span style="color: #cc66cc;">1</span><span style="color: #339933;">;</span><span style="color: #666666; font-style: italic;">//Omitimos sus gets y sets</span>
&nbsp;
    <span style="color: #000000; font-weight: bold;">public</span>  Map<span style="color: #339933;">&lt;</span>String,Integer<span style="color: #339933;">&gt;</span> getCiudadList<span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
        <span style="color: #003399;">String</span> query <span style="color: #339933;">=</span> <span style="color: #0000ff;">&quot;select new map(nombre as nombre, idCiudad as idCiudad) &quot;</span> <span style="color: #339933;">+</span>
                <span style="color: #0000ff;">&quot;from Ciudad order by nombre&quot;</span><span style="color: #339933;">;</span>
        <span style="color: #000000; font-weight: bold;">return</span> uiUtils.<span style="color: #006633;">getComboBox</span><span style="color: #009900;">&#40;</span>query, <span style="color: #0000ff;">&quot;nombre&quot;</span>, <span style="color: #0000ff;">&quot;idCiudad&quot;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
    <span style="color: #009900;">&#125;</span>
&nbsp;
    <span style="color: #000000; font-weight: bold;">public</span>  Map<span style="color: #339933;">&lt;</span>String,Integer<span style="color: #339933;">&gt;</span> getDistritoList<span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
        <span style="color: #003399;">String</span> query <span style="color: #339933;">=</span> <span style="color: #0000ff;">&quot;select new map(d.nombre as nombre, d.idDistrito as idDistrito) &quot;</span> <span style="color: #339933;">+</span>
                <span style="color: #0000ff;">&quot;from Distrito d where d.ciudad.idCiudad = &quot;</span> <span style="color: #339933;">+</span> idCiudad <span style="color: #339933;">+</span> <span style="color: #0000ff;">&quot; order by nombre&quot;</span><span style="color: #339933;">;</span>
        <span style="color: #000000; font-weight: bold;">return</span> uiUtils.<span style="color: #006633;">getComboBox</span><span style="color: #009900;">&#40;</span>query, <span style="color: #0000ff;">&quot;nombre&quot;</span>, <span style="color: #0000ff;">&quot;idDistrito&quot;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
    <span style="color: #009900;">&#125;</span>
&nbsp;
<span style="color: #009900;">&#125;</span></pre></div></div>

<p>Solo para simplificar el asunto el método getComboBox hace una consulta a la Base de datos y genera una estructura Map&amp;ltString,Integer&gt;</p>
<p>El signature del método es:</p>

<div class="wp_syntax"><div class="code"><pre class="java" style="font-family:monospace;"><span style="color: #000000; font-weight: bold;">public</span>  Map<span style="color: #339933;">&lt;</span>String,Integer<span style="color: #339933;">&gt;</span> getComboBox<span style="color: #009900;">&#40;</span><span style="color: #003399;">String</span> query, <span style="color: #003399;">String</span> value, <span style="color: #003399;">String</span> key<span style="color: #009900;">&#41;</span></pre></div></div>

<p>El código que corresponde a la parte de JSF se los presento a continuación:</p>

<div class="wp_syntax"><div class="code"><pre class="xml" style="font-family:monospace;"><span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;h:selectOneMenu</span> <span style="color: #000066;">value</span>=<span style="color: #ff0000;">&quot;#{testBean.idCiudad}&quot;</span> <span style="color: #000066;">style</span>=<span style="color: #ff0000;">&quot;width:200px;&quot;</span><span style="color: #000000; font-weight: bold;">&gt;</span></span>
  <span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;f:selectItem</span> <span style="color: #000066;">itemLabel</span>=<span style="color: #ff0000;">&quot;#{messages['comun.selectOneMenu.seleccione']}&quot;</span> <span style="color: #000066;">itemValue</span>=<span style="color: #ff0000;">&quot;-1&quot;</span> <span style="color: #000000; font-weight: bold;">/&gt;</span></span>
  <span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;f:selectItems</span> <span style="color: #000066;">value</span>=<span style="color: #ff0000;">&quot;#{testBean.cuidades}&quot;</span><span style="color: #000000; font-weight: bold;">/&gt;</span></span>
  <span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;a4j:support</span> <span style="color: #000066;">event</span>=<span style="color: #ff0000;">&quot;onclick&quot;</span> <span style="color: #000066;">reRender</span>=<span style="color: #ff0000;">&quot;distritosPanel&quot;</span><span style="color: #000000; font-weight: bold;">/&gt;</span></span>
<span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;/h:selectOneMenu<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>
<span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;a4j:outputPanel</span> <span style="color: #000066;">id</span>=<span style="color: #ff0000;">&quot;distritosPanel&quot;</span><span style="color: #000000; font-weight: bold;">&gt;</span></span>
  <span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;ui:fragment</span> <span style="color: #000066;">rendered</span>=<span style="color: #ff0000;">&quot;#{testBean.idCiudad ne -1}&quot;</span><span style="color: #000000; font-weight: bold;">&gt;</span></span>
    <span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;h:selectOneMenu</span> <span style="color: #000066;">value</span>=<span style="color: #ff0000;">&quot;#{testBean.idDistrito}&quot;</span> <span style="color: #000066;">style</span>=<span style="color: #ff0000;">&quot;width:200px;&quot;</span><span style="color: #000000; font-weight: bold;">&gt;</span></span>
       <span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;f:selectItem</span> <span style="color: #000066;">itemLabel</span>=<span style="color: #ff0000;">&quot;#{messages['comun.selectOneMenu.seleccione']}&quot;</span> <span style="color: #000066;">itemValue</span>=<span style="color: #ff0000;">&quot;-1&quot;</span> <span style="color: #000000; font-weight: bold;">/&gt;</span></span>
       <span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;f:selectItems</span> <span style="color: #000066;">value</span>=<span style="color: #ff0000;">&quot;#{testBean.distritos}&quot;</span><span style="color: #000000; font-weight: bold;">/&gt;</span></span>
    <span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;/h:selectOneMenu<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>
  <span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;/ui:fragment<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>
<span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;/a4j:outputPanel<span style="color: #000000; font-weight: bold;">&gt;</span></span></span></pre></div></div>

<p>Como pueden ver es muy sencillo, cada combo tiene dos propiedades importantes, la primera es la que almacenará el resultado de la selección en este caso idCiudad y idDistrito, la segunda es la lista de opciones del combo el cual se obtiene de una propiedad List&lt;SelectItem&gt;, esta lista es generada en el managed bean haciendo consultas a la base de datos.</p>
<p>Los componentes JSF por default no tienen soporte AJAX, lo que significa que tendrían que hacer un submit cada vez que quisieran recargar una sección de la página, es por esto que utilizamos el tag a4j:support que nos permite darle una naturaleza AJAX al componente JSF.</p>

<div class="wp_syntax"><div class="code"><pre class="xml" style="font-family:monospace;"><span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;a4j:support</span> <span style="color: #000066;">event</span>=<span style="color: #ff0000;">&quot;onclick&quot;</span>  <span style="color: #000066;">reRender</span>=<span style="color: #ff0000;">&quot;distritosPanel&quot;</span><span style="color: #000000; font-weight: bold;">/&gt;</span></span></pre></div></div>

<p>Como pueden ver al tag a4j:support tiene 2 propiedades, la primera es el evento que dispara la acción, este podría ser onclick, onmouseover, onmouseout, en este caso utilizamos onchange.La segunda propiedad es el parámetro reRender que le dice al componente las secciones de código que deben ser refrescadas una vez que el request AJAX haya terminado.</p>
<p>De esta manera podemos conseguir cargar dinámicamente un combo JSF mediante AJAX.</p>
<p><strong>Más información</strong></p>
<ul>
<li><a href="http://livedemo.exadel.com/richfaces-demo/richfaces/actionparam.jsf?c=actionparam&amp;tab=usage" target="_blank">Rich faces Demo</a></li>
<li><a href="http://java.sun.com/javaee/javaserverfaces/1.2/docs/tlddocs/index.html" target="_blank">Tag lib de JSF 1.2</a></li>
</ul>


<p>Sin posts relacionados.</p><div class="feedflare">
<a href="http://feeds.feedburner.com/~f/DesarrolloEnWeb?a=VAnViCDs"><img src="http://feeds.feedburner.com/~f/DesarrolloEnWeb?d=41" border="0"></img></a> <a href="http://feeds.feedburner.com/~f/DesarrolloEnWeb?a=CZmp0a1y"><img src="http://feeds.feedburner.com/~f/DesarrolloEnWeb?d=52" border="0"></img></a>
</div>]]></content:encoded>
			<wfw:commentRss>http://blogs.antartec.com/desarrolloweb/2009/01/carga-dinamica-de-combos-usando-jsf-y-richfaces/feed/</wfw:commentRss>
		<slash:comments>8</slash:comments>
		</item>
	</channel>
</rss>
