<?xml version="1.0" encoding="UTF-8"?>
<?xml-stylesheet type="text/xsl" media="screen" href="/~d/styles/rss2enclosuresfull.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/" xmlns:media="http://search.yahoo.com/mrss/" version="2.0">

<channel>
	<title>rails y más cosas</title>
	
	<link>http://www.railsymas.com</link>
	<description>Nuevas Tecnologías</description>
	<lastBuildDate>Sat, 28 Jan 2012 10:23:40 +0000</lastBuildDate>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.3.1</generator>
		<atom10:link xmlns:atom10="http://www.w3.org/2005/Atom" rel="self" type="application/rss+xml" href="http://feeds.feedburner.com/railsymas" /><feedburner:info xmlns:feedburner="http://rssnamespace.org/feedburner/ext/1.0" uri="railsymas" /><atom10:link xmlns:atom10="http://www.w3.org/2005/Atom" rel="hub" href="http://pubsubhubbub.appspot.com/" /><media:copyright>copyright railsymas.com</media:copyright><item>
		<title>Configurando ubuntu para roo</title>
		<link>http://www.railsymas.com/2012/01/27/configurando-ubuntu-para-roo/</link>
		<comments>http://www.railsymas.com/2012/01/27/configurando-ubuntu-para-roo/#comments</comments>
		<pubDate>Fri, 27 Jan 2012 17:38:26 +0000</pubDate>
		<dc:creator>admin</dc:creator>
				<category><![CDATA[spring roo]]></category>

		<guid isPermaLink="false">http://www.railsymas.com/?p=2656</guid>
		<description><![CDATA[Para poder tener la consola de spring roo operativa desde cualquier un terminal recien abierto tenemos que seguir los pasos que nos indica la documentación oficial Es fácil y rápido solamante tenemos que crear un enlace simbólico al lugar o path de nuestra computadora donde hemos descargado el proyecto de spring roo Creamos un enlace [...]]]></description>
			<content:encoded><![CDATA[<p>Para poder tener la consola de spring roo operativa desde cualquier un terminal recien abierto<br />
tenemos que seguir los pasos que nos indica la documentación oficial</p>
<p><span id="more-2656"></span></p>
<p>Es fácil y rápido solamante tenemos que crear un enlace simbólico al lugar o path de nuestra computadora donde hemos descargado el proyecto de spring roo</p>
<p>Creamos un enlace simbólico al sh de la instalción de roo sudo ln -s directorio de instalación de roo/bin/roo.sh /usr/bin/roo</p>
<p>para los usuarios de windows es directorio home de roo\bin  como path en las variables de entorno</p>
<p>Nos aparecerá un enlace como el siguiente</p>
<p><img src="http://www.railsymas.com/wp-content/uploads/2012/01/rooln.png" alt="" title="rooln" width="275" height="21" class="alignnone size-full wp-image-2659" /></p>
<p>es necesario tener instalado maven <a href="http://www.railsymas.com/2011/11/28/instalando-maven-en-ubuntu/"><b>instalando maven en ubuntu</b></a></p>
<img src="http://feeds.feedburner.com/~r/railsymas/~4/oHT3U_8Bp18" height="1" width="1"/>]]></content:encoded>
			<wfw:commentRss>http://www.railsymas.com/2012/01/27/configurando-ubuntu-para-roo/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Dojo framework javascript</title>
		<link>http://www.railsymas.com/2012/01/15/dojo-framework-javascript/</link>
		<comments>http://www.railsymas.com/2012/01/15/dojo-framework-javascript/#comments</comments>
		<pubDate>Sun, 15 Jan 2012 11:52:42 +0000</pubDate>
		<dc:creator>admin</dc:creator>
				<category><![CDATA[Nuevas Tecnologías]]></category>

		<guid isPermaLink="false">http://www.railsymas.com/?p=2623</guid>
		<description><![CDATA[Desde la página web oficial del proyecto nos podemos descargar sus librerias para empezar hacer ejemplos Enlace: http://dojotoolkit.org/ Actualmente spring js da soporte para dojo y spring roo como framework rad viene con los scaffold automatizados para dojo, por lo que esta herramienta se convierte en un elemento importante a conocer dentro del desarrollo de [...]]]></description>
			<content:encoded><![CDATA[<p>Desde la página web oficial del proyecto nos podemos descargar sus librerias para empezar hacer ejemplos</p>
<p>Enlace: <a href="http://dojotoolkit.org/">http://dojotoolkit.org/</a></p>
<p><span id="more-2623"></span></p>
<p><img src="http://www.railsymas.com/wp-content/uploads/2012/01/dojo2.png" alt="" title="dojo2" width="700" height="200" class="alignnone size-full wp-image-2626" /></p>
<p>Actualmente spring js da soporte para dojo y spring roo  como framework rad viene con los scaffold automatizados para dojo, por lo que esta herramienta se convierte en un elemento importante a conocer dentro del desarrollo de las aplicaciones web con el framework spring</p>
<p>Una vez descargado el proyecto vía zip o tar desempaquetamos en nuestra computadora</p>
<p><img src="http://www.railsymas.com/wp-content/uploads/2012/01/dojo1.png" alt="" title="dojo1" width="611" height="145" class="alignnone size-full wp-image-2629" /></p>
<p> Dijit (dojo widgets) un framework para construir interface html mediante widgets así como una librería de controladores preconstruidos, dijit depende de dojo</p>
<p> Dojo es el nucleo que incluye librerías que son útiles en muchos programs y constituyen un árbol de desarrollo denominado nucleo de dojo</p>
<p>dojox proyectos abiertos que no son 100 estables con las últimas características que puede que algunos navegadores no tengan un buen soporte.</p>
<p>Formulario con dos pestañas, primera imagen corresponde a los campos de datos personales</p>
<p><img src="http://www.railsymas.com/wp-content/uploads/2012/01/dojo3s.png" alt="" title="dojo3s" width="561" height="383" class="alignnone size-full wp-image-2633" /></p>
<p>La segunda pestaña corresponde a los datos de direcciones</p>
<p><img src="http://www.railsymas.com/wp-content/uploads/2012/01/dojos4.png" alt="" title="dojos4" width="551" height="371" class="alignnone size-full wp-image-2634" /></p>
<p>Código del formulario ejemplodojo.html que se encuentra al mismo nivel de los directorios dojo dijit y dojox</p>

<div class="wp_syntax"><table><tr><td class="line_numbers"><pre>1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
</pre></td><td class="code"><pre class="html4strict" style="font-family:monospace;"><span style="color: #009900;">&lt;<span style="color: #000000; font-weight: bold;">html</span>&gt;</span>
<span style="color: #009900;">&lt;<span style="color: #000000; font-weight: bold;">head</span>&gt;</span>
<span style="color: #009900;">&lt;<span style="color: #000000; font-weight: bold;">link</span> <span style="color: #000066;">rel</span><span style="color: #66cc66;">=</span><span style="color: #ff0000;">&quot;stylesheet&quot;</span> <span style="color: #000066;">type</span><span style="color: #66cc66;">=</span><span style="color: #ff0000;">&quot;text/css&quot;</span> <span style="color: #000066;">href</span><span style="color: #66cc66;">=</span><span style="color: #ff0000;">&quot;dojo/resources/dojo.css&quot;</span><span style="color: #66cc66;">/</span>&gt;</span>
<span style="color: #009900;">&lt;<span style="color: #000000; font-weight: bold;">link</span> <span style="color: #000066;">rel</span><span style="color: #66cc66;">=</span><span style="color: #ff0000;">&quot;stylesheet&quot;</span> <span style="color: #000066;">type</span><span style="color: #66cc66;">=</span><span style="color: #ff0000;">&quot;text/css&quot;</span> <span style="color: #000066;">href</span><span style="color: #66cc66;">=</span><span style="color: #ff0000;">&quot;dijit/themes/tundra/tundra.css&quot;</span><span style="color: #66cc66;">/</span>&gt;</span>
<span style="color: #009900;">&lt;<span style="color: #000000; font-weight: bold;">script</span> <span style="color: #000066;">language</span><span style="color: #66cc66;">=</span><span style="color: #ff0000;">&quot;javascript&quot;</span> <span style="color: #000066;">type</span><span style="color: #66cc66;">=</span><span style="color: #ff0000;">&quot;text/javascript&quot;</span> <span style="color: #000066;">src</span><span style="color: #66cc66;">=</span><span style="color: #ff0000;">&quot;dojo/dojo.js&quot;</span> djConfig<span style="color: #66cc66;">=</span><span style="color: #ff0000;">&quot;parseOnLoad :true&quot;</span>&gt;&lt;<span style="color: #66cc66;">/</span><span style="color: #000000; font-weight: bold;">script</span>&gt;</span>
&nbsp;
&nbsp;
<span style="color: #009900;">&lt;<span style="color: #000000; font-weight: bold;">style</span>&gt;</span>
.formularioContenedor {
&nbsp;
width:600px;
height:350px;
margin-top:30px;
margin-left:50px;
color:#3443B5;
}
&nbsp;
&nbsp;
<span style="color: #009900;">&lt;<span style="color: #66cc66;">/</span><span style="color: #000000; font-weight: bold;">style</span>&gt;</span>
&nbsp;
&nbsp;
&nbsp;
<span style="color: #009900;">&lt;<span style="color: #000000; font-weight: bold;">script</span>  <span style="color: #000066;">type</span><span style="color: #66cc66;">=</span><span style="color: #ff0000;">&quot;text/javascript&quot;</span>&gt;</span>
dojo.require(&quot;dojo.parser&quot;);
dojo.require(&quot;dijit.layout.ContentPane&quot; );
dojo.require(&quot;dijit.layout.TabContainer&quot; );
&nbsp;
<span style="color: #009900;">&lt;<span style="color: #66cc66;">/</span><span style="color: #000000; font-weight: bold;">script</span>&gt;</span>
&nbsp;
<span style="color: #009900;">&lt;<span style="color: #66cc66;">/</span><span style="color: #000000; font-weight: bold;">button</span>&gt;</span>
&nbsp;
&nbsp;
<span style="color: #009900;">&lt;<span style="color: #66cc66;">/</span><span style="color: #000000; font-weight: bold;">script</span>&gt;</span>
&nbsp;
<span style="color: #009900;">&lt;<span style="color: #66cc66;">/</span><span style="color: #000000; font-weight: bold;">head</span>&gt;</span>
<span style="color: #009900;">&lt;<span style="color: #000000; font-weight: bold;">body</span> <span style="color: #000066;">class</span><span style="color: #66cc66;">=</span><span style="color: #ff0000;">&quot;tundra&quot;</span>&gt;</span>
<span style="color: #009900;">&lt;<span style="color: #000000; font-weight: bold;">div</span> <span style="color: #000066;">class</span><span style="color: #66cc66;">=</span><span style="color: #ff0000;">&quot;formularioContenedor&quot;</span> dojoType<span style="color: #66cc66;">=</span><span style="color: #ff0000;">&quot;dijit.layout.TabContainer&quot;</span></span>
<span style="color: #009900;"><span style="color: #000066;">style</span><span style="color: #66cc66;">=</span><span style="color: #ff0000;">&quot;contenedor&quot;</span> &gt;</span>
&nbsp;
<span style="color: #009900;">&lt;<span style="color: #000000; font-weight: bold;">div</span> dojoType<span style="color: #66cc66;">=</span><span style="color: #ff0000;">&quot;dijit.layout.ContentPane&quot;</span> <span style="color: #000066;">title</span><span style="color: #66cc66;">=</span><span style="color: #ff0000;">&quot;Datos Personales&quot;</span>&gt;</span>
<span style="color: #009900;">&lt;<span style="color: #000000; font-weight: bold;">label</span> <span style="color: #000066;">for</span><span style="color: #66cc66;">=</span><span style="color: #ff0000;">&quot;nombre&quot;</span>&gt;</span>Introduce el nombre:<span style="color: #009900;">&lt;<span style="color: #66cc66;">/</span><span style="color: #000000; font-weight: bold;">label</span>&gt;</span>
<span style="color: #009900;">&lt;<span style="color: #000000; font-weight: bold;">br</span><span style="color: #66cc66;">/</span>&gt;</span>
<span style="color: #009900;">&lt;<span style="color: #000000; font-weight: bold;">input</span> <span style="color: #000066;">type</span><span style="color: #66cc66;">=</span><span style="color: #ff0000;">&quot;text&quot;</span> <span style="color: #000066;">name</span><span style="color: #66cc66;">=</span><span style="color: #ff0000;">&quot;nombre&quot;</span> <span style="color: #000066;">id</span><span style="color: #66cc66;">=</span><span style="color: #ff0000;">&quot;nombre&quot;</span></span>
<span style="color: #009900;"><span style="color: #000066;">size</span><span style="color: #66cc66;">=</span><span style="color: #ff0000;">&quot;30&quot;</span> <span style="color: #66cc66;">/</span>&gt;&lt;<span style="color: #000000; font-weight: bold;">br</span><span style="color: #66cc66;">/</span>&gt;</span>
<span style="color: #009900;">&lt;<span style="color: #000000; font-weight: bold;">label</span> <span style="color: #000066;">for</span><span style="color: #66cc66;">=</span><span style="color: #ff0000;">&quot;apellidos&quot;</span>&gt;</span>Introduce los apellidos:<span style="color: #009900;">&lt;<span style="color: #66cc66;">/</span><span style="color: #000000; font-weight: bold;">label</span>&gt;</span>
<span style="color: #009900;">&lt;<span style="color: #000000; font-weight: bold;">br</span><span style="color: #66cc66;">/</span>&gt;</span>
<span style="color: #009900;">&lt;<span style="color: #000000; font-weight: bold;">input</span> <span style="color: #000066;">type</span><span style="color: #66cc66;">=</span><span style="color: #ff0000;">&quot;text&quot;</span> <span style="color: #000066;">name</span><span style="color: #66cc66;">=</span><span style="color: #ff0000;">&quot;apellidos&quot;</span> <span style="color: #000066;">id</span><span style="color: #66cc66;">=</span><span style="color: #ff0000;">&quot;apellidos&quot;</span></span>
<span style="color: #009900;"><span style="color: #000066;">size</span><span style="color: #66cc66;">=</span><span style="color: #ff0000;">&quot;30&quot;</span> <span style="color: #66cc66;">/</span>&gt;&lt;<span style="color: #000000; font-weight: bold;">br</span><span style="color: #66cc66;">/</span>&gt;</span>
<span style="color: #009900;">&lt;<span style="color: #000000; font-weight: bold;">label</span> <span style="color: #000066;">for</span><span style="color: #66cc66;">=</span><span style="color: #ff0000;">&quot;edad&quot;</span>&gt;</span>edad:<span style="color: #009900;">&lt;<span style="color: #66cc66;">/</span><span style="color: #000000; font-weight: bold;">label</span>&gt;</span>
<span style="color: #009900;">&lt;<span style="color: #000000; font-weight: bold;">br</span><span style="color: #66cc66;">/</span>&gt;</span>
<span style="color: #009900;">&lt;<span style="color: #000000; font-weight: bold;">input</span> <span style="color: #000066;">type</span><span style="color: #66cc66;">=</span><span style="color: #ff0000;">&quot;text&quot;</span> <span style="color: #000066;">name</span><span style="color: #66cc66;">=</span><span style="color: #ff0000;">&quot;edad&quot;</span> <span style="color: #000066;">id</span><span style="color: #66cc66;">=</span><span style="color: #ff0000;">&quot;edad&quot;</span></span>
<span style="color: #009900;"><span style="color: #000066;">size</span><span style="color: #66cc66;">=</span><span style="color: #ff0000;">&quot;2&quot;</span> <span style="color: #66cc66;">/</span>&gt;&lt;<span style="color: #000000; font-weight: bold;">br</span><span style="color: #66cc66;">/</span>&gt;</span>
<span style="color: #009900;">&lt;<span style="color: #000000; font-weight: bold;">label</span> <span style="color: #000066;">for</span><span style="color: #66cc66;">=</span><span style="color: #ff0000;">&quot;telefono&quot;</span>&gt;</span>Tel<span style="color: #ddbb00;">&amp;eacute;</span>fono de  casa:<span style="color: #009900;">&lt;<span style="color: #66cc66;">/</span><span style="color: #000000; font-weight: bold;">label</span>&gt;</span>
<span style="color: #009900;">&lt;<span style="color: #000000; font-weight: bold;">br</span><span style="color: #66cc66;">/</span>&gt;</span>
<span style="color: #009900;">&lt;<span style="color: #000000; font-weight: bold;">input</span> <span style="color: #000066;">type</span><span style="color: #66cc66;">=</span><span style="color: #ff0000;">&quot;text&quot;</span> <span style="color: #000066;">name</span><span style="color: #66cc66;">=</span><span style="color: #ff0000;">&quot;home_phone&quot;</span> <span style="color: #000066;">id</span><span style="color: #66cc66;">=</span><span style="color: #ff0000;">&quot;home_phone&quot;</span></span>
<span style="color: #009900;"><span style="color: #000066;">size</span><span style="color: #66cc66;">=</span><span style="color: #ff0000;">&quot;30&quot;</span> <span style="color: #66cc66;">/</span>&gt;&lt;<span style="color: #000000; font-weight: bold;">br</span><span style="color: #66cc66;">/</span>&gt;</span>
<span style="color: #009900;">&lt;<span style="color: #66cc66;">/</span><span style="color: #000000; font-weight: bold;">div</span>&gt;</span>
&nbsp;
<span style="color: #009900;">&lt;<span style="color: #000000; font-weight: bold;">div</span> dojoType<span style="color: #66cc66;">=</span><span style="color: #ff0000;">&quot;dijit.layout.ContentPane&quot;</span> <span style="color: #000066;">title</span><span style="color: #66cc66;">=</span><span style="color: #ff0000;">&quot;Direcciones&quot;</span>&gt;</span>
&nbsp;
<span style="color: #009900;">&lt;<span style="color: #000000; font-weight: bold;">label</span> <span style="color: #000066;">for</span><span style="color: #66cc66;">=</span><span style="color: #ff0000;">&quot;codigopostal&quot;</span>&gt;</span>Direcci<span style="color: #ddbb00;">&amp;oacute;</span>n de correo postal:<span style="color: #009900;">&lt;<span style="color: #66cc66;">/</span><span style="color: #000000; font-weight: bold;">label</span>&gt;</span>
<span style="color: #009900;">&lt;<span style="color: #000000; font-weight: bold;">br</span><span style="color: #66cc66;">/</span>&gt;</span>
<span style="color: #009900;">&lt;<span style="color: #000000; font-weight: bold;">input</span> <span style="color: #000066;">type</span><span style="color: #66cc66;">=</span><span style="color: #ff0000;">&quot;text&quot;</span> <span style="color: #000066;">name</span><span style="color: #66cc66;">=</span><span style="color: #ff0000;">&quot;codigopostal&quot;</span> <span style="color: #000066;">id</span><span style="color: #66cc66;">=</span><span style="color: #ff0000;">&quot;codigopostal&quot;</span></span>
<span style="color: #009900;"><span style="color: #000066;">size</span><span style="color: #66cc66;">=</span><span style="color: #ff0000;">&quot;30&quot;</span> <span style="color: #66cc66;">/</span>&gt;&lt;<span style="color: #000000; font-weight: bold;">br</span><span style="color: #66cc66;">/</span>&gt;</span>
<span style="color: #009900;">&lt;<span style="color: #000000; font-weight: bold;">label</span> <span style="color: #000066;">for</span><span style="color: #66cc66;">=</span><span style="color: #ff0000;">&quot;direccion&quot;</span>&gt;</span>Direcci<span style="color: #ddbb00;">&amp;oacute;</span>n:<span style="color: #009900;">&lt;<span style="color: #66cc66;">/</span><span style="color: #000000; font-weight: bold;">label</span>&gt;</span>
<span style="color: #009900;">&lt;<span style="color: #000000; font-weight: bold;">br</span><span style="color: #66cc66;">/</span>&gt;</span>
<span style="color: #009900;">&lt;<span style="color: #000000; font-weight: bold;">input</span> <span style="color: #000066;">type</span><span style="color: #66cc66;">=</span><span style="color: #ff0000;">&quot;text&quot;</span> <span style="color: #000066;">name</span><span style="color: #66cc66;">=</span><span style="color: #ff0000;">&quot;direccion&quot;</span> <span style="color: #000066;">id</span><span style="color: #66cc66;">=</span><span style="color: #ff0000;">&quot;direccion&quot;</span> <span style="color: #000066;">size</span><span style="color: #66cc66;">=</span><span style="color: #ff0000;">&quot;50&quot;</span> <span style="color: #66cc66;">/</span>&gt;&lt;<span style="color: #000000; font-weight: bold;">br</span><span style="color: #66cc66;">/</span>&gt;</span>
<span style="color: #009900;">&lt;<span style="color: #66cc66;">/</span><span style="color: #000000; font-weight: bold;">div</span>&gt;</span>
<span style="color: #009900;">&lt;<span style="color: #66cc66;">/</span><span style="color: #000000; font-weight: bold;">div</span>&gt;</span>
&nbsp;
&nbsp;
<span style="color: #009900;">&lt;<span style="color: #66cc66;">/</span><span style="color: #000000; font-weight: bold;">body</span>&gt;</span>
<span style="color: #009900;">&lt;<span style="color: #66cc66;">/</span><span style="color: #000000; font-weight: bold;">html</span>&gt;</span></pre></td></tr></table></div>

<p>Se modifica el código del anterior formulario para dar lugar a la validación de los campos .  creamos un contenedor panel con dos pestañas en cada una de las cuales tenemos un formulario con una serie de dastos para completar  se procede a la validación de cada uno de los elementos del formulario y se muestra un mensaje de alerta en el caso de no estar completados los campos del formulario. Si no pusieramos el script para contralar el envio no saldrían indicados todo los errores a la vez al pulsar enviar sino<br />
inmediatamente al escribir sobre un campo y no ajustarse en el formato</p>
<p>Ventana emergente de aviso<br />
<img src="http://www.railsymas.com/wp-content/uploads/2012/01/dojom1.png" alt="" title="dojom1" width="417" height="152" class="alignnone size-full wp-image-2640" /></p>
<p>imagen validación campos<br />
<img src="http://www.railsymas.com/wp-content/uploads/2012/01/dojom2.png" alt="" title="dojom2" width="515" height="251" class="alignnone size-full wp-image-2642" /></p>
<p>mensaje al nombre<br />
<img src="http://www.railsymas.com/wp-content/uploads/2012/01/dojom21.png" alt="" title="dojom2" width="515" height="251" class="alignnone size-full wp-image-2643" /></p>
<p>mensaje de edad para reclamar campo requerido</p>
<p><img src="http://www.railsymas.com/wp-content/uploads/2012/01/dojom4.png" alt="" title="dojom4" width="413" height="46" class="alignnone size-full wp-image-2645" /></p>
<p>dentro de la pestaña de direcciones al enviar los datos mal </p>
<p><img src="http://www.railsymas.com/wp-content/uploads/2012/01/dojom5.png" alt="" title="dojom5" width="499" height="224" class="alignnone size-full wp-image-2647" /></p>
<p>indicando fallo en el código de correos mal introducido</p>
<p><img src="http://www.railsymas.com/wp-content/uploads/2012/01/dojom6.png" alt="" title="dojom6" width="432" height="181" class="alignnone size-full wp-image-2650" /></p>
<p>Modificando el código anterior para añadir formularios validados a las pestañas</p>

<div class="wp_syntax"><table><tr><td class="line_numbers"><pre>1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
</pre></td><td class="code"><pre class="html4strict" style="font-family:monospace;"><span style="color: #009900;">&lt;<span style="color: #000000; font-weight: bold;">html</span>&gt;</span>
<span style="color: #009900;">&lt;<span style="color: #000000; font-weight: bold;">head</span>&gt;</span>
<span style="color: #009900;">&lt;<span style="color: #000000; font-weight: bold;">link</span> <span style="color: #000066;">rel</span><span style="color: #66cc66;">=</span><span style="color: #ff0000;">&quot;stylesheet&quot;</span> <span style="color: #000066;">type</span><span style="color: #66cc66;">=</span><span style="color: #ff0000;">&quot;text/css&quot;</span> <span style="color: #000066;">href</span><span style="color: #66cc66;">=</span><span style="color: #ff0000;">&quot;dojo/resources/dojo.css&quot;</span><span style="color: #66cc66;">/</span>&gt;</span>
<span style="color: #009900;">&lt;<span style="color: #000000; font-weight: bold;">link</span> <span style="color: #000066;">rel</span><span style="color: #66cc66;">=</span><span style="color: #ff0000;">&quot;stylesheet&quot;</span> <span style="color: #000066;">type</span><span style="color: #66cc66;">=</span><span style="color: #ff0000;">&quot;text/css&quot;</span> <span style="color: #000066;">href</span><span style="color: #66cc66;">=</span><span style="color: #ff0000;">&quot;dijit/themes/tundra/tundra.css&quot;</span><span style="color: #66cc66;">/</span>&gt;</span>
<span style="color: #009900;">&lt;<span style="color: #000000; font-weight: bold;">script</span> <span style="color: #000066;">language</span><span style="color: #66cc66;">=</span><span style="color: #ff0000;">&quot;javascript&quot;</span> <span style="color: #000066;">type</span><span style="color: #66cc66;">=</span><span style="color: #ff0000;">&quot;text/javascript&quot;</span> <span style="color: #000066;">src</span><span style="color: #66cc66;">=</span><span style="color: #ff0000;">&quot;dojo/dojo.js&quot;</span> djConfig<span style="color: #66cc66;">=</span><span style="color: #ff0000;">&quot;isDebug:false, parseOnLoad :true&quot;</span>&gt;&lt;<span style="color: #66cc66;">/</span><span style="color: #000000; font-weight: bold;">script</span>&gt;</span>
&nbsp;
&nbsp;
<span style="color: #009900;">&lt;<span style="color: #000000; font-weight: bold;">style</span>&gt;</span>
.formularioContenedor {
&nbsp;
width:600px;
height:350px;
margin-top:30px;
margin-left:50px;
color:#3443B5;
}
&nbsp;
&nbsp;
<span style="color: #009900;">&lt;<span style="color: #66cc66;">/</span><span style="color: #000000; font-weight: bold;">style</span>&gt;</span>
&nbsp;
&nbsp;
&nbsp;
<span style="color: #009900;">&lt;<span style="color: #000000; font-weight: bold;">script</span>  <span style="color: #000066;">type</span><span style="color: #66cc66;">=</span><span style="color: #ff0000;">&quot;text/javascript&quot;</span>&gt;</span>
&nbsp;
&nbsp;
&nbsp;
dojo.require(&quot;dojo.parser&quot;);
dojo.require(&quot;dijit.layout.ContentPane&quot; );
dojo.require(&quot;dijit.layout.TabContainer&quot; );
dojo.require(&quot;dijit.form.ValidationTextBox&quot; );
dojo.require('dijit.form.Button');
dojo.require('dijit.form.Form');
dojo.require(&quot;dojox.validate.web&quot;);
dojo.require(&quot;dojox.validate&quot;);
&nbsp;
&nbsp;
<span style="color: #009900;">&lt;<span style="color: #66cc66;">/</span><span style="color: #000000; font-weight: bold;">script</span>&gt;</span>
&nbsp;
<span style="color: #009900;">&lt;<span style="color: #66cc66;">/</span><span style="color: #000000; font-weight: bold;">button</span>&gt;</span>
&nbsp;
&nbsp;
<span style="color: #009900;">&lt;<span style="color: #66cc66;">/</span><span style="color: #000000; font-weight: bold;">script</span>&gt;</span>
&nbsp;
&nbsp;
&nbsp;
&nbsp;
<span style="color: #009900;">&lt;<span style="color: #66cc66;">/</span><span style="color: #000000; font-weight: bold;">head</span>&gt;</span>
<span style="color: #009900;">&lt;<span style="color: #000000; font-weight: bold;">body</span> <span style="color: #000066;">class</span><span style="color: #66cc66;">=</span><span style="color: #ff0000;">&quot;tundra&quot;</span>&gt;</span>
<span style="color: #009900;">&lt;<span style="color: #000000; font-weight: bold;">div</span> <span style="color: #000066;">class</span><span style="color: #66cc66;">=</span><span style="color: #ff0000;">&quot;formularioContenedor&quot;</span> dojoType<span style="color: #66cc66;">=</span><span style="color: #ff0000;">&quot;dijit.layout.TabContainer&quot;</span></span>
<span style="color: #009900;"><span style="color: #000066;">style</span><span style="color: #66cc66;">=</span><span style="color: #ff0000;">&quot;contenedor&quot;</span> &gt;</span>
&nbsp;
&nbsp;
<span style="color: #009900;">&lt;<span style="color: #000000; font-weight: bold;">div</span> dojoType<span style="color: #66cc66;">=</span><span style="color: #ff0000;">&quot;dijit.layout.ContentPane&quot;</span> <span style="color: #000066;">title</span><span style="color: #66cc66;">=</span><span style="color: #ff0000;">&quot;Datos Personales&quot;</span>&gt;</span>
<span style="color: #009900;">&lt;<span style="color: #000000; font-weight: bold;">form</span> dojoType<span style="color: #66cc66;">=</span><span style="color: #ff0000;">&quot;dijit.form.Form&quot;</span> <span style="color: #000066;">action</span><span style="color: #66cc66;">=</span><span style="color: #ff0000;">&quot;datospersonales&quot;</span> <span style="color: #000066;">method</span><span style="color: #66cc66;">=</span><span style="color: #ff0000;">&quot;get&quot;</span>&gt;</span>
&nbsp;
&nbsp;
&nbsp;
<span style="color: #009900;">&lt;<span style="color: #000000; font-weight: bold;">script</span> <span style="color: #000066;">type</span><span style="color: #66cc66;">=</span><span style="color: #ff0000;">&quot;dojo/method&quot;</span> event<span style="color: #66cc66;">=</span><span style="color: #ff0000;">&quot;onSubmit&quot;</span>&gt;</span>
 if (this.validate()) {
   return confirm('Datos bien introducidos pulsa aceptar');
 } else {
     alert('Existen datos mal introducidos revisa el formulario');
    return false;
 }
<span style="color: #009900;">&lt;<span style="color: #66cc66;">/</span><span style="color: #000000; font-weight: bold;">script</span>&gt;</span>
<span style="color: #009900;">&lt;<span style="color: #000000; font-weight: bold;">label</span> <span style="color: #000066;">for</span><span style="color: #66cc66;">=</span><span style="color: #ff0000;">&quot;nombre&quot;</span>&gt;</span>Introduce el nombre:<span style="color: #009900;">&lt;<span style="color: #66cc66;">/</span><span style="color: #000000; font-weight: bold;">label</span>&gt;</span>
<span style="color: #009900;">&lt;<span style="color: #000000; font-weight: bold;">br</span><span style="color: #66cc66;">/</span>&gt;</span>
<span style="color: #009900;">&lt;<span style="color: #000000; font-weight: bold;">input</span> <span style="color: #000066;">type</span><span style="color: #66cc66;">=</span><span style="color: #ff0000;">&quot;text&quot;</span> <span style="color: #000066;">name</span><span style="color: #66cc66;">=</span><span style="color: #ff0000;">&quot;nombre&quot;</span> <span style="color: #000066;">id</span><span style="color: #66cc66;">=</span><span style="color: #ff0000;">&quot;nombre&quot;</span> required<span style="color: #66cc66;">=</span><span style="color: #ff0000;">&quot;true&quot;</span> dojoType<span style="color: #66cc66;">=</span><span style="color: #ff0000;">&quot;dijit.form.ValidationTextBox&quot;</span> missingMessage<span style="color: #66cc66;">=</span><span style="color: #ff0000;">&quot;No has introducido tu nombre&quot;</span> <span style="color: #000066;">size</span><span style="color: #66cc66;">=</span><span style="color: #ff0000;">&quot;30&quot;</span> <span style="color: #66cc66;">/</span>&gt;&lt;<span style="color: #000000; font-weight: bold;">br</span><span style="color: #66cc66;">/</span>&gt;</span>
<span style="color: #009900;">&lt;<span style="color: #000000; font-weight: bold;">label</span> <span style="color: #000066;">for</span><span style="color: #66cc66;">=</span><span style="color: #ff0000;">&quot;apellidos&quot;</span>&gt;</span>Introduce los apellidos:<span style="color: #009900;">&lt;<span style="color: #66cc66;">/</span><span style="color: #000000; font-weight: bold;">label</span>&gt;</span>
<span style="color: #009900;">&lt;<span style="color: #000000; font-weight: bold;">br</span><span style="color: #66cc66;">/</span>&gt;</span>
<span style="color: #009900;">&lt;<span style="color: #000000; font-weight: bold;">input</span> <span style="color: #000066;">type</span><span style="color: #66cc66;">=</span><span style="color: #ff0000;">&quot;text&quot;</span> <span style="color: #000066;">name</span><span style="color: #66cc66;">=</span><span style="color: #ff0000;">&quot;apellidos&quot;</span> <span style="color: #000066;">id</span><span style="color: #66cc66;">=</span><span style="color: #ff0000;">&quot;apellidos&quot;</span>   required<span style="color: #66cc66;">=</span><span style="color: #ff0000;">&quot;true&quot;</span> dojoType<span style="color: #66cc66;">=</span><span style="color: #ff0000;">&quot;dijit.form.ValidationTextBox&quot;</span>   missingMessage<span style="color: #66cc66;">=</span><span style="color: #ff0000;">&quot;No has introducido tus apellidos&quot;</span> plaseHolder<span style="color: #66cc66;">=</span><span style="color: #ff0000;">&quot;apellidos&quot;</span><span style="color: #66cc66;">/</span>&gt;</span>
  <span style="color: #009900;">&lt;<span style="color: #000000; font-weight: bold;">br</span><span style="color: #66cc66;">/</span>&gt;</span>
<span style="color: #009900;">&lt;<span style="color: #000000; font-weight: bold;">label</span> <span style="color: #000066;">for</span><span style="color: #66cc66;">=</span><span style="color: #ff0000;">&quot;edad&quot;</span>&gt;</span>edad:<span style="color: #009900;">&lt;<span style="color: #66cc66;">/</span><span style="color: #000000; font-weight: bold;">label</span>&gt;</span>
<span style="color: #009900;">&lt;<span style="color: #000000; font-weight: bold;">br</span><span style="color: #66cc66;">/</span>&gt;</span>
<span style="color: #009900;">&lt;<span style="color: #000000; font-weight: bold;">input</span> <span style="color: #000066;">type</span><span style="color: #66cc66;">=</span><span style="color: #ff0000;">&quot;text&quot;</span> <span style="color: #000066;">name</span><span style="color: #66cc66;">=</span><span style="color: #ff0000;">&quot;edad&quot;</span> <span style="color: #000066;">id</span><span style="color: #66cc66;">=</span><span style="color: #ff0000;">&quot;edad&quot;</span> required<span style="color: #66cc66;">=</span><span style="color: #ff0000;">&quot;true&quot;</span> <span style="color: #000066;">size</span><span style="color: #66cc66;">=</span><span style="color: #ff0000;">&quot;2&quot;</span>  data-dojo-<span style="color: #000066;">type</span><span style="color: #66cc66;">=</span><span style="color: #ff0000;">&quot;dijit.form.ValidationTextBox&quot;</span></span>
<span style="color: #009900;">    data-dojo-props<span style="color: #66cc66;">=</span><span style="color: #ff0000;">&quot;validator:dojox.validate.isInRange,   constraints:{ min:1, max:100 },   invalidMessage:'no es un n&amp;uacute;mero correcto'&quot;</span> missingMessage<span style="color: #66cc66;">=</span><span style="color: #ff0000;">&quot;No has introducido tu edad&quot;</span> <span style="color: #66cc66;">/</span>&gt;&lt;<span style="color: #000000; font-weight: bold;">br</span><span style="color: #66cc66;">/</span>&gt;</span>
<span style="color: #009900;">&lt;<span style="color: #000000; font-weight: bold;">label</span> <span style="color: #000066;">for</span><span style="color: #66cc66;">=</span><span style="color: #ff0000;">&quot;telefono&quot;</span>&gt;</span>Tel<span style="color: #ddbb00;">&amp;eacute;</span>fono de  casa:<span style="color: #009900;">&lt;<span style="color: #66cc66;">/</span><span style="color: #000000; font-weight: bold;">label</span>&gt;</span>
<span style="color: #009900;">&lt;<span style="color: #000000; font-weight: bold;">br</span><span style="color: #66cc66;">/</span>&gt;</span>
<span style="color: #009900;">&lt;<span style="color: #000000; font-weight: bold;">input</span> <span style="color: #000066;">type</span><span style="color: #66cc66;">=</span><span style="color: #ff0000;">&quot;text&quot;</span> <span style="color: #000066;">name</span><span style="color: #66cc66;">=</span><span style="color: #ff0000;">&quot;telefono&quot;</span> <span style="color: #000066;">id</span><span style="color: #66cc66;">=</span><span style="color: #ff0000;">&quot;telefono&quot;</span> <span style="color: #000066;">size</span><span style="color: #66cc66;">=</span><span style="color: #ff0000;">&quot;30&quot;</span> required<span style="color: #66cc66;">=</span><span style="color: #ff0000;">&quot;true&quot;</span> data-dojo-<span style="color: #000066;">type</span><span style="color: #66cc66;">=</span><span style="color: #ff0000;">&quot;dijit.form.ValidationTextBox&quot;</span><span style="color: #66cc66;">/</span>&gt;&lt;<span style="color: #000000; font-weight: bold;">br</span><span style="color: #66cc66;">/</span>&gt;</span>
<span style="color: #009900;">&lt;<span style="color: #000000; font-weight: bold;">input</span> <span style="color: #000066;">type</span><span style="color: #66cc66;">=</span><span style="color: #ff0000;">&quot;submit&quot;</span> <span style="color: #000066;">label</span><span style="color: #66cc66;">=</span><span style="color: #ff0000;">&quot;enviar&quot;</span> <span style="color: #000066;">id</span><span style="color: #66cc66;">=</span><span style="color: #ff0000;">&quot;enviar&quot;</span> dojoType<span style="color: #66cc66;">=</span><span style="color: #ff0000;">&quot;dijit.form.Button&quot;</span><span style="color: #66cc66;">/</span>&gt;</span>
<span style="color: #009900;">&lt;<span style="color: #66cc66;">/</span><span style="color: #000000; font-weight: bold;">form</span>&gt;</span>
<span style="color: #009900;">&lt;<span style="color: #66cc66;">/</span><span style="color: #000000; font-weight: bold;">div</span>&gt;</span>
&nbsp;
<span style="color: #009900;">&lt;<span style="color: #000000; font-weight: bold;">div</span> dojoType<span style="color: #66cc66;">=</span><span style="color: #ff0000;">&quot;dijit.layout.ContentPane&quot;</span> <span style="color: #000066;">title</span><span style="color: #66cc66;">=</span><span style="color: #ff0000;">&quot;Direcciones&quot;</span>&gt;</span>
<span style="color: #009900;">&lt;<span style="color: #000000; font-weight: bold;">form</span> dojoType<span style="color: #66cc66;">=</span><span style="color: #ff0000;">&quot;dijit.form.Form&quot;</span> <span style="color: #000066;">action</span><span style="color: #66cc66;">=</span><span style="color: #ff0000;">&quot;direcciones&quot;</span> <span style="color: #000066;">method</span><span style="color: #66cc66;">=</span><span style="color: #ff0000;">&quot;get&quot;</span>&gt;</span>
<span style="color: #009900;">&lt;<span style="color: #000000; font-weight: bold;">script</span> <span style="color: #000066;">type</span><span style="color: #66cc66;">=</span><span style="color: #ff0000;">&quot;dojo/method&quot;</span> event<span style="color: #66cc66;">=</span><span style="color: #ff0000;">&quot;onSubmit&quot;</span>&gt;</span>
 if (this.validate()) {
   return confirm('Datos bien introducidos pulsa aceptar');
 } else {
     alert('Existen datos mal introducidos revisa el formulario');
    return false;
 }
<span style="color: #009900;">&lt;<span style="color: #66cc66;">/</span><span style="color: #000000; font-weight: bold;">script</span>&gt;</span>
&nbsp;
<span style="color: #009900;">&lt;<span style="color: #000000; font-weight: bold;">label</span> <span style="color: #000066;">for</span><span style="color: #66cc66;">=</span><span style="color: #ff0000;">&quot;codigopostal&quot;</span>&gt;</span>Direcci<span style="color: #ddbb00;">&amp;oacute;</span>n de correo postal:<span style="color: #009900;">&lt;<span style="color: #66cc66;">/</span><span style="color: #000000; font-weight: bold;">label</span>&gt;</span>
<span style="color: #009900;">&lt;<span style="color: #000000; font-weight: bold;">br</span><span style="color: #66cc66;">/</span>&gt;</span>
<span style="color: #009900;">&lt;<span style="color: #000000; font-weight: bold;">input</span> <span style="color: #000066;">type</span><span style="color: #66cc66;">=</span><span style="color: #ff0000;">&quot;text&quot;</span> <span style="color: #000066;">name</span><span style="color: #66cc66;">=</span><span style="color: #ff0000;">&quot;codigopostal&quot;</span> <span style="color: #000066;">id</span><span style="color: #66cc66;">=</span><span style="color: #ff0000;">&quot;codigopostal&quot;</span> required<span style="color: #66cc66;">=</span><span style="color: #ff0000;">&quot;true&quot;</span> <span style="color: #000066;">size</span><span style="color: #66cc66;">=</span><span style="color: #ff0000;">&quot;4&quot;</span> data-dojo-<span style="color: #000066;">type</span><span style="color: #66cc66;">=</span><span style="color: #ff0000;">&quot;dijit.form.ValidationTextBox&quot;</span> data-dojo-props<span style="color: #66cc66;">=</span><span style="color: #ff0000;">&quot;validator:dojox.validate.isNumberFormat, constraints:{ format:'(##)-###'} , invalidMessage:'no es un c&amp;oacute;digo correcto '&quot;</span></span>
<span style="color: #009900;"> missingMessage<span style="color: #66cc66;">=</span><span style="color: #ff0000;">&quot;No has introducido tu c&amp;oacute;digo postal&quot;</span> <span style="color: #66cc66;">/</span>&gt;</span>
<span style="color: #009900;">&lt;<span style="color: #000000; font-weight: bold;">br</span><span style="color: #66cc66;">/</span>&gt;</span>
<span style="color: #009900;">&lt;<span style="color: #000000; font-weight: bold;">label</span> <span style="color: #000066;">for</span><span style="color: #66cc66;">=</span><span style="color: #ff0000;">&quot;direccion&quot;</span>&gt;</span>Direcci<span style="color: #ddbb00;">&amp;oacute;</span>n de correo:<span style="color: #009900;">&lt;<span style="color: #66cc66;">/</span><span style="color: #000000; font-weight: bold;">label</span>&gt;</span>
<span style="color: #009900;">&lt;<span style="color: #000000; font-weight: bold;">br</span><span style="color: #66cc66;">/</span>&gt;</span>
<span style="color: #009900;">&lt;<span style="color: #000000; font-weight: bold;">input</span> <span style="color: #000066;">type</span><span style="color: #66cc66;">=</span><span style="color: #ff0000;">&quot;text&quot;</span> <span style="color: #000066;">name</span><span style="color: #66cc66;">=</span><span style="color: #ff0000;">&quot;direccion&quot;</span> <span style="color: #000066;">id</span><span style="color: #66cc66;">=</span><span style="color: #ff0000;">&quot;direccion&quot;</span> <span style="color: #000066;">size</span><span style="color: #66cc66;">=</span><span style="color: #ff0000;">&quot;50&quot;</span> required<span style="color: #66cc66;">=</span><span style="color: #ff0000;">&quot;true&quot;</span> data-dojo-<span style="color: #000066;">type</span><span style="color: #66cc66;">=</span><span style="color: #ff0000;">&quot;dijit.form.ValidationTextBox&quot;</span> missingMessage<span style="color: #66cc66;">=</span><span style="color: #ff0000;">&quot;No has introducido tu direcci&amp;oacute;n de correo&quot;</span> data-dojo-props<span style="color: #66cc66;">=</span><span style="color: #ff0000;">&quot;validator:dojox.validate.isEmailAddress, invalidMessage:'no es una direcci&amp;oacute;n de correo v&amp;aacute;lida '&quot;</span> <span style="color: #66cc66;">/</span>&gt;</span>
<span style="color: #009900;">&lt;<span style="color: #000000; font-weight: bold;">br</span><span style="color: #66cc66;">/</span>&gt;</span>
<span style="color: #009900;">&lt;<span style="color: #000000; font-weight: bold;">input</span> <span style="color: #000066;">type</span><span style="color: #66cc66;">=</span><span style="color: #ff0000;">&quot;submit&quot;</span> <span style="color: #000066;">label</span><span style="color: #66cc66;">=</span><span style="color: #ff0000;">&quot;enviar&quot;</span> <span style="color: #000066;">id</span><span style="color: #66cc66;">=</span><span style="color: #ff0000;">&quot;enviardireccion&quot;</span> dojoType<span style="color: #66cc66;">=</span><span style="color: #ff0000;">&quot;dijit.form.Button&quot;</span><span style="color: #66cc66;">/</span>&gt;</span>
<span style="color: #009900;">&lt;<span style="color: #66cc66;">/</span><span style="color: #000000; font-weight: bold;">form</span>&gt;</span>
<span style="color: #009900;">&lt;<span style="color: #66cc66;">/</span><span style="color: #000000; font-weight: bold;">div</span>&gt;</span>
<span style="color: #009900;">&lt;<span style="color: #66cc66;">/</span><span style="color: #000000; font-weight: bold;">div</span>&gt;</span>
&nbsp;
&nbsp;
<span style="color: #009900;">&lt;<span style="color: #66cc66;">/</span><span style="color: #000000; font-weight: bold;">body</span>&gt;</span>
<span style="color: #009900;">&lt;<span style="color: #66cc66;">/</span><span style="color: #000000; font-weight: bold;">html</span>&gt;</span></pre></td></tr></table></div>

<img src="http://feeds.feedburner.com/~r/railsymas/~4/GXy1_fHSUOw" height="1" width="1"/>]]></content:encoded>
			<wfw:commentRss>http://www.railsymas.com/2012/01/15/dojo-framework-javascript/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Aplicaciones rad con spring</title>
		<link>http://www.railsymas.com/2012/01/08/aplicaciones-rad-con-spring/</link>
		<comments>http://www.railsymas.com/2012/01/08/aplicaciones-rad-con-spring/#comments</comments>
		<pubDate>Sun, 08 Jan 2012 13:54:52 +0000</pubDate>
		<dc:creator>admin</dc:creator>
				<category><![CDATA[spring roo]]></category>

		<guid isPermaLink="false">http://www.railsymas.com/?p=2603</guid>
		<description><![CDATA[Introducción a una nueva forma de desarrollo dentro de las aplicaciones web para desarrolladores java El termino rad (rapid application development) no es un término nuevo ni exclusivo de spring roo. Forma parte de un nuevo paradigma de desarrollo que es aplicado por distintas tecnologías y comparten un denominador común, el desarrollo automatizado de partes [...]]]></description>
			<content:encoded><![CDATA[<p>Introducción a una nueva forma de desarrollo dentro de las aplicaciones web para desarrolladores java </p>
<p><span id="more-2603"></span></p>
<p> El termino rad (rapid application development) no es un término nuevo ni exclusivo de spring roo. Forma parte de un nuevo paradigma de desarrollo que es aplicado por distintas tecnologías y comparten un denominador común, el desarrollo automatizado de partes de la aplicación. Son muchos los frameworks que comparten esta filosofía, quizás uno de los primeros a nivel web fue ruby on rails del que toma nombre el blog, los programadores de python cuentan con django y en php5 tenemos frameworks como symfony y zend framework, java grails. Con esta enumeración de tecnologías, algunas de ellas con ejemplos aquí en railsymas estamos reflejando una preocupación o interés por hacer más sencillo y rápido el trabajo pesado , cotidiano y repetitivo que se suele dar en todo proyecto web con independencia de la tecnología usada</p>
<p>Spring roo da un rápido y fácil acceso a tecnologías estandar en java así como de terceros</p>
<p><img src="http://www.railsymas.com/wp-content/uploads/2012/01/rads1.png" alt="" title="rads1" width="634" height="374" class="alignnone size-full wp-image-2608" /></p>
<p>Para el desarrollo de estas aplicaciones se recomienda como requisitos iniciales tener instalados jdk de java y maven según la versión de roo sería 1.5 o superior y maven 2.0 o superior</p>
<p>Tecnologías que se utilizan en el desarrollo de spring roo  jspx, spring javascript, spring mvc y jpa </p>
<p>Es un proyecto de software libre y podemos descargarlo desde el sitio oficial</p>
<p><img src="http://www.railsymas.com/wp-content/uploads/2012/01/eroo3.png" alt="" title="eroo3" width="528" height="496" class="alignnone size-full wp-image-2612" /></p>
<p>Generación de código pasivo mediante el shell de roo y generación de código activo al detectar cambios de código hechos en nuestra aplicación con nuestro editor favorito y funcionamiento de autocompletado de código de roo por debajo en otras partes de la aplicación</p>
<p>aspectj para programación de aspectos que modifican el comportamiento de controladores </p>
<p>Las vistas para el desarrollo de la interacción dinámica de elmentos del dom utiliza spring-js.jar el cual hace uso de dojo para javascript (actualmente no tiene soporte automático para jquery)</p>
<p>Una vez arrancado su shell nos aparece la pantala de bienvenida para empezar a trabajar con roo</p>
<p><img src="http://www.railsymas.com/wp-content/uploads/2012/01/roas1.png" alt="" title="roas1" width="645" height="218" class="alignnone size-full wp-image-2614" /></p>
<p>Si pulsamos tab (el tabulador ) automáticamente nos sale una ayuda con los comandos disponibles en cada momento<br />
<img src="http://www.railsymas.com/wp-content/uploads/2012/01/shro2.png" alt="" title="shro2" width="552" height="84" class="alignnone size-full wp-image-2617" /></p>
<p>Para disponer de una indicación de qué debemos hacer según el estado en el que se enncuentra la aplicación detemos el comando hint (nos ofrece indicaciones) </p>
<p><img src="http://www.railsymas.com/wp-content/uploads/2012/01/sh3.png" alt="" title="sh3" width="603" height="252" class="alignnone size-full wp-image-2621" /></p>
<img src="http://feeds.feedburner.com/~r/railsymas/~4/XLG4jkKF9og" height="1" width="1"/>]]></content:encoded>
			<wfw:commentRss>http://www.railsymas.com/2012/01/08/aplicaciones-rad-con-spring/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Spring mvc uno a muchos hibernate</title>
		<link>http://www.railsymas.com/2012/01/02/spring-mvc-uno-a-muchos-hibernate/</link>
		<comments>http://www.railsymas.com/2012/01/02/spring-mvc-uno-a-muchos-hibernate/#comments</comments>
		<pubDate>Mon, 02 Jan 2012 17:56:48 +0000</pubDate>
		<dc:creator>admin</dc:creator>
				<category><![CDATA[spring]]></category>

		<guid isPermaLink="false">http://www.railsymas.com/?p=2578</guid>
		<description><![CDATA[Siguiendo con los ejemplos de spring framework con hibernate en este caso establecemos una relación uno a muchos con jpa La siguiente imagen corresponde a una vista jsp donde tenemos una llamada a la acción que desencadena el ejemplo Creamos la interface Unoamuchos que nos servirá de esqueleto para nuestra aplicación 1 2 3 4 [...]]]></description>
			<content:encoded><![CDATA[<p>Siguiendo con los ejemplos de spring framework con hibernate en este caso establecemos una relación uno a muchos con jpa</p>
<p><span id="more-2578"></span></p>
<p>La siguiente imagen corresponde a una vista jsp donde tenemos una llamada a la acción que desencadena el ejemplo</p>
<p><img src="http://www.railsymas.com/wp-content/uploads/2012/01/unoam1.png" alt="" title="unoam1" width="317" height="30" class="alignnone size-full wp-image-2579" /></p>
<p>Creamos la interface Unoamuchos que nos servirá de esqueleto para nuestra aplicación</p>

<div class="wp_syntax"><table><tr><td class="line_numbers"><pre>1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
</pre></td><td class="code"><pre class="java" style="font-family:monospace;"><span style="color: #000000; font-weight: bold;">package</span> <span style="color: #006699;">recursos</span><span style="color: #339933;">;</span>
&nbsp;
<span style="color: #000000; font-weight: bold;">import</span> <span style="color: #006699;">java.util.List</span><span style="color: #339933;">;</span>
<span style="color: #000000; font-weight: bold;">import</span> <span style="color: #006699;">modelos.Propietario</span><span style="color: #339933;">;</span>
<span style="color: #000000; font-weight: bold;">import</span> <span style="color: #006699;">modelos.Automovil</span><span style="color: #339933;">;</span>
&nbsp;
<span style="color: #000000; font-weight: bold;">public</span> <span style="color: #000000; font-weight: bold;">interface</span> Unoamuchos <span style="color: #009900;">&#123;</span>
&nbsp;
	<span style="color: #000000; font-weight: bold;">public</span> List<span style="color: #339933;">&lt;</span>Propietario<span style="color: #339933;">&gt;</span> listadoPropietarios<span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
	<span style="color: #000000; font-weight: bold;">public</span> List<span style="color: #339933;">&lt;</span>Automovil<span style="color: #339933;">&gt;</span>  listadoAutomoviles<span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
	<span style="color: #000000; font-weight: bold;">public</span> <span style="color: #000066; font-weight: bold;">void</span> introducirPropietario <span style="color: #009900;">&#40;</span>Propietario propietario<span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
&nbsp;
&nbsp;
&nbsp;
<span style="color: #009900;">&#125;</span></pre></td></tr></table></div>

<p>Implementación de la interface</p>

<div class="wp_syntax"><table><tr><td class="line_numbers"><pre>1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
</pre></td><td class="code"><pre class="java" style="font-family:monospace;"><span style="color: #000000; font-weight: bold;">package</span> <span style="color: #006699;">recursos</span><span style="color: #339933;">;</span>
&nbsp;
<span style="color: #000000; font-weight: bold;">import</span> <span style="color: #006699;">modelos.Automovil</span><span style="color: #339933;">;</span>
<span style="color: #000000; font-weight: bold;">import</span> <span style="color: #006699;">modelos.Propietario</span><span style="color: #339933;">;</span>
<span style="color: #000000; font-weight: bold;">import</span> <span style="color: #006699;">java.util.List</span><span style="color: #339933;">;</span>
<span style="color: #000000; font-weight: bold;">import</span> <span style="color: #006699;">org.springframework.orm.hibernate3.HibernateTemplate</span><span style="color: #339933;">;</span>
&nbsp;
&nbsp;
<span style="color: #000000; font-weight: bold;">public</span> <span style="color: #000000; font-weight: bold;">class</span> UnoamuchosImpl <span style="color: #000000; font-weight: bold;">implements</span> Unoamuchos <span style="color: #009900;">&#123;</span>
&nbsp;
&nbsp;
&nbsp;
&nbsp;
		<span style="color: #000000; font-weight: bold;">private</span> HibernateTemplate hibernateTemplate<span style="color: #339933;">;</span>
&nbsp;
		<span style="color: #000000; font-weight: bold;">public</span> HibernateTemplate getHibernateTemplate<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> hibernateTemplate<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> setHibernateTemplate<span style="color: #009900;">&#40;</span>HibernateTemplate hibernateTemplate<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;">hibernateTemplate</span> <span style="color: #339933;">=</span> hibernateTemplate<span style="color: #339933;">;</span>
		<span style="color: #009900;">&#125;</span>
		@SuppressWarnings<span style="color: #009900;">&#40;</span><span style="color: #0000ff;">&quot;unchecked&quot;</span><span style="color: #009900;">&#41;</span>
		<span style="color: #000000; font-weight: bold;">public</span> <span style="color: #003399;">List</span> <span style="color: #339933;">&lt;</span>Propietario<span style="color: #339933;">&gt;</span> listadoPropietarios<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> <span style="color: #009900;">&#40;</span>List<span style="color: #339933;">&lt;</span>Propietario<span style="color: #339933;">&gt;</span><span style="color: #009900;">&#41;</span> hibernateTemplate.<span style="color: #006633;">find</span><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">&quot;from Propietario&quot;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
		<span style="color: #009900;">&#125;</span>
&nbsp;
		@SuppressWarnings<span style="color: #009900;">&#40;</span><span style="color: #0000ff;">&quot;unchecked&quot;</span><span style="color: #009900;">&#41;</span>
		<span style="color: #000000; font-weight: bold;">public</span> <span style="color: #003399;">List</span> <span style="color: #339933;">&lt;</span>Automovil<span style="color: #339933;">&gt;</span> listadoAutomoviles<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> <span style="color: #009900;">&#40;</span>List<span style="color: #339933;">&lt;</span>Automovil<span style="color: #339933;">&gt;</span><span style="color: #009900;">&#41;</span> hibernateTemplate.<span style="color: #006633;">find</span><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">&quot;from Automovil&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> <span style="color: #000066; font-weight: bold;">void</span> introducirPropietario <span style="color: #009900;">&#40;</span>Propietario propietario<span style="color: #009900;">&#41;</span>
		<span style="color: #009900;">&#123;</span>
			hibernateTemplate.<span style="color: #006633;">saveOrUpdate</span><span style="color: #009900;">&#40;</span>propietario<span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
		<span style="color: #009900;">&#125;</span>
&nbsp;
&nbsp;
&nbsp;
	<span style="color: #009900;">&#125;</span></pre></td></tr></table></div>

<p>Imagen del formulario de entrada de datos</p>
<p><img src="http://www.railsymas.com/wp-content/uploads/2012/01/unoam2.png" alt="" title="unoam2" width="623" height="361" class="alignnone size-full wp-image-2591" /></p>
<p>Listado de datos una vez introducidos<br />
<img src="http://www.railsymas.com/wp-content/uploads/2012/01/unoam3.png" alt="" title="unoam3" width="632" height="303" class="alignnone size-full wp-image-2593" /></p>
<p>Configuración del bean de gestión</p>

<div class="wp_syntax"><table><tr><td class="line_numbers"><pre>1
2
3
4
5
6
</pre></td><td class="code"><pre class="xml" style="font-family:monospace;">&nbsp;
   <span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;bean</span> <span style="color: #000066;">name</span>=<span style="color: #ff0000;">&quot;/formulariopropietario.html&quot;</span> <span style="color: #000066;">class</span>=<span style="color: #ff0000;">&quot;controlador.ControladorPropietario&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;property</span> <span style="color: #000066;">name</span>=<span style="color: #ff0000;">&quot;methodNameResolver&quot;</span> <span style="color: #000066;">ref</span>=<span style="color: #ff0000;">&quot;paramResolver&quot;</span><span style="color: #000000; font-weight: bold;">/&gt;</span></span>
    <span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;property</span> <span style="color: #000066;">name</span>=<span style="color: #ff0000;">&quot;propieatarioDao&quot;</span> <span style="color: #000066;">ref</span>=<span style="color: #ff0000;">&quot;propietarioDao&quot;</span><span style="color: #000000; font-weight: bold;">/&gt;</span></span>
   <span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;/bean<span style="color: #000000; font-weight: bold;">&gt;</span></span></span></pre></td></tr></table></div>

<p>Controlador encargado de la gestión</p>

<div class="wp_syntax"><table><tr><td class="line_numbers"><pre>1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
</pre></td><td class="code"><pre class="java" style="font-family:monospace;"><span style="color: #000000; font-weight: bold;">package</span> <span style="color: #006699;">controlador</span><span style="color: #339933;">;</span>
&nbsp;
<span style="color: #000000; font-weight: bold;">import</span> <span style="color: #006699;">javax.servlet.http.HttpServletRequest</span><span style="color: #339933;">;</span>
<span style="color: #000000; font-weight: bold;">import</span> <span style="color: #006699;">javax.servlet.http.HttpServletResponse</span><span style="color: #339933;">;</span>
&nbsp;
<span style="color: #000000; font-weight: bold;">import</span> <span style="color: #006699;">org.springframework.web.servlet.ModelAndView</span><span style="color: #339933;">;</span>
<span style="color: #000000; font-weight: bold;">import</span> <span style="color: #006699;">org.springframework.web.servlet.mvc.multiaction.MultiActionController</span><span style="color: #339933;">;</span>
&nbsp;
<span style="color: #000000; font-weight: bold;">import</span> <span style="color: #006699;">org.springframework.ui.ModelMap</span><span style="color: #339933;">;</span>
<span style="color: #000000; font-weight: bold;">import</span> <span style="color: #006699;">ClasesBean.DatosPropietario</span><span style="color: #339933;">;</span>
<span style="color: #000000; font-weight: bold;">import</span> <span style="color: #006699;">recursos.Unoamuchos</span><span style="color: #339933;">;</span>
<span style="color: #000000; font-weight: bold;">import</span> <span style="color: #006699;">modelos.Propietario</span><span style="color: #339933;">;</span>
<span style="color: #000000; font-weight: bold;">import</span> <span style="color: #006699;">modelos.Automovil</span><span style="color: #339933;">;</span>
<span style="color: #000000; font-weight: bold;">import</span> <span style="color: #006699;">java.util.List</span><span style="color: #339933;">;</span>
<span style="color: #000000; font-weight: bold;">import</span> <span style="color: #006699;">java.util.ArrayList</span><span style="color: #339933;">;</span>
&nbsp;
<span style="color: #000000; font-weight: bold;">public</span> <span style="color: #000000; font-weight: bold;">class</span> ControladorPropietario <span style="color: #000000; font-weight: bold;">extends</span> MultiActionController <span style="color: #009900;">&#123;</span>
&nbsp;
    <span style="color: #000000; font-weight: bold;">private</span> Unoamuchos	propieatarioDao<span style="color: #339933;">;</span>
    <span style="color: #000000; font-weight: bold;">private</span> List<span style="color: #339933;">&lt;</span>Automovil<span style="color: #339933;">&gt;</span> listaautomoviles <span style="color: #339933;">=</span>  <span style="color: #000000; font-weight: bold;">new</span> <span style="color: #003399;">ArrayList</span> <span style="color: #339933;">&lt;</span>Automovil<span style="color: #339933;">&gt;</span> <span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
&nbsp;
&nbsp;
	<span style="color: #000000; font-weight: bold;">public</span> Unoamuchos getPropieatarioDao<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> propieatarioDao<span style="color: #339933;">;</span>
	<span style="color: #009900;">&#125;</span>
&nbsp;
&nbsp;
&nbsp;
	<span style="color: #000000; font-weight: bold;">public</span> <span style="color: #000066; font-weight: bold;">void</span> setPropieatarioDao<span style="color: #009900;">&#40;</span>Unoamuchos propieatarioDao<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;">propieatarioDao</span> <span style="color: #339933;">=</span> propieatarioDao<span style="color: #339933;">;</span>
	<span style="color: #009900;">&#125;</span>
&nbsp;
&nbsp;
&nbsp;
	<span style="color: #000000; font-weight: bold;">public</span> ModelAndView introducirDatos <span style="color: #009900;">&#40;</span> HttpServletRequest request, HttpServletResponse response, DatosPropietario propietario<span style="color: #009900;">&#41;</span> <span style="color: #000000; font-weight: bold;">throws</span> <span style="color: #003399;">Exception</span>
	<span style="color: #009900;">&#123;</span>
&nbsp;
		Propietario owner <span style="color: #339933;">=</span> <span style="color: #000000; font-weight: bold;">new</span> Propietario<span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
		Automovil automovil <span style="color: #339933;">=</span> <span style="color: #000000; font-weight: bold;">new</span> Automovil<span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
&nbsp;
		automovil.<span style="color: #006633;">setMarca</span><span style="color: #009900;">&#40;</span>propietario.<span style="color: #006633;">getMarca</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
		automovil.<span style="color: #006633;">setModelo</span><span style="color: #009900;">&#40;</span>propietario.<span style="color: #006633;">getModelo</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
		owner.<span style="color: #006633;">setNombre</span><span style="color: #009900;">&#40;</span>propietario.<span style="color: #006633;">getNombre</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
		owner.<span style="color: #006633;">setApellidos</span><span style="color: #009900;">&#40;</span>propietario.<span style="color: #006633;">getApellidos</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
&nbsp;
		listaautomoviles.<span style="color: #006633;">add</span><span style="color: #009900;">&#40;</span>automovil<span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
		owner.<span style="color: #006633;">setPropietarioautomovil</span><span style="color: #009900;">&#40;</span>listaautomoviles<span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
&nbsp;
        propieatarioDao.<span style="color: #006633;">introducirPropietario</span><span style="color: #009900;">&#40;</span>owner<span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
&nbsp;
&nbsp;
    	ModelMap mapa <span style="color: #339933;">=</span> <span style="color: #000000; font-weight: bold;">new</span> ModelMap<span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
&nbsp;
    	mapa.<span style="color: #006633;">addAttribute</span><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">&quot;propietarios&quot;</span>,propieatarioDao.<span style="color: #006633;">listadoPropietarios</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
&nbsp;
    	mapa.<span style="color: #006633;">addAttribute</span><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">&quot;automoviles&quot;</span>,propieatarioDao.<span style="color: #006633;">listadoAutomoviles</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
&nbsp;
    	ModelAndView vista <span style="color: #339933;">=</span> <span style="color: #000000; font-weight: bold;">new</span> ModelAndView<span style="color: #009900;">&#40;</span><span style="color: #0000ff;">&quot;resultadopropietario&quot;</span>,mapa<span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
&nbsp;
    	<span style="color: #000000; font-weight: bold;">return</span> vista<span style="color: #339933;">;</span>
&nbsp;
&nbsp;
&nbsp;
	<span style="color: #009900;">&#125;</span>
&nbsp;
&nbsp;
&nbsp;
	<span style="color: #000000; font-weight: bold;">public</span> ModelAndView introducirPropietario <span style="color: #009900;">&#40;</span>HttpServletRequest request, HttpServletResponse response, DatosPropietario propietario<span style="color: #009900;">&#41;</span> <span style="color: #000000; font-weight: bold;">throws</span> <span style="color: #003399;">Exception</span>
	<span style="color: #009900;">&#123;</span>
		ModelAndView vista <span style="color: #339933;">=</span> <span style="color: #000000; font-weight: bold;">new</span> ModelAndView <span style="color: #009900;">&#40;</span><span style="color: #0000ff;">&quot;formulariopropietario&quot;</span>,<span style="color: #0000ff;">&quot;propietario&quot;</span>,propietario<span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
&nbsp;
		<span style="color: #000000; font-weight: bold;">return</span> vista<span style="color: #339933;">;</span>
	<span style="color: #009900;">&#125;</span>
&nbsp;
&nbsp;
&nbsp;
&nbsp;
<span style="color: #009900;">&#125;</span></pre></td></tr></table></div>

<p>Clase modelo propietario</p>

<div class="wp_syntax"><table><tr><td class="line_numbers"><pre>1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
</pre></td><td class="code"><pre class="java" style="font-family:monospace;"><span style="color: #000000; font-weight: bold;">package</span> <span style="color: #006699;">modelos</span><span style="color: #339933;">;</span>
<span style="color: #000000; font-weight: bold;">import</span> <span style="color: #006699;">java.util.List</span><span style="color: #339933;">;</span>
<span style="color: #000000; font-weight: bold;">import</span> <span style="color: #006699;">javax.persistence.CascadeType</span><span style="color: #339933;">;</span>
<span style="color: #000000; font-weight: bold;">import</span> <span style="color: #006699;">javax.persistence.Entity</span><span style="color: #339933;">;</span>
<span style="color: #000000; font-weight: bold;">import</span> <span style="color: #006699;">javax.persistence.GenerationType</span><span style="color: #339933;">;</span>
<span style="color: #000000; font-weight: bold;">import</span> <span style="color: #006699;">javax.persistence.Table</span><span style="color: #339933;">;</span>
<span style="color: #000000; font-weight: bold;">import</span> <span style="color: #006699;">javax.persistence.Column</span><span style="color: #339933;">;</span>
<span style="color: #000000; font-weight: bold;">import</span> <span style="color: #006699;">javax.persistence.GeneratedValue</span><span style="color: #339933;">;</span>
<span style="color: #000000; font-weight: bold;">import</span> <span style="color: #006699;">javax.persistence.Id</span><span style="color: #339933;">;</span>
<span style="color: #000000; font-weight: bold;">import</span> <span style="color: #006699;">javax.persistence.OneToMany</span><span style="color: #339933;">;</span>
<span style="color: #000000; font-weight: bold;">import</span> <span style="color: #006699;">javax.persistence.JoinTable</span><span style="color: #339933;">;</span>
<span style="color: #000000; font-weight: bold;">import</span> <span style="color: #006699;">javax.persistence.JoinColumn</span><span style="color: #339933;">;</span>
&nbsp;
&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;propietario&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> Propietario <span style="color: #009900;">&#123;</span>
&nbsp;
	<span style="color: #000000; font-weight: bold;">private</span> <span style="color: #000066; font-weight: bold;">long</span> propietarioid<span style="color: #339933;">;</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: #000000; font-weight: bold;">private</span> <span style="color: #003399;">String</span> apellidos<span style="color: #339933;">;</span>
	<span style="color: #000000; font-weight: bold;">private</span> List<span style="color: #339933;">&lt;</span>Automovil<span style="color: #339933;">&gt;</span> propietarioautomovil<span style="color: #339933;">;</span>
&nbsp;
	@Id
	@GeneratedValue<span style="color: #009900;">&#40;</span>strategy<span style="color: #339933;">=</span>GenerationType.<span style="color: #006633;">IDENTITY</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;propietario_id&quot;</span><span style="color: #009900;">&#41;</span>
	<span style="color: #000000; font-weight: bold;">public</span> <span style="color: #000066; font-weight: bold;">long</span> getPropietarioid<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> propietarioid<span style="color: #339933;">;</span>
	<span style="color: #009900;">&#125;</span>
	<span style="color: #000000; font-weight: bold;">public</span> <span style="color: #000066; font-weight: bold;">void</span> setPropietarioid<span style="color: #009900;">&#40;</span><span style="color: #000066; font-weight: bold;">long</span> propietarioid<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;">propietarioid</span> <span style="color: #339933;">=</span> propietarioid<span style="color: #339933;">;</span>
	<span style="color: #009900;">&#125;</span>
	@Column<span style="color: #009900;">&#40;</span>name<span style="color: #339933;">=</span><span style="color: #0000ff;">&quot;nombre&quot;</span>, nullable<span style="color: #339933;">=</span><span style="color: #000066; font-weight: bold;">false</span>, length<span style="color: #339933;">=</span><span style="color: #cc66cc;">25</span><span style="color: #009900;">&#41;</span>
	<span style="color: #000000; font-weight: bold;">public</span> <span style="color: #003399;">String</span> getNombre<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> nombre<span style="color: #339933;">;</span>
	<span style="color: #009900;">&#125;</span>
	<span style="color: #000000; font-weight: bold;">public</span> <span style="color: #000066; font-weight: bold;">void</span> setNombre<span style="color: #009900;">&#40;</span><span style="color: #003399;">String</span> nombre<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;">nombre</span> <span style="color: #339933;">=</span> nombre<span style="color: #339933;">;</span>
	<span style="color: #009900;">&#125;</span>
	@Column<span style="color: #009900;">&#40;</span>name<span style="color: #339933;">=</span><span style="color: #0000ff;">&quot;apellidos&quot;</span>,nullable<span style="color: #339933;">=</span><span style="color: #000066; font-weight: bold;">false</span>,length<span style="color: #339933;">=</span><span style="color: #cc66cc;">50</span><span style="color: #009900;">&#41;</span>
	<span style="color: #000000; font-weight: bold;">public</span> <span style="color: #003399;">String</span> getApellidos<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> apellidos<span style="color: #339933;">;</span>
	<span style="color: #009900;">&#125;</span>
	<span style="color: #000000; font-weight: bold;">public</span> <span style="color: #000066; font-weight: bold;">void</span> setApellidos<span style="color: #009900;">&#40;</span><span style="color: #003399;">String</span> apellidos<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;">apellidos</span> <span style="color: #339933;">=</span> apellidos<span style="color: #339933;">;</span>
	<span style="color: #009900;">&#125;</span>
	@OneToMany<span style="color: #009900;">&#40;</span>cascade <span style="color: #339933;">=</span> CascadeType.<span style="color: #006633;">ALL</span><span style="color: #009900;">&#41;</span>
	@JoinTable<span style="color: #009900;">&#40;</span>name<span style="color: #339933;">=</span><span style="color: #0000ff;">&quot;propietario_automovil&quot;</span>, joinColumns <span style="color: #339933;">=</span><span style="color: #009900;">&#123;</span>@JoinColumn <span style="color: #009900;">&#40;</span>name<span style="color: #339933;">=</span><span style="color: #0000ff;">&quot;propietario_id&quot;</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#125;</span>, inverseJoinColumns<span style="color: #339933;">=</span><span style="color: #009900;">&#123;</span>@JoinColumn <span style="color: #009900;">&#40;</span>name<span style="color: #339933;">=</span><span style="color: #0000ff;">&quot;automovil_id&quot;</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#125;</span><span style="color: #009900;">&#41;</span>
	<span style="color: #000000; font-weight: bold;">public</span> List<span style="color: #339933;">&lt;</span>Automovil<span style="color: #339933;">&gt;</span> getPropietarioautomovil<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> propietarioautomovil<span style="color: #339933;">;</span>
	<span style="color: #009900;">&#125;</span>
	<span style="color: #000000; font-weight: bold;">public</span> <span style="color: #000066; font-weight: bold;">void</span> setPropietarioautomovil<span style="color: #009900;">&#40;</span>List<span style="color: #339933;">&lt;</span>Automovil<span style="color: #339933;">&gt;</span> propietarioautomovil<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;">propietarioautomovil</span> <span style="color: #339933;">=</span> propietarioautomovil<span style="color: #339933;">;</span>
	<span style="color: #009900;">&#125;</span>
&nbsp;
&nbsp;
&nbsp;
&nbsp;
<span style="color: #009900;">&#125;</span></pre></td></tr></table></div>

<p>Clase modelo Automovil</p>

<div class="wp_syntax"><table><tr><td class="line_numbers"><pre>1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
</pre></td><td class="code"><pre class="java" style="font-family:monospace;"><span style="color: #000000; font-weight: bold;">package</span> <span style="color: #006699;">modelos</span><span style="color: #339933;">;</span>
&nbsp;
<span style="color: #000000; font-weight: bold;">import</span> <span style="color: #006699;">javax.persistence.Column</span><span style="color: #339933;">;</span>
<span style="color: #000000; font-weight: bold;">import</span> <span style="color: #006699;">javax.persistence.GeneratedValue</span><span style="color: #339933;">;</span>
<span style="color: #000000; font-weight: bold;">import</span> <span style="color: #006699;">javax.persistence.GenerationType</span><span style="color: #339933;">;</span>
<span style="color: #000000; font-weight: bold;">import</span> <span style="color: #006699;">javax.persistence.Id</span><span style="color: #339933;">;</span>
<span style="color: #000000; font-weight: bold;">import</span> <span style="color: #006699;">javax.persistence.Entity</span><span style="color: #339933;">;</span>
<span style="color: #000000; font-weight: bold;">import</span> <span style="color: #006699;">javax.persistence.Table</span><span style="color: #339933;">;</span>
&nbsp;
&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;automovil&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> Automovil <span style="color: #009900;">&#123;</span>
&nbsp;
	<span style="color: #000000; font-weight: bold;">private</span> <span style="color: #003399;">Long</span> automovilid<span style="color: #339933;">;</span>
&nbsp;
	<span style="color: #000000; font-weight: bold;">private</span> <span style="color: #003399;">String</span> marca<span style="color: #339933;">;</span>
	<span style="color: #000000; font-weight: bold;">private</span> <span style="color: #003399;">String</span> modelo<span style="color: #339933;">;</span>
&nbsp;
&nbsp;
    @Id
    @GeneratedValue<span style="color: #009900;">&#40;</span>strategy <span style="color: #339933;">=</span> GenerationType.<span style="color: #006633;">IDENTITY</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;automovil_id&quot;</span><span style="color: #009900;">&#41;</span>
	<span style="color: #000000; font-weight: bold;">public</span> <span style="color: #003399;">Long</span> getAutomovilid<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> automovilid<span style="color: #339933;">;</span>
	<span style="color: #009900;">&#125;</span>
	<span style="color: #000000; font-weight: bold;">public</span> <span style="color: #000066; font-weight: bold;">void</span> setAutomovilid<span style="color: #009900;">&#40;</span><span style="color: #003399;">Long</span> automovilid<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;">automovilid</span> <span style="color: #339933;">=</span> automovilid<span style="color: #339933;">;</span>
	<span style="color: #009900;">&#125;</span>
&nbsp;
	@Column<span style="color: #009900;">&#40;</span>name<span style="color: #339933;">=</span><span style="color: #0000ff;">&quot;marca&quot;</span>,nullable<span style="color: #339933;">=</span><span style="color: #000066; font-weight: bold;">false</span>,length<span style="color: #339933;">=</span><span style="color: #cc66cc;">50</span><span style="color: #009900;">&#41;</span>
	<span style="color: #000000; font-weight: bold;">public</span> <span style="color: #003399;">String</span> getMarca<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> marca<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> setMarca<span style="color: #009900;">&#40;</span><span style="color: #003399;">String</span> marca<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;">marca</span> <span style="color: #339933;">=</span> marca<span style="color: #339933;">;</span>
	<span style="color: #009900;">&#125;</span>
	@Column<span style="color: #009900;">&#40;</span>name<span style="color: #339933;">=</span><span style="color: #0000ff;">&quot;modelo&quot;</span>,nullable<span style="color: #339933;">=</span><span style="color: #000066; font-weight: bold;">false</span>,length<span style="color: #339933;">=</span><span style="color: #cc66cc;">50</span><span style="color: #009900;">&#41;</span>
	<span style="color: #000000; font-weight: bold;">public</span> <span style="color: #003399;">String</span> getModelo<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> modelo<span style="color: #339933;">;</span>
	<span style="color: #009900;">&#125;</span>
	<span style="color: #000000; font-weight: bold;">public</span> <span style="color: #000066; font-weight: bold;">void</span> setModelo<span style="color: #009900;">&#40;</span><span style="color: #003399;">String</span> modelo<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;">modelo</span> <span style="color: #339933;">=</span> modelo<span style="color: #339933;">;</span>
	<span style="color: #009900;">&#125;</span>
&nbsp;
&nbsp;
&nbsp;
&nbsp;
<span style="color: #009900;">&#125;</span></pre></td></tr></table></div>

<p>Configuración de la factoria en dispatcher-servlet.xml</p>

<div class="wp_syntax"><table><tr><td class="line_numbers"><pre>1
2
3
4
5
6
7
8
9
10
</pre></td><td class="code"><pre class="xml" style="font-family:monospace;"> <span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;bean</span> <span style="color: #000066;">id</span>=<span style="color: #ff0000;">&quot;conexionFactoria&quot;</span> <span style="color: #000066;">class</span>=<span style="color: #ff0000;">&quot;org.springframework.orm.hibernate3.annotation.AnnotationSessionFactoryBean&quot;</span><span style="color: #000000; font-weight: bold;">&gt;</span></span>
    <span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;property</span> <span style="color: #000066;">name</span>=<span style="color: #ff0000;">&quot;dataSource&quot;</span> <span style="color: #000066;">ref</span>=<span style="color: #ff0000;">&quot;datasource&quot;</span><span style="color: #000000; font-weight: bold;">/&gt;</span></span>
    <span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;property</span> <span style="color: #000066;">name</span>=<span style="color: #ff0000;">&quot;annotatedClasses&quot;</span><span style="color: #000000; font-weight: bold;">&gt;</span></span>
       <span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;list<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>
&nbsp;
       <span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;value<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>modelos.Propietario<span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;/value<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>  
       <span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;value<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>modelos.Automovil<span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;/value<span style="color: #000000; font-weight: bold;">&gt;</span></span></span> 
&nbsp;
       <span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;/list<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>
    <span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;/property<span style="color: #000000; font-weight: bold;">&gt;</span></span></span></pre></td></tr></table></div>

<p><img src="http://www.railsymas.com/wp-content/uploads/2012/01/unoam5.png" alt="" title="unoam5" width="186" height="41" class="alignnone size-full wp-image-2599" /><br />
<img src="http://www.railsymas.com/wp-content/uploads/2012/01/unoam4.png" alt="" title="unoam4" width="726" height="101" class="alignnone size-full wp-image-2601" /></p>
<img src="http://feeds.feedburner.com/~r/railsymas/~4/PQ3Mq9qW2sw" height="1" width="1"/>]]></content:encoded>
			<wfw:commentRss>http://www.railsymas.com/2012/01/02/spring-mvc-uno-a-muchos-hibernate/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Integración plantillas velocity Spring framework</title>
		<link>http://www.railsymas.com/2011/12/28/integracion-plantillas-velocity-spring-framework-eg/</link>
		<comments>http://www.railsymas.com/2011/12/28/integracion-plantillas-velocity-spring-framework-eg/#comments</comments>
		<pubDate>Wed, 28 Dec 2011 17:23:12 +0000</pubDate>
		<dc:creator>admin</dc:creator>
				<category><![CDATA[spring]]></category>

		<guid isPermaLink="false">http://www.railsymas.com/?p=1645</guid>
		<description><![CDATA[En anteriores post ya se habían expuesto tanto la forma de descargar el proyecto velocity como las características generales de cómo trabajar con velocity. Para facilitar el trabajo con platillas velocity habíamos recomendado un plugin para el editor eclipse llamado veloeclipse Ahora en este post vemos la forma de integrarlo en uno de los frameworks [...]]]></description>
			<content:encoded><![CDATA[<p> En anteriores post ya se habían expuesto tanto la forma de descargar el proyecto velocity como las características generales de cómo trabajar con velocity. </p>
<p> Para facilitar el trabajo con platillas velocity habíamos recomendado un plugin para el editor eclipse<br />
 llamado veloeclipse</p>
<p> Ahora en este post vemos la forma de integrarlo en uno de los frameworks más importantes de java como es spring framework. Spring nos ofrece un importante soporte para dichas plantillas facilitando su integración</p>
<p><span id="more-1645"></span></p>
<p>Simplemente el ejercicio que se muestra es una forma alternativa de mostrar los resultados al igual que hacíamos con spring mvc mostrando las vistas con jsp normales</p>
<p>Para ello vamos a configurar el motor de velocity para spring, crearemos dentro del fichero de configuración de spring en nuestro caso, dispatcher-servlet.xml un bean velocityconfigurer aunque el nombre del bean es opcional lo ponemos para acordarnos de que estamos creando una configuración para velocity</p>
<p>Dentro del bean velocityConfigurer tenemos una propiedad resourceLoaderPath con el valor WEB-INF/plantillasvelocity . Con esto estamos configurando el motor de plantillas velocity y le decimos a velocity donde encontrar las plantillas.</p>
<p>Una vez hecho lo anterior debemos de configurar la resolución de visualización para velocity<br />
para ello creamos un bean nombre viewResolver de clase VelecityViewResolver y declaramos la propiedad suffix con el valo .vm</p>

<div class="wp_syntax"><table><tr><td class="line_numbers"><pre>1
2
3
4
5
6
7
8
9
10
</pre></td><td class="code"><pre class="xml" style="font-family:monospace;">&nbsp;
    <span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;bean</span> <span style="color: #000066;">id</span>=<span style="color: #ff0000;">&quot;viewResolver&quot;</span> <span style="color: #000066;">class</span>=<span style="color: #ff0000;">&quot;org.springframework.web.servlet.view.velocity.VelocityViewResolver&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;property</span> <span style="color: #000066;">name</span>=<span style="color: #ff0000;">&quot;suffix&quot;</span> <span style="color: #000066;">value</span>=<span style="color: #ff0000;">&quot;.vm&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;/bean<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>
&nbsp;
    <span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;bean</span> <span style="color: #000066;">id</span>=<span style="color: #ff0000;">&quot;velocityConfigurer&quot;</span>       <span style="color: #000066;">class</span>=<span style="color: #ff0000;">&quot;org.springframework.web.servlet.view.velocity.VelocityConfigurer&quot;</span><span style="color: #000000; font-weight: bold;">&gt;</span></span>
     <span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;property</span> <span style="color: #000066;">name</span>=<span style="color: #ff0000;">&quot;resourceLoaderPath&quot;</span> <span style="color: #000066;">value</span>=<span style="color: #ff0000;">&quot;/WEB-INF/plantillasvelocity&quot;</span><span style="color: #000000; font-weight: bold;">/&gt;</span></span>
    <span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;/bean<span style="color: #000000; font-weight: bold;">&gt;</span></span></span></pre></td></tr></table></div>

<p>Código para la página ejercicios.vm</p>

<div class="wp_syntax"><table><tr><td class="line_numbers"><pre>1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
</pre></td><td class="code"><pre class="java" style="font-family:monospace;"><span style="color: #339933;">&lt;!</span>DOCTYPE html <span style="color: #000000; font-weight: bold;">PUBLIC</span> <span style="color: #0000ff;">&quot;-//W3C//DTD HTML 4.01 Transitional//EN&quot;</span> <span style="color: #0000ff;">&quot;http://www.w3.org/TR/html4/loose.dtd&quot;</span><span style="color: #339933;">&gt;</span>
<span style="color: #339933;">&lt;</span>html<span style="color: #339933;">&gt;</span>
<span style="color: #339933;">&lt;</span>head<span style="color: #339933;">&gt;</span>
<span style="color: #339933;">&lt;</span>link rel<span style="color: #339933;">=</span><span style="color: #0000ff;">&quot;stylesheet&quot;</span> href<span style="color: #339933;">=</span><span style="color: #0000ff;">&quot;css/estilo.css&quot;</span> type<span style="color: #339933;">=</span><span style="color: #0000ff;">&quot;text/css&quot;</span><span style="color: #339933;">/&gt;</span>
<span style="color: #339933;">&lt;</span>meta http<span style="color: #339933;">-</span>equiv<span style="color: #339933;">=</span><span style="color: #0000ff;">&quot;Content-Type&quot;</span> content<span style="color: #339933;">=</span><span style="color: #0000ff;">&quot;text/html; charset=UTF-8&quot;</span><span style="color: #339933;">&gt;</span>
<span style="color: #339933;">&lt;</span>title<span style="color: #339933;">&gt;</span>Ejercicios<span style="color: #339933;">&lt;/</span>title<span style="color: #339933;">&gt;</span>
<span style="color: #339933;">&lt;/</span>head<span style="color: #339933;">&gt;</span>
	<span style="color: #339933;">&lt;</span>body<span style="color: #339933;">&gt;</span>
		<span style="color: #339933;">&lt;</span>div id<span style="color: #339933;">=</span><span style="color: #0000ff;">&quot;contenedor&quot;</span><span style="color: #339933;">&gt;</span>
            <span style="color: #339933;">&lt;</span>h2<span style="color: #339933;">&gt;</span>Ejercicios<span style="color: #339933;">&lt;/</span>h2<span style="color: #339933;">&gt;</span>
	        <span style="color: #339933;">&lt;</span>div <span style="color: #000000; font-weight: bold;">class</span><span style="color: #339933;">=</span><span style="color: #0000ff;">&quot;campo&quot;</span><span style="color: #339933;">&gt;</span>
             <span style="color: #339933;">&lt;</span>a href<span style="color: #339933;">=</span><span style="color: #0000ff;">&quot;basico.html&quot;</span><span style="color: #339933;">&gt;</span><span style="color: #cc66cc;">1</span><span style="color: #009900;">&#41;</span> Trabajo b<span style="color: #339933;">&amp;</span>aacute<span style="color: #339933;">;</span>sico con plantillas<span style="color: #339933;">&lt;/</span>a<span style="color: #339933;">&gt;</span>
			<span style="color: #339933;">&lt;/</span>div<span style="color: #339933;">&gt;</span>
			<span style="color: #339933;">&lt;</span>div <span style="color: #000000; font-weight: bold;">class</span><span style="color: #339933;">=</span><span style="color: #0000ff;">&quot;campo&quot;</span><span style="color: #339933;">&gt;</span>
            <span style="color: #339933;">&lt;</span>a href<span style="color: #339933;">=</span><span style="color: #0000ff;">&quot;objetos.html&quot;</span><span style="color: #339933;">&gt;</span> <span style="color: #cc66cc;">2</span><span style="color: #009900;">&#41;</span> Trabajo con objetos  <span style="color: #339933;">&lt;/</span>a<span style="color: #339933;">&gt;</span>
            <span style="color: #339933;">&lt;/</span>div<span style="color: #339933;">&gt;</span>
			<span style="color: #339933;">&lt;</span>div id<span style="color: #339933;">=</span><span style="color: #0000ff;">&quot;pie&quot;</span><span style="color: #339933;">&gt;</span>
				<span style="color: #339933;">&lt;</span>p<span style="color: #339933;">&gt;</span>www.<span style="color: #006633;">railsymas</span>.<span style="color: #006633;">com</span><span style="color: #339933;">&lt;/</span>p<span style="color: #339933;">&gt;</span>
            <span style="color: #339933;">&lt;/</span>div<span style="color: #339933;">&gt;</span>
        <span style="color: #339933;">&lt;/</span>div<span style="color: #339933;">&gt;</span>
    <span style="color: #339933;">&lt;/</span>body<span style="color: #339933;">&gt;</span>
 <span style="color: #339933;">&lt;/</span>html<span style="color: #339933;">&gt;</span></pre></td></tr></table></div>

<p>visualización de ejercicios.vm</p>
<p><img src="http://www.railsymas.com/wp-content/uploads/2011/12/basico1.png" alt="" title="basico1" width="629" height="168" class="alignnone size-full wp-image-2565" /></p>
<p>Simplemente en ejercicios tenemos dos enlaces a dos acciones, la diferencia que se puede apreciar con respecto a jsp es que no hemos declarado ninguna librería</p>
<p>En este ejemplo básico se accede a una platilla en la que se muestra el mensaje almacenado en un bean de configuración</p>
<p>Código de básico.vm</p>

<div class="wp_syntax"><table><tr><td class="line_numbers"><pre>1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
</pre></td><td class="code"><pre class="java" style="font-family:monospace;"><span style="color: #339933;">&lt;!</span>DOCTYPE html <span style="color: #000000; font-weight: bold;">PUBLIC</span> <span style="color: #0000ff;">&quot;-//W3C//DTD HTML 4.01 Transitional//EN&quot;</span> <span style="color: #0000ff;">&quot;http://www.w3.org/TR/html4/loose.dtd&quot;</span><span style="color: #339933;">&gt;</span>
<span style="color: #339933;">&lt;</span>html<span style="color: #339933;">&gt;</span>
<span style="color: #339933;">&lt;</span>head<span style="color: #339933;">&gt;</span>
<span style="color: #339933;">&lt;</span>link rel<span style="color: #339933;">=</span><span style="color: #0000ff;">&quot;stylesheet&quot;</span> href<span style="color: #339933;">=</span><span style="color: #0000ff;">&quot;css/estilo.css&quot;</span> type<span style="color: #339933;">=</span><span style="color: #0000ff;">&quot;text/css&quot;</span><span style="color: #339933;">/&gt;</span>
<span style="color: #339933;">&lt;</span>title<span style="color: #339933;">&gt;</span>basico<span style="color: #339933;">&lt;/</span>title<span style="color: #339933;">&gt;</span>
<span style="color: #339933;">&lt;/</span>head<span style="color: #339933;">&gt;</span>
<span style="color: #339933;">&lt;</span>body<span style="color: #339933;">&gt;</span>
&nbsp;
 <span style="color: #339933;">&lt;</span>div id<span style="color: #339933;">=</span><span style="color: #0000ff;">&quot;contenedor&quot;</span><span style="color: #339933;">&gt;</span>
&nbsp;
  $<span style="color: #009900;">&#123;</span>mensajeporpantalla<span style="color: #009900;">&#125;</span>
&nbsp;
  <span style="color: #339933;">&lt;</span>div id<span style="color: #339933;">=</span><span style="color: #0000ff;">&quot;pie&quot;</span><span style="color: #339933;">&gt;</span>
&nbsp;
   <span style="color: #339933;">&lt;</span>p<span style="color: #339933;">&gt;</span>www.<span style="color: #006633;">railsymas</span>.<span style="color: #006633;">com</span><span style="color: #339933;">&lt;/</span>p<span style="color: #339933;">&gt;</span>
&nbsp;
 <span style="color: #339933;">&lt;/</span>div<span style="color: #339933;">&gt;</span>
&nbsp;
 <span style="color: #339933;">&lt;/</span>div<span style="color: #339933;">&gt;</span>
&nbsp;
<span style="color: #339933;">&lt;/</span>body<span style="color: #339933;">&gt;</span>
<span style="color: #339933;">&lt;/</span>html<span style="color: #339933;">&gt;</span></pre></td></tr></table></div>

<p>Visualización de la plantilla básico.vm</p>
<p><img src="http://www.railsymas.com/wp-content/uploads/2011/12/basico2.png" alt="" title="basico2" width="626" height="78" class="alignnone size-full wp-image-2573" /></p>
<p>Dentro del fichero de configuración dispatcher-servlet.xml se declara el bean basico.html asociado al controlador con el nombre basico en el package controlador y una propieadad mensaje con el valor hola plantillas velocity que será lo que salga por pantalla</p>

<div class="wp_syntax"><table><tr><td class="line_numbers"><pre>1
2
3
</pre></td><td class="code"><pre class="xml" style="font-family:monospace;">  <span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;bean</span> <span style="color: #000066;">name</span>=<span style="color: #ff0000;">&quot;/basico.html&quot;</span> <span style="color: #000066;">class</span>=<span style="color: #ff0000;">&quot;controlador.Basico&quot;</span><span style="color: #000000; font-weight: bold;">&gt;</span></span>
    <span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;property</span> <span style="color: #000066;">name</span>=<span style="color: #ff0000;">&quot;mensaje&quot;</span> <span style="color: #000066;">value</span>=<span style="color: #ff0000;">&quot;hola plantilas velocity&quot;</span><span style="color: #000000; font-weight: bold;">/&gt;</span></span>
    <span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;/bean<span style="color: #000000; font-weight: bold;">&gt;</span></span></span></pre></td></tr></table></div>

<p>Código del controlador Basico.java</p>
<p>Simplemente generamos un setter para la propiedad mensaje y mediante ModelAndView cargamos los datos en la vista con el valor del string mensajeporpantalla</p>

<div class="wp_syntax"><table><tr><td class="line_numbers"><pre>1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
</pre></td><td class="code"><pre class="java" style="font-family:monospace;">&nbsp;
<span style="color: #000000; font-weight: bold;">package</span> <span style="color: #006699;">controlador</span><span style="color: #339933;">;</span>
&nbsp;
<span style="color: #000000; font-weight: bold;">import</span> <span style="color: #006699;">javax.servlet.http.HttpServletRequest</span><span style="color: #339933;">;</span>
<span style="color: #000000; font-weight: bold;">import</span> <span style="color: #006699;">javax.servlet.http.HttpServletResponse</span><span style="color: #339933;">;</span>
&nbsp;
&nbsp;
&nbsp;
<span style="color: #000000; font-weight: bold;">import</span> <span style="color: #006699;">org.springframework.web.servlet.ModelAndView</span><span style="color: #339933;">;</span>
<span style="color: #000000; font-weight: bold;">import</span> <span style="color: #006699;">org.springframework.web.servlet.mvc.AbstractController</span><span style="color: #339933;">;</span>
&nbsp;
&nbsp;
&nbsp;
&nbsp;
<span style="color: #000000; font-weight: bold;">public</span> <span style="color: #000000; font-weight: bold;">class</span> Basico  <span style="color: #000000; font-weight: bold;">extends</span> AbstractController
<span style="color: #009900;">&#123;</span>
    <span style="color: #000000; font-weight: bold;">private</span> <span style="color: #003399;">String</span> mensaje<span style="color: #339933;">;</span>
&nbsp;
	<span style="color: #000000; font-weight: bold;">public</span> ModelAndView handleRequestInternal <span style="color: #009900;">&#40;</span>HttpServletRequest request, HttpServletResponse response<span style="color: #009900;">&#41;</span>
	<span style="color: #009900;">&#123;</span>
		<span style="color: #000000; font-weight: bold;">return</span> <span style="color: #000000; font-weight: bold;">new</span> ModelAndView<span style="color: #009900;">&#40;</span><span style="color: #0000ff;">&quot;basico&quot;</span>,<span style="color: #0000ff;">&quot;mensajeporpantalla&quot;</span>,<span style="color: #000000; font-weight: bold;">this</span>.<span style="color: #006633;">mensaje</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
	<span style="color: #009900;">&#125;</span>
&nbsp;
&nbsp;
&nbsp;
	<span style="color: #000000; font-weight: bold;">public</span> <span style="color: #000066; font-weight: bold;">void</span> setMensaje<span style="color: #009900;">&#40;</span><span style="color: #003399;">String</span> mensaje<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;">mensaje</span> <span style="color: #339933;">=</span> mensaje<span style="color: #339933;">;</span>
	<span style="color: #009900;">&#125;</span>
&nbsp;
&nbsp;
&nbsp;
<span style="color: #009900;">&#125;</span></pre></td></tr></table></div>

<p>En otro ejemplo más complejo se verán el tratamiento de objetos y formularios</p>
<img src="http://feeds.feedburner.com/~r/railsymas/~4/8Sg02eGetXQ" height="1" width="1"/>]]></content:encoded>
			<wfw:commentRss>http://www.railsymas.com/2011/12/28/integracion-plantillas-velocity-spring-framework-eg/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Instalando veloeclipse</title>
		<link>http://www.railsymas.com/2011/12/17/instalando-veloeclipse/</link>
		<comments>http://www.railsymas.com/2011/12/17/instalando-veloeclipse/#comments</comments>
		<pubDate>Sat, 17 Dec 2011 09:51:55 +0000</pubDate>
		<dc:creator>admin</dc:creator>
				<category><![CDATA[Nuevas Tecnologías]]></category>

		<guid isPermaLink="false">http://www.railsymas.com/?p=2543</guid>
		<description><![CDATA[Veloeclipse es un plugin para eclipse que nos ofrece un editor de código para diversas tecnologías. Veloeclipse es un editor para html, xml , jsp y velocity Para instalarlo abrimos nuestro espacio de trabajo de eclipse y vamos al menú pulsamos sobre help y seleccionamos la opción install new software una vez pulsada nos aparece [...]]]></description>
			<content:encoded><![CDATA[<p>Veloeclipse es un plugin para eclipse que nos ofrece un editor de código para diversas tecnologías.</p>
<p>Veloeclipse es un editor para html, xml , jsp y velocity</p>
<p><span id="more-2543"></span></p>
<p>Para instalarlo abrimos nuestro espacio de trabajo de eclipse y vamos al menú pulsamos sobre<br />
help y seleccionamos la opción install new software una vez pulsada nos aparece una ventena como la siguiente</p>
<p><img src="http://www.railsymas.com/wp-content/uploads/2011/12/velo1a.png" alt="" title="velo1a" width="702" height="423" class="alignnone size-full wp-image-2544" /></p>
<p>Pulsamos sobre add para añadir un nuevo repositorio a nuestro eclipse, en la ventana tenemos que darle un nombre en este caso elegimos velocity pero es opcional. La url es la indicada http://veloeclipse.googlecode.com/svn/trunk/update/</p>
<p><img src="http://www.railsymas.com/wp-content/uploads/2011/12/velo31.png" alt="" title="velo3" width="724" height="409" class="alignnone size-full wp-image-2551" /></p>
<p>Una vez elegido la versión del plugin y descargado nos aparece un mensaje indicando que es conveniente resetear eclipse para que los cambios tengan efecto</p>
<p><img src="http://www.railsymas.com/wp-content/uploads/2011/12/velo4.png" alt="" title="velo4" width="611" height="142" class="alignnone size-full wp-image-2552" /></p>
<p>Reconocimiento del código de archivos .vm</p>
<p><img src="http://www.railsymas.com/wp-content/uploads/2011/12/velo3.png" alt="" title="velo3" width="232" height="98" class="alignnone size-full wp-image-2549" /></p>
<p>En el siguiente enlace tenemos una introducción al lenguaje de las plantillas velocity</p>
<p><a href="http://www.railsymas.com/2010/07/01/plantillas-velocity/">plantillas velocity</a></p>
<img src="http://feeds.feedburner.com/~r/railsymas/~4/dz8pA11rdDM" height="1" width="1"/>]]></content:encoded>
			<wfw:commentRss>http://www.railsymas.com/2011/12/17/instalando-veloeclipse/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Instalando maven en ubuntu</title>
		<link>http://www.railsymas.com/2011/11/28/instalando-maven-en-ubuntu/</link>
		<comments>http://www.railsymas.com/2011/11/28/instalando-maven-en-ubuntu/#comments</comments>
		<pubDate>Mon, 28 Nov 2011 15:57:10 +0000</pubDate>
		<dc:creator>admin</dc:creator>
				<category><![CDATA[Nuevas Tecnologías]]></category>

		<guid isPermaLink="false">http://www.railsymas.com/?p=2521</guid>
		<description><![CDATA[Nos descargamos el proyecto desde el sitio oficial una vez descargado lo desempaquetamos en un directorio de nuestra computadora y obtenemos un directorio con el nombre maven Dentro del directorio tenemos la estructura de ficheros de la imagen anterior *Nota importante es necesario tener el jdk instalado no el jre ya que en algunos proyectos [...]]]></description>
			<content:encoded><![CDATA[<p>Nos descargamos el proyecto desde el sitio oficial</p>
<p><span id="more-2521"></span></p>
<p><img src="http://www.railsymas.com/wp-content/uploads/2011/11/maven1.jpg" alt="" title="maven1" width="650" height="600" class="alignnone size-full wp-image-2526" /></p>
<p>una vez descargado lo desempaquetamos en un directorio de nuestra computadora y obtenemos un directorio con el nombre maven</p>
<p><img src="http://www.railsymas.com/wp-content/uploads/2011/11/carpetamaven.png" alt="" title="carpetamaven" width="86" height="66" class="alignnone size-full wp-image-2524" /></p>
<p><img src="http://www.railsymas.com/wp-content/uploads/2011/11/maven2.png" alt="" title="maven2" width="630" height="193" class="alignnone size-full wp-image-2530" /></p>
<p>Dentro del directorio tenemos la estructura de ficheros de la imagen anterior</p>
<p>*Nota importante es necesario tener el jdk instalado no el jre ya que en algunos proyectos nos dará error al utilizar maven</p>
<p>Abrimos un terminal por consola y escribimos lo siguiente sudo gedit /etc/profile<br />
para guardar los cambios en el fichero de perfiles</p>

<div class="wp_syntax"><table><tr><td class="line_numbers"><pre>1
2
3
4
5
</pre></td><td class="code"><pre class="xml" style="font-family:monospace;">JAVA_HOME=/usr/lib/jvm/java-1.6.0-openjdk
M2_HOME=/home/directorio/maven
PATH=$PATH:$JAVA_HOME/bin:$M2_HOME/bin
export JAVA_HOME
export M2_HOME</pre></td></tr></table></div>

<p>Y para propagar los cambios escribimos por el terminal</p>
<p>una vez descargado en paquete de maven en algún lugar de nuestra computadora podemos comprobar la instalación mediante el comando mvn -v para ver la versión instalada.</p>

<div class="wp_syntax"><table><tr><td class="line_numbers"><pre>1
2
3
4
5
6
7
</pre></td><td class="code"><pre class="xml" style="font-family:monospace;">desktop:~$ mvn -v
Apache Maven 3.0.3 (r1075438; 2011-02-28 18:31:09+0100)
Maven home: /home/directorio de instalación/maven
Java version: 1.6.0_20, vendor: Sun Microsystems Inc.
Java home: /usr/lib/jvm/java-6-openjdk/jre
Default locale: es_ES, platform encoding: UTF-8
OS name: &quot;linux&quot;, version: &quot;2.6.32-35-generic&quot;, arch: &quot;i386&quot;, family: &quot;unix&quot;</pre></td></tr></table></div>

<img src="http://feeds.feedburner.com/~r/railsymas/~4/vD9Snlcvb1I" height="1" width="1"/>]]></content:encoded>
			<wfw:commentRss>http://www.railsymas.com/2011/11/28/instalando-maven-en-ubuntu/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Exportando los datos a pdf con spring framework</title>
		<link>http://www.railsymas.com/2011/10/31/exportando-los-datos-a-pdf-con-spring-framework/</link>
		<comments>http://www.railsymas.com/2011/10/31/exportando-los-datos-a-pdf-con-spring-framework/#comments</comments>
		<pubDate>Mon, 31 Oct 2011 16:20:07 +0000</pubDate>
		<dc:creator>admin</dc:creator>
				<category><![CDATA[spring]]></category>

		<guid isPermaLink="false">http://www.railsymas.com/?p=2494</guid>
		<description><![CDATA[En el anterior post habíamos visto para la categoría de spring framework un ejemplo de relación uno a uno con hibernate donde teníamos la posibilidad de además de almacenar los datos exportarlos a excel En el siguiente ejemplo vamos a exportar esos mismos datos a formato pdf Datos introducidos para un estudiante laura, maria y [...]]]></description>
			<content:encoded><![CDATA[<p> En el anterior post habíamos visto para la categoría de spring framework un ejemplo de relación uno a uno con hibernate donde teníamos la posibilidad de además de almacenar los datos exportarlos a excel</p>
<p><span id="more-2494"></span></p>
<p> En el siguiente ejemplo vamos a exportar esos mismos datos a formato pdf</p>
<p> Datos introducidos para un estudiante laura, maria y juan</p>
<p> <img src="http://www.railsymas.com/wp-content/uploads/2011/10/spdf1.png" alt="" title="spdf1" width="617" height="357" class="alignnone size-full wp-image-2512" /></p>
<p> Visualización de datos </p>
<p> <img src="http://www.railsymas.com/wp-content/uploads/2011/10/spdf2.png" alt="" title="spdf2" width="609" height="399" class="alignnone size-full wp-image-2514" /></p>
<p>Pulsamos sobre el icono de fichero pdf</p>
<p><img src="http://www.railsymas.com/wp-content/uploads/2011/10/spdf3.png" alt="" title="spdf3" width="600" height="421" class="alignnone size-full wp-image-2516" /></p>
<p> Código de la clase de recursos</p>

<div class="wp_syntax"><table><tr><td class="line_numbers"><pre>1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
</pre></td><td class="code"><pre class="java" style="font-family:monospace;"> <span style="color: #000000; font-weight: bold;">package</span> <span style="color: #006699;">recursos</span><span style="color: #339933;">;</span>
&nbsp;
<span style="color: #000000; font-weight: bold;">import</span> <span style="color: #006699;">java.util.List</span><span style="color: #339933;">;</span>
<span style="color: #000000; font-weight: bold;">import</span> <span style="color: #006699;">java.util.Map</span><span style="color: #339933;">;</span>
<span style="color: #000000; font-weight: bold;">import</span> <span style="color: #006699;">java.util.Iterator</span><span style="color: #339933;">;</span>
&nbsp;
<span style="color: #000000; font-weight: bold;">import</span> <span style="color: #006699;">javax.servlet.ServletOutputStream</span><span style="color: #339933;">;</span>
<span style="color: #000000; font-weight: bold;">import</span> <span style="color: #006699;">javax.servlet.http.HttpServletRequest</span><span style="color: #339933;">;</span>
<span style="color: #000000; font-weight: bold;">import</span> <span style="color: #006699;">javax.servlet.http.HttpServletResponse</span><span style="color: #339933;">;</span>
<span style="color: #000000; font-weight: bold;">import</span> <span style="color: #006699;">org.springframework.web.servlet.view.document.AbstractPdfView</span><span style="color: #339933;">;</span>
&nbsp;
<span style="color: #000000; font-weight: bold;">import</span> <span style="color: #006699;">com.lowagie.text.Document</span><span style="color: #339933;">;</span>
<span style="color: #000000; font-weight: bold;">import</span> <span style="color: #006699;">com.lowagie.text.Element</span><span style="color: #339933;">;</span>
&nbsp;
<span style="color: #000000; font-weight: bold;">import</span> <span style="color: #006699;">com.lowagie.text.pdf.PdfWriter</span><span style="color: #339933;">;</span>
<span style="color: #000000; font-weight: bold;">import</span> <span style="color: #006699;">com.lowagie.text.pdf.PdfPTable</span><span style="color: #339933;">;</span>
<span style="color: #000000; font-weight: bold;">import</span> <span style="color: #006699;">com.lowagie.text.pdf.PdfPCell</span><span style="color: #339933;">;</span>
&nbsp;
&nbsp;
<span style="color: #000000; font-weight: bold;">import</span> <span style="color: #006699;">modelos.Estudiante</span><span style="color: #339933;">;</span>
<span style="color: #000000; font-weight: bold;">import</span> <span style="color: #006699;">modelos.Direccion</span><span style="color: #339933;">;</span>
&nbsp;
<span style="color: #000000; font-weight: bold;">import</span> <span style="color: #006699;">java.io.ByteArrayOutputStream</span><span style="color: #339933;">;</span>
&nbsp;
<span style="color: #000000; font-weight: bold;">import</span> <span style="color: #006699;">com.lowagie.text.Paragraph</span><span style="color: #339933;">;</span>
&nbsp;
<span style="color: #000000; font-weight: bold;">import</span> <span style="color: #006699;">java.awt.Color</span><span style="color: #339933;">;</span>
&nbsp;
<span style="color: #000000; font-weight: bold;">public</span> <span style="color: #000000; font-weight: bold;">class</span> GenerarPdf  <span style="color: #000000; font-weight: bold;">extends</span> AbstractPdfView <span style="color: #009900;">&#123;</span>
&nbsp;
&nbsp;
	 <span style="color: #000000; font-weight: bold;">private</span> <span style="color: #003399;">ByteArrayOutputStream</span> fichero <span style="color: #339933;">=</span> <span style="color: #000000; font-weight: bold;">new</span> <span style="color: #003399;">ByteArrayOutputStream</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
&nbsp;
&nbsp;
	<span style="color: #000000; font-weight: bold;">public</span> <span style="color: #000066; font-weight: bold;">void</span> buildPdfDocument <span style="color: #009900;">&#40;</span> <span style="color: #003399;">Map</span> model, <span style="color: #003399;">Document</span> document, PdfWriter pdfwriter,HttpServletRequest request, HttpServletResponse response<span style="color: #009900;">&#41;</span> <span style="color: #000000; font-weight: bold;">throws</span> <span style="color: #003399;">Exception</span>
	<span style="color: #009900;">&#123;</span>  
&nbsp;
		List<span style="color: #339933;">&lt;</span>Estudiante<span style="color: #339933;">&gt;</span> estudiantes <span style="color: #339933;">=</span> <span style="color: #009900;">&#40;</span><span style="color: #003399;">List</span><span style="color: #009900;">&#41;</span> model.<span style="color: #006633;">get</span><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">&quot;estudiantes&quot;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
		List<span style="color: #339933;">&lt;</span>Direccion<span style="color: #339933;">&gt;</span> direcciones <span style="color: #339933;">=</span> <span style="color: #009900;">&#40;</span><span style="color: #003399;">List</span><span style="color: #009900;">&#41;</span> model.<span style="color: #006633;">get</span><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">&quot;direcciones&quot;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
&nbsp;
&nbsp;
&nbsp;
&nbsp;
		document.<span style="color: #006633;">open</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
&nbsp;
&nbsp;
		PdfPTable tablaestudiantes <span style="color: #339933;">=</span> <span style="color: #000000; font-weight: bold;">new</span> PdfPTable<span style="color: #009900;">&#40;</span><span style="color: #cc66cc;">2</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
&nbsp;
		PdfPCell celdanombre <span style="color: #339933;">=</span> <span style="color: #000000; font-weight: bold;">new</span> PdfPCell<span style="color: #009900;">&#40;</span><span style="color: #000000; font-weight: bold;">new</span> Paragraph<span style="color: #009900;">&#40;</span><span style="color: #0000ff;">&quot;nombre&quot;</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
		PdfPCell celdaedad <span style="color: #339933;">=</span> <span style="color: #000000; font-weight: bold;">new</span> PdfPCell<span style="color: #009900;">&#40;</span><span style="color: #000000; font-weight: bold;">new</span> Paragraph<span style="color: #009900;">&#40;</span><span style="color: #0000ff;">&quot;edad&quot;</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
		PdfPCell tituloestudiantes <span style="color: #339933;">=</span> <span style="color: #000000; font-weight: bold;">new</span> PdfPCell<span style="color: #009900;">&#40;</span> <span style="color: #000000; font-weight: bold;">new</span> Paragraph<span style="color: #009900;">&#40;</span><span style="color: #0000ff;">&quot;listado estudiantes&quot;</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
		tituloestudiantes.<span style="color: #006633;">setColspan</span><span style="color: #009900;">&#40;</span><span style="color: #cc66cc;">2</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
		tituloestudiantes.<span style="color: #006633;">setBackgroundColor</span><span style="color: #009900;">&#40;</span><span style="color: #000000; font-weight: bold;">new</span> <span style="color: #003399;">Color</span><span style="color: #009900;">&#40;</span><span style="color: #cc66cc;">214</span>,<span style="color: #cc66cc;">246</span>,<span style="color: #cc66cc;">145</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
		tituloestudiantes.<span style="color: #006633;">setHorizontalAlignment</span><span style="color: #009900;">&#40;</span><span style="color: #003399;">Element</span>.<span style="color: #006633;">ALIGN_CENTER</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
		celdanombre.<span style="color: #006633;">setHorizontalAlignment</span><span style="color: #009900;">&#40;</span><span style="color: #003399;">Element</span>.<span style="color: #006633;">ALIGN_CENTER</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
		celdanombre.<span style="color: #006633;">setBackgroundColor</span><span style="color: #009900;">&#40;</span><span style="color: #000000; font-weight: bold;">new</span> <span style="color: #003399;">Color</span><span style="color: #009900;">&#40;</span><span style="color: #cc66cc;">217</span>,<span style="color: #cc66cc;">217</span>,<span style="color: #cc66cc;">180</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
		celdaedad.<span style="color: #006633;">setHorizontalAlignment</span><span style="color: #009900;">&#40;</span><span style="color: #003399;">Element</span>.<span style="color: #006633;">ALIGN_CENTER</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
		celdaedad.<span style="color: #006633;">setBackgroundColor</span><span style="color: #009900;">&#40;</span><span style="color: #000000; font-weight: bold;">new</span> <span style="color: #003399;">Color</span><span style="color: #009900;">&#40;</span><span style="color: #cc66cc;">217</span>,<span style="color: #cc66cc;">217</span>,<span style="color: #cc66cc;">180</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
&nbsp;
&nbsp;
		tablaestudiantes.<span style="color: #006633;">addCell</span><span style="color: #009900;">&#40;</span>tituloestudiantes<span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
		tablaestudiantes.<span style="color: #006633;">addCell</span><span style="color: #009900;">&#40;</span>celdanombre<span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
		tablaestudiantes.<span style="color: #006633;">addCell</span><span style="color: #009900;">&#40;</span>celdaedad<span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
&nbsp;
&nbsp;
&nbsp;
	    <span style="color: #000000; font-weight: bold;">for</span> <span style="color: #009900;">&#40;</span> Iterator<span style="color: #339933;">&lt;</span>Estudiante<span style="color: #339933;">&gt;</span> iterador <span style="color: #339933;">=</span>  estudiantes.<span style="color: #006633;">iterator</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span> iterador.<span style="color: #006633;">hasNext</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span><span style="color: #009900;">&#41;</span>
	    <span style="color: #009900;">&#123;</span>
	    	Estudiante estudiante <span style="color: #339933;">=</span> <span style="color: #009900;">&#40;</span>Estudiante<span style="color: #009900;">&#41;</span> iterador.<span style="color: #006633;">next</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
	    	tablaestudiantes.<span style="color: #006633;">addCell</span><span style="color: #009900;">&#40;</span>estudiante.<span style="color: #006633;">getNombre</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
	    	tablaestudiantes.<span style="color: #006633;">addCell</span><span style="color: #009900;">&#40;</span>estudiante.<span style="color: #006633;">getEdad</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
	    <span style="color: #009900;">&#125;</span>
&nbsp;
&nbsp;
	    document.<span style="color: #006633;">add</span><span style="color: #009900;">&#40;</span>tablaestudiantes<span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
&nbsp;
	    document.<span style="color: #006633;">add</span><span style="color: #009900;">&#40;</span><span style="color: #000000; font-weight: bold;">new</span> Paragraph<span style="color: #009900;">&#40;</span><span style="color: #0000ff;">&quot;                                         &quot;</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
&nbsp;
	    PdfPTable tabladirecciones <span style="color: #339933;">=</span>  <span style="color: #000000; font-weight: bold;">new</span> PdfPTable<span style="color: #009900;">&#40;</span><span style="color: #cc66cc;">2</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
&nbsp;
&nbsp;
	    PdfPCell celdacalle<span style="color: #339933;">=</span> <span style="color: #000000; font-weight: bold;">new</span> PdfPCell<span style="color: #009900;">&#40;</span><span style="color: #000000; font-weight: bold;">new</span> Paragraph<span style="color: #009900;">&#40;</span><span style="color: #0000ff;">&quot;calle&quot;</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
		PdfPCell celdalocalidad <span style="color: #339933;">=</span> <span style="color: #000000; font-weight: bold;">new</span> PdfPCell<span style="color: #009900;">&#40;</span><span style="color: #000000; font-weight: bold;">new</span> Paragraph<span style="color: #009900;">&#40;</span><span style="color: #0000ff;">&quot;localidad&quot;</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
		PdfPCell titulodirecciones <span style="color: #339933;">=</span> <span style="color: #000000; font-weight: bold;">new</span> PdfPCell<span style="color: #009900;">&#40;</span> <span style="color: #000000; font-weight: bold;">new</span> Paragraph<span style="color: #009900;">&#40;</span><span style="color: #0000ff;">&quot;listado direcciones&quot;</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
&nbsp;
		titulodirecciones.<span style="color: #006633;">setColspan</span><span style="color: #009900;">&#40;</span><span style="color: #cc66cc;">2</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
		titulodirecciones.<span style="color: #006633;">setBackgroundColor</span><span style="color: #009900;">&#40;</span><span style="color: #000000; font-weight: bold;">new</span> <span style="color: #003399;">Color</span><span style="color: #009900;">&#40;</span><span style="color: #cc66cc;">214</span>,<span style="color: #cc66cc;">246</span>,<span style="color: #cc66cc;">145</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
		titulodirecciones.<span style="color: #006633;">setHorizontalAlignment</span><span style="color: #009900;">&#40;</span><span style="color: #003399;">Element</span>.<span style="color: #006633;">ALIGN_CENTER</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
		celdacalle.<span style="color: #006633;">setBackgroundColor</span><span style="color: #009900;">&#40;</span><span style="color: #000000; font-weight: bold;">new</span> <span style="color: #003399;">Color</span><span style="color: #009900;">&#40;</span><span style="color: #cc66cc;">217</span>,<span style="color: #cc66cc;">217</span>,<span style="color: #cc66cc;">180</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
		celdacalle.<span style="color: #006633;">setHorizontalAlignment</span><span style="color: #009900;">&#40;</span><span style="color: #003399;">Element</span>.<span style="color: #006633;">ALIGN_CENTER</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
		celdalocalidad.<span style="color: #006633;">setBackgroundColor</span><span style="color: #009900;">&#40;</span><span style="color: #000000; font-weight: bold;">new</span> <span style="color: #003399;">Color</span><span style="color: #009900;">&#40;</span><span style="color: #cc66cc;">217</span>,<span style="color: #cc66cc;">217</span>,<span style="color: #cc66cc;">180</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
		celdalocalidad.<span style="color: #006633;">setHorizontalAlignment</span><span style="color: #009900;">&#40;</span><span style="color: #003399;">Element</span>.<span style="color: #006633;">ALIGN_CENTER</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
&nbsp;
		tabladirecciones.<span style="color: #006633;">addCell</span><span style="color: #009900;">&#40;</span>titulodirecciones<span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
	        tabladirecciones.<span style="color: #006633;">addCell</span><span style="color: #009900;">&#40;</span>celdacalle<span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
	        tabladirecciones.<span style="color: #006633;">addCell</span><span style="color: #009900;">&#40;</span>celdalocalidad<span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
&nbsp;
&nbsp;
&nbsp;
&nbsp;
	    <span style="color: #000000; font-weight: bold;">for</span> <span style="color: #009900;">&#40;</span> Iterator<span style="color: #339933;">&lt;</span>Direccion<span style="color: #339933;">&gt;</span> iterador <span style="color: #339933;">=</span>  direcciones.<span style="color: #006633;">iterator</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span> iterador.<span style="color: #006633;">hasNext</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span><span style="color: #009900;">&#41;</span>
	    <span style="color: #009900;">&#123;</span>
	    	Direccion direccion <span style="color: #339933;">=</span> <span style="color: #009900;">&#40;</span>Direccion<span style="color: #009900;">&#41;</span> iterador.<span style="color: #006633;">next</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
	    	tabladirecciones.<span style="color: #006633;">addCell</span><span style="color: #009900;">&#40;</span>direccion.<span style="color: #006633;">getCalle</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
	    	tabladirecciones.<span style="color: #006633;">addCell</span><span style="color: #009900;">&#40;</span>direccion.<span style="color: #006633;">getLocalidad</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
	    <span style="color: #009900;">&#125;</span>
&nbsp;
	    document.<span style="color: #006633;">add</span><span style="color: #009900;">&#40;</span>tabladirecciones<span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
&nbsp;
	    document.<span style="color: #006633;">close</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
&nbsp;
&nbsp;
	    response.<span style="color: #006633;">setContentType</span><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">&quot;application/pdf&quot;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
&nbsp;
	    response.<span style="color: #006633;">setContentLength</span><span style="color: #009900;">&#40;</span><span style="color: #000000; font-weight: bold;">this</span>.<span style="color: #006633;">fichero</span>.<span style="color: #006633;">size</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
&nbsp;
	    response.<span style="color: #006633;">setHeader</span><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">&quot;Content-disposition&quot;</span>,<span style="color: #0000ff;">&quot;attachment; filename=estudiantes.pdf&quot;</span> <span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
&nbsp;
	    ServletOutputStream out <span style="color: #339933;">=</span> response.<span style="color: #006633;">getOutputStream</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
&nbsp;
	    <span style="color: #000000; font-weight: bold;">this</span>.<span style="color: #006633;">fichero</span>.<span style="color: #006633;">writeTo</span><span style="color: #009900;">&#40;</span>out<span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
&nbsp;
	    out.<span style="color: #006633;">flush</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
&nbsp;
&nbsp;
&nbsp;
	<span style="color: #009900;">&#125;</span>
&nbsp;
&nbsp;
&nbsp;
&nbsp;
	<span style="color: #000000; font-weight: bold;">public</span> <span style="color: #000066; font-weight: bold;">void</span> llamandoBuildPdf<span style="color: #009900;">&#40;</span>Map<span style="color: #339933;">&lt;</span>String,List<span style="color: #339933;">&gt;</span> model,HttpServletRequest request, HttpServletResponse response<span style="color: #009900;">&#41;</span> <span style="color: #000000; font-weight: bold;">throws</span> <span style="color: #003399;">Exception</span>
	<span style="color: #009900;">&#123;</span>
&nbsp;
	   <span style="color: #003399;">Document</span> document <span style="color: #339933;">=</span> <span style="color: #000000; font-weight: bold;">new</span> <span style="color: #003399;">Document</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
&nbsp;
	   document.<span style="color: #006633;">addTitle</span><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">&quot;listado estudiantes hibernate &quot;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
&nbsp;
&nbsp;
&nbsp;
	   PdfWriter aux  <span style="color: #339933;">=</span>	PdfWriter.<span style="color: #006633;">getInstance</span><span style="color: #009900;">&#40;</span>document,<span style="color: #000000; font-weight: bold;">this</span>.<span style="color: #006633;">fichero</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
&nbsp;
	   buildPdfDocument <span style="color: #009900;">&#40;</span>model,document,aux, request, response<span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
&nbsp;
&nbsp;
&nbsp;
&nbsp;
	<span style="color: #009900;">&#125;</span>
&nbsp;
&nbsp;
&nbsp;
<span style="color: #009900;">&#125;</span></pre></td></tr></table></div>

<p>Gracias al controlador que lo hemos declarado como multiactioncontroller podemos realizar múltiples acciones en un mismo fichero de clase permitiéndonos introducir los datos en la base de datos así como exportarlos tanto a excel como a pdf</p>
<p>Modificamos la vista del formulario de estudiantes del anterior ejemplo para ello creamos un menú para tener las dos opciones disponibles </p>
<p>css encargada del menú</p>

<div class="wp_syntax"><table><tr><td class="line_numbers"><pre>1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
</pre></td><td class="code"><pre class="css" style="font-family:monospace;">ul<span style="color: #00AA00;">&#123;</span>
&nbsp;
 <span style="color: #000000; font-weight: bold;">margin-left</span><span style="color: #00AA00;">:</span><span style="color: #933;">300px</span><span style="color: #00AA00;">;</span>
&nbsp;
 <span style="color: #00AA00;">&#125;</span>
&nbsp;
 ul li <span style="color: #00AA00;">&#123;</span> 
  <span style="color: #000000; font-weight: bold;">float</span><span style="color: #00AA00;">:</span><span style="color: #000000; font-weight: bold;">left</span><span style="color: #00AA00;">;</span>
  <span style="color: #000000; font-weight: bold;">margin-right</span><span style="color: #00AA00;">:</span><span style="color: #933;">10px</span><span style="color: #00AA00;">;</span>
  <span style="color: #000000; font-weight: bold;">list-style-type</span><span style="color: #00AA00;">:</span> <span style="color: #993333;">none</span><span style="color: #00AA00;">;</span>
 <span style="color: #00AA00;">&#125;</span>  
&nbsp;
 <span style="color: #cc00cc;">#enlacepdf</span> a<span style="color: #00AA00;">&#123;</span>
&nbsp;
   <span style="color: #000000; font-weight: bold;">background-image</span><span style="color: #00AA00;">:</span> <span style="color: #993333;">url</span><span style="color: #00AA00;">&#40;</span><span style="color: #ff0000;">&quot;../imagenes/file_pdf.png&quot;</span><span style="color: #00AA00;">&#41;</span><span style="color: #00AA00;">;</span>
   <span style="color: #000000; font-weight: bold;">background-repeat</span><span style="color: #00AA00;">:</span> <span style="color: #993333;">no-repeat</span><span style="color: #00AA00;">;</span>
   <span style="color: #000000; font-weight: bold;">display</span><span style="color: #00AA00;">:</span><span style="color: #993333;">block</span><span style="color: #00AA00;">;</span>
   <span style="color: #000000; font-weight: bold;">width</span><span style="color: #00AA00;">:</span><span style="color: #933;">50px</span><span style="color: #00AA00;">;</span>
   <span style="color: #000000; font-weight: bold;">height</span><span style="color: #00AA00;">:</span><span style="color: #933;">50px</span><span style="color: #00AA00;">;</span>
&nbsp;
&nbsp;
&nbsp;
 <span style="color: #00AA00;">&#125;</span>
&nbsp;
 <span style="color: #cc00cc;">#enlaceexcel</span> a <span style="color: #00AA00;">&#123;</span>
 <span style="color: #000000; font-weight: bold;">background-image</span><span style="color: #00AA00;">:</span> <span style="color: #993333;">url</span><span style="color: #00AA00;">&#40;</span><span style="color: #ff0000;">&quot;../imagenes/file_excel.png&quot;</span><span style="color: #00AA00;">&#41;</span><span style="color: #00AA00;">;</span>
 <span style="color: #000000; font-weight: bold;">background-repeat</span><span style="color: #00AA00;">:</span> <span style="color: #993333;">no-repeat</span><span style="color: #00AA00;">;</span>
 <span style="color: #000000; font-weight: bold;">display</span><span style="color: #00AA00;">:</span><span style="color: #993333;">block</span><span style="color: #00AA00;">;</span>
 <span style="color: #000000; font-weight: bold;">width</span><span style="color: #00AA00;">:</span><span style="color: #933;">55px</span><span style="color: #00AA00;">;</span>
 <span style="color: #000000; font-weight: bold;">height</span><span style="color: #00AA00;">:</span><span style="color: #933;">55px</span><span style="color: #00AA00;">;</span>
&nbsp;
&nbsp;
&nbsp;
 <span style="color: #00AA00;">&#125;</span></pre></td></tr></table></div>

<p>Dentro del controlador estudiante añadimos el método</p>
<p>generarPdf</p>

<div class="wp_syntax"><table><tr><td class="line_numbers"><pre>1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
</pre></td><td class="code"><pre class="java" style="font-family:monospace;">  <span style="color: #000000; font-weight: bold;">public</span> <span style="color: #000066; font-weight: bold;">void</span> generarPdf<span style="color: #009900;">&#40;</span>HttpServletRequest request, HttpServletResponse response<span style="color: #009900;">&#41;</span> <span style="color: #000000; font-weight: bold;">throws</span> <span style="color: #003399;">Exception</span>
    <span style="color: #009900;">&#123;</span>
&nbsp;
&nbsp;
      List<span style="color: #339933;">&lt;</span>Estudiante<span style="color: #339933;">&gt;</span> estudiantes <span style="color: #339933;">=</span> estudianteDao.<span style="color: #006633;">listadoEstudiantes</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
&nbsp;
      List<span style="color: #339933;">&lt;</span>Direccion<span style="color: #339933;">&gt;</span> direcciones <span style="color: #339933;">=</span> estudianteDao.<span style="color: #006633;">listadoDireccion</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
&nbsp;
      <span style="color: #003399;">Map</span> modelmap <span style="color: #339933;">=</span> <span style="color: #000000; font-weight: bold;">new</span> <span style="color: #003399;">HashMap</span> <span style="color: #339933;">&lt;</span>String,List<span style="color: #339933;">&gt;</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
&nbsp;
      modelmap.<span style="color: #006633;">put</span><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">&quot;estudiantes&quot;</span>, estudiantes<span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
&nbsp;
      modelmap.<span style="color: #006633;">put</span><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">&quot;direcciones&quot;</span>, direcciones<span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>      
&nbsp;
      GenerarPdf pdf <span style="color: #339933;">=</span> <span style="color: #000000; font-weight: bold;">new</span> GenerarPdf<span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
&nbsp;
      pdf.<span style="color: #006633;">llamandoBuildPdf</span><span style="color: #009900;">&#40;</span>modelmap, request, response<span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
&nbsp;
&nbsp;
&nbsp;
&nbsp;
&nbsp;
&nbsp;
&nbsp;
    <span style="color: #009900;">&#125;</span></pre></td></tr></table></div>

<p>Cambiamos el código de la página para poder visualizar el menú</p>

<div class="wp_syntax"><table><tr><td class="line_numbers"><pre>1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
</pre></td><td class="code"><pre class="java" style="font-family:monospace;"><span style="color: #339933;">&lt;%</span>@ page language<span style="color: #339933;">=</span><span style="color: #0000ff;">&quot;java&quot;</span> contentType<span style="color: #339933;">=</span><span style="color: #0000ff;">&quot;text/html; charset=UTF-8&quot;</span> 
    pageEncoding<span style="color: #339933;">=</span><span style="color: #0000ff;">&quot;UTF-8&quot;</span><span style="color: #339933;">%&gt;</span>
<span style="color: #339933;">&lt;%</span>@taglib uri<span style="color: #339933;">=</span><span style="color: #0000ff;">&quot;http://www.springframework.org/tags&quot;</span> prefix<span style="color: #339933;">=</span><span style="color: #0000ff;">&quot;spring&quot;</span> <span style="color: #339933;">%&gt;</span>
<span style="color: #339933;">&lt;%</span>@taglib uri<span style="color: #339933;">=</span><span style="color: #0000ff;">&quot;http://java.sun.com/jsp/jstl/core&quot;</span> prefix<span style="color: #339933;">=</span><span style="color: #0000ff;">&quot;c&quot;</span> <span style="color: #339933;">%&gt;</span>
<span style="color: #339933;">&lt;%</span>@taglib uri<span style="color: #339933;">=</span><span style="color: #0000ff;">&quot;http://www.springframework.org/tags/form&quot;</span> prefix<span style="color: #339933;">=</span><span style="color: #0000ff;">&quot;form&quot;</span> <span style="color: #339933;">%&gt;</span>
<span style="color: #339933;">&lt;!</span>DOCTYPE html <span style="color: #000000; font-weight: bold;">PUBLIC</span> <span style="color: #0000ff;">&quot;-//W3C//DTD HTML 4.01 Transitional//EN&quot;</span>
 <span style="color: #0000ff;">&quot;http://www.w3.org/TR/html4/loose.dtd&quot;</span><span style="color: #339933;">&gt;</span>
<span style="color: #339933;">&lt;</span>html<span style="color: #339933;">&gt;</span>
<span style="color: #339933;">&lt;</span>head<span style="color: #339933;">&gt;</span>
<span style="color: #339933;">&lt;</span>meta http<span style="color: #339933;">-</span>equiv<span style="color: #339933;">=</span><span style="color: #0000ff;">&quot;Content-Type&quot;</span> content<span style="color: #339933;">=</span><span style="color: #0000ff;">&quot;text/html; charset=UTF-8&quot;</span><span style="color: #339933;">&gt;</span>
<span style="color: #339933;">&lt;</span>link rel<span style="color: #339933;">=</span><span style="color: #0000ff;">&quot;stylesheet&quot;</span> href<span style="color: #339933;">=</span><span style="color: #0000ff;">&quot;css/estilo.css&quot;</span> type<span style="color: #339933;">=</span><span style="color: #0000ff;">&quot;text/css&quot;</span><span style="color: #339933;">/&gt;</span>
<span style="color: #339933;">&lt;</span>title<span style="color: #339933;">&gt;&lt;</span>spring<span style="color: #339933;">:</span>message code<span style="color: #339933;">=</span><span style="color: #0000ff;">&quot;unoanuno.resultado&quot;</span><span style="color: #339933;">/&gt;&lt;/</span>title<span style="color: #339933;">&gt;</span>
<span style="color: #339933;">&lt;/</span>head<span style="color: #339933;">&gt;</span>
<span style="color: #339933;">&lt;</span>body<span style="color: #339933;">&gt;</span>
&nbsp;
 <span style="color: #339933;">&lt;</span>div id<span style="color: #339933;">=</span><span style="color: #0000ff;">&quot;contenedor&quot;</span><span style="color: #339933;">&gt;</span>
&nbsp;
&nbsp;
&nbsp;
 <span style="color: #339933;">&lt;</span>ul id<span style="color: #339933;">=</span><span style="color: #0000ff;">&quot;menu&quot;</span><span style="color: #339933;">&gt;</span>
 <span style="color: #339933;">&lt;</span>li<span style="color: #339933;">&gt;</span>
 <span style="color: #339933;">&lt;</span>div id<span style="color: #339933;">=</span><span style="color: #0000ff;">&quot;enlacepdf&quot;</span><span style="color: #339933;">&gt;</span>
 <span style="color: #339933;">&lt;</span>a href<span style="color: #339933;">=</span><span style="color: #0000ff;">&quot;&lt;c:url value='formularioestudiante.html?method=generarPdf'/&gt;&quot;</span><span style="color: #339933;">&gt;&lt;/</span>a<span style="color: #339933;">&gt;</span>
 <span style="color: #339933;">&lt;/</span>div<span style="color: #339933;">&gt;</span>
 <span style="color: #339933;">&lt;/</span>li<span style="color: #339933;">&gt;</span>
 <span style="color: #339933;">&lt;</span>li<span style="color: #339933;">&gt;</span>
 <span style="color: #339933;">&lt;</span>div id<span style="color: #339933;">=</span><span style="color: #0000ff;">&quot;enlaceexcel&quot;</span><span style="color: #339933;">&gt;</span>
  <span style="color: #339933;">&lt;</span>a href<span style="color: #339933;">=</span><span style="color: #0000ff;">&quot;&lt;c:url value='formularioestudiante.html?method=generarExcel'/&gt;&quot;</span><span style="color: #339933;">&gt;&lt;/</span>a<span style="color: #339933;">&gt;</span>
 <span style="color: #339933;">&lt;/</span>div<span style="color: #339933;">&gt;</span>
 <span style="color: #339933;">&lt;/</span>li<span style="color: #339933;">&gt;</span>
 <span style="color: #339933;">&lt;/</span>ul<span style="color: #339933;">&gt;</span>
&nbsp;
&nbsp;
&nbsp;
&nbsp;
 <span style="color: #339933;">&lt;</span>div id<span style="color: #339933;">=</span><span style="color: #0000ff;">&quot;borrar&quot;</span><span style="color: #339933;">&gt;</span>
   <span style="color: #339933;">&amp;</span>nbsp<span style="color: #339933;">;</span>
 <span style="color: #339933;">&lt;/</span>div<span style="color: #339933;">&gt;</span>
&nbsp;
 <span style="color: #339933;">&lt;</span>div <span style="color: #000000; font-weight: bold;">class</span><span style="color: #339933;">=</span><span style="color: #0000ff;">&quot;campo&quot;</span><span style="color: #339933;">&gt;</span>
&nbsp;
 <span style="color: #339933;">&lt;</span>c<span style="color: #339933;">:</span>out value<span style="color: #339933;">=</span><span style="color: #0000ff;">&quot;listado de  estudiantes&quot;</span><span style="color: #339933;">/&gt;</span>
&nbsp;
 <span style="color: #339933;">&lt;</span>br<span style="color: #339933;">/&gt;</span>
&nbsp;
 <span style="color: #339933;">&lt;</span>div <span style="color: #000000; font-weight: bold;">class</span><span style="color: #339933;">=</span><span style="color: #0000ff;">&quot;tabla&quot;</span><span style="color: #339933;">&gt;</span>
&nbsp;
 <span style="color: #339933;">&lt;</span>table title<span style="color: #339933;">=</span><span style="color: #0000ff;">&quot;listado de estudiantes&quot;</span><span style="color: #339933;">&gt;</span>
 <span style="color: #339933;">&lt;</span>tr<span style="color: #339933;">&gt;</span>
 <span style="color: #339933;">&lt;</span>th<span style="color: #339933;">&gt;</span>nombre<span style="color: #339933;">&lt;/</span>th<span style="color: #339933;">&gt;</span>
 <span style="color: #339933;">&lt;</span>th<span style="color: #339933;">&gt;</span>edad<span style="color: #339933;">&lt;/</span>th<span style="color: #339933;">&gt;</span> 
 <span style="color: #339933;">&lt;/</span>tr<span style="color: #339933;">&gt;</span>
 <span style="color: #339933;">&lt;</span>c<span style="color: #339933;">:</span><span style="color: #000000; font-weight: bold;">forEach</span> items<span style="color: #339933;">=</span><span style="color: #0000ff;">&quot;${estudiantes}&quot;</span> var<span style="color: #339933;">=</span><span style="color: #0000ff;">&quot;estudiante&quot;</span><span style="color: #339933;">&gt;</span>
&nbsp;
  <span style="color: #339933;">&lt;</span>tr<span style="color: #339933;">&gt;</span>
&nbsp;
  <span style="color: #339933;">&lt;</span>td <span style="color: #000000; font-weight: bold;">class</span><span style="color: #339933;">=</span><span style="color: #0000ff;">&quot;impar&quot;</span><span style="color: #339933;">&gt;</span>  <span style="color: #339933;">&lt;</span>c<span style="color: #339933;">:</span>out value<span style="color: #339933;">=</span><span style="color: #0000ff;">&quot;${estudiante.nombre}&quot;</span><span style="color: #339933;">/&gt;</span> <span style="color: #339933;">&lt;/</span>td<span style="color: #339933;">&gt;</span>
  <span style="color: #339933;">&lt;</span>td <span style="color: #000000; font-weight: bold;">class</span><span style="color: #339933;">=</span><span style="color: #0000ff;">&quot;par&quot;</span><span style="color: #339933;">&gt;</span>  <span style="color: #339933;">&lt;</span>c<span style="color: #339933;">:</span>out value<span style="color: #339933;">=</span><span style="color: #0000ff;">&quot;${estudiante.edad}&quot;</span><span style="color: #339933;">/&gt;</span> <span style="color: #339933;">&lt;/</span>td<span style="color: #339933;">&gt;</span>
  <span style="color: #339933;">&lt;/</span>tr<span style="color: #339933;">&gt;</span>
 <span style="color: #339933;">&lt;/</span>c<span style="color: #339933;">:</span>forEach<span style="color: #339933;">&gt;</span>
&nbsp;
 <span style="color: #339933;">&lt;/</span>table<span style="color: #339933;">&gt;</span>
 <span style="color: #339933;">&lt;/</span>div<span style="color: #339933;">&gt;</span>
&nbsp;
&nbsp;
 <span style="color: #339933;">&lt;/</span>div<span style="color: #339933;">&gt;</span>
&nbsp;
 <span style="color: #339933;">&lt;</span>div <span style="color: #000000; font-weight: bold;">class</span><span style="color: #339933;">=</span><span style="color: #0000ff;">&quot;campo&quot;</span><span style="color: #339933;">&gt;</span>
&nbsp;
 <span style="color: #339933;">&lt;</span>c<span style="color: #339933;">:</span>out value<span style="color: #339933;">=</span><span style="color: #0000ff;">&quot;listado de direcciones&quot;</span><span style="color: #339933;">/&gt;</span>
&nbsp;
 <span style="color: #339933;">&lt;</span>br<span style="color: #339933;">/&gt;</span>
&nbsp;
 <span style="color: #339933;">&lt;</span>div <span style="color: #000000; font-weight: bold;">class</span><span style="color: #339933;">=</span><span style="color: #0000ff;">&quot;tabla&quot;</span><span style="color: #339933;">&gt;</span>
&nbsp;
 <span style="color: #339933;">&lt;</span>table title<span style="color: #339933;">=</span><span style="color: #0000ff;">&quot;listado de direcciones&quot;</span><span style="color: #339933;">&gt;</span>
&nbsp;
 <span style="color: #339933;">&lt;</span>tr<span style="color: #339933;">&gt;</span>
 <span style="color: #339933;">&lt;</span>th<span style="color: #339933;">&gt;</span>calle<span style="color: #339933;">&lt;/</span>th<span style="color: #339933;">&gt;</span>
 <span style="color: #339933;">&lt;</span>th<span style="color: #339933;">&gt;</span>localidad<span style="color: #339933;">&lt;/</span>th<span style="color: #339933;">&gt;</span> 
 <span style="color: #339933;">&lt;/</span>tr<span style="color: #339933;">&gt;</span>
&nbsp;
 <span style="color: #339933;">&lt;</span>c<span style="color: #339933;">:</span><span style="color: #000000; font-weight: bold;">forEach</span> items<span style="color: #339933;">=</span><span style="color: #0000ff;">&quot;${direcciones}&quot;</span> var<span style="color: #339933;">=</span><span style="color: #0000ff;">&quot;direccion&quot;</span><span style="color: #339933;">&gt;</span>
 <span style="color: #339933;">&lt;</span>tr<span style="color: #339933;">&gt;</span> 
 <span style="color: #339933;">&lt;</span>td <span style="color: #000000; font-weight: bold;">class</span><span style="color: #339933;">=</span><span style="color: #0000ff;">&quot;impar&quot;</span><span style="color: #339933;">&gt;</span> <span style="color: #339933;">&lt;</span>c<span style="color: #339933;">:</span>out value<span style="color: #339933;">=</span><span style="color: #0000ff;">&quot;${direccion.calle}&quot;</span><span style="color: #339933;">/&gt;</span> <span style="color: #339933;">&lt;/</span>td<span style="color: #339933;">&gt;</span>
 <span style="color: #339933;">&lt;</span>td <span style="color: #000000; font-weight: bold;">class</span><span style="color: #339933;">=</span><span style="color: #0000ff;">&quot;par&quot;</span><span style="color: #339933;">&gt;</span> <span style="color: #339933;">&lt;</span>c<span style="color: #339933;">:</span>out value<span style="color: #339933;">=</span><span style="color: #0000ff;">&quot;${direccion.localidad}&quot;</span><span style="color: #339933;">/&gt;</span> <span style="color: #339933;">&lt;/</span>td<span style="color: #339933;">&gt;</span>
 <span style="color: #339933;">&lt;/</span>tr<span style="color: #339933;">&gt;</span> 
 <span style="color: #339933;">&lt;/</span>c<span style="color: #339933;">:</span>forEach<span style="color: #339933;">&gt;</span>
&nbsp;
 <span style="color: #339933;">&lt;/</span>table<span style="color: #339933;">&gt;</span>
&nbsp;
 <span style="color: #339933;">&lt;</span>a href<span style="color: #339933;">=</span><span style="color: #0000ff;">&quot;&lt;c:url value=&quot;</span><span style="color: #339933;">/</span>ejercicios.<span style="color: #006633;">html</span><span style="color: #0000ff;">&quot;/&gt;&quot;</span><span style="color: #339933;">&gt;</span>Regreso a ejercicios<span style="color: #339933;">&lt;/</span>a<span style="color: #339933;">&gt;</span>
&nbsp;
 <span style="color: #339933;">&lt;/</span>div<span style="color: #339933;">&gt;</span>
&nbsp;
&nbsp;
&nbsp;
 <span style="color: #339933;">&lt;/</span>div<span style="color: #339933;">&gt;</span>
&nbsp;
&nbsp;
&nbsp;
&nbsp;
 <span style="color: #339933;">&lt;</span>div id<span style="color: #339933;">=</span><span style="color: #0000ff;">&quot;pie&quot;</span><span style="color: #339933;">&gt;</span>
   <span style="color: #339933;">&lt;</span>p<span style="color: #339933;">&gt;</span>www.<span style="color: #006633;">railsymas</span>.<span style="color: #006633;">com</span><span style="color: #339933;">&lt;/</span>p<span style="color: #339933;">&gt;</span>
 <span style="color: #339933;">&lt;/</span>div<span style="color: #339933;">&gt;</span>
 <span style="color: #339933;">&lt;/</span>div<span style="color: #339933;">&gt;</span>
&nbsp;
<span style="color: #339933;">&lt;/</span>body<span style="color: #339933;">&gt;</span>
<span style="color: #339933;">&lt;/</span>html<span style="color: #339933;">&gt;</span></pre></td></tr></table></div>

<p> Resultado </p>
<p><img src="http://www.railsymas.com/wp-content/uploads/2011/10/spdf4.png" alt="" title="spdf4" width="697" height="458" class="alignnone size-full wp-image-2518" /></p>
<p>Al igual que en el ejemplo de excel en este ejemplo para el desarrollo de spring mvc pdf e hibernate no es el objetivo un tutorial sobre la librería itext por ello para mayor entendimiento y más ejemplos se deriva a la siguiente dirección web para completar conocimientos</p>
<p><a href="http://www.roseindia.net/java/itext/index.shtml">Rose India</a></p>
<img src="http://feeds.feedburner.com/~r/railsymas/~4/_8ogEOBp71w" height="1" width="1"/>]]></content:encoded>
			<wfw:commentRss>http://www.railsymas.com/2011/10/31/exportando-los-datos-a-pdf-con-spring-framework/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Exportando datos a excel con spring framework</title>
		<link>http://www.railsymas.com/2011/10/26/exportando-datos-a-excel-con-spring-framework/</link>
		<comments>http://www.railsymas.com/2011/10/26/exportando-datos-a-excel-con-spring-framework/#comments</comments>
		<pubDate>Wed, 26 Oct 2011 15:27:15 +0000</pubDate>
		<dc:creator>admin</dc:creator>
				<category><![CDATA[spring]]></category>

		<guid isPermaLink="false">http://www.railsymas.com/?p=2460</guid>
		<description><![CDATA[Habíamos visto la inserción de datos mediante jdbcTemplate de spring y luego un ejemplo sobre hibernate en una relación de uno a uno En la primera imagen podemos observar un formulario para introducir los datos estará controlado por hibernate Código del formulario de introducción de datos del estudiante &#8220;formularioestudiante.jsp&#8221; 1 2 3 4 5 6 [...]]]></description>
			<content:encoded><![CDATA[<p>Habíamos visto la inserción de datos mediante jdbcTemplate de spring y luego un ejemplo sobre hibernate en una relación de uno a uno</p>
<p><span id="more-2460"></span></p>
<p> En la primera imagen podemos observar un formulario para introducir los datos estará controlado por hibernate</p>
<p> <img src="http://www.railsymas.com/wp-content/uploads/2011/10/hiberex1.png" alt="" title="hiberex1" width="612" height="376" class="alignnone size-full wp-image-2462" /></p>
<p>Código del formulario de introducción de datos del estudiante &#8220;formularioestudiante.jsp&#8221;</p>

<div class="wp_syntax"><table><tr><td class="line_numbers"><pre>1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
</pre></td><td class="code"><pre class="java" style="font-family:monospace;"><span style="color: #339933;">&lt;%</span>@ page language<span style="color: #339933;">=</span><span style="color: #0000ff;">&quot;java&quot;</span> contentType<span style="color: #339933;">=</span><span style="color: #0000ff;">&quot;text/html; charset=UTF-8&quot;</span>  pageEncoding<span style="color: #339933;">=</span><span style="color: #0000ff;">&quot;UTF-8&quot;</span><span style="color: #339933;">%&gt;</span>
<span style="color: #339933;">&lt;%</span>@taglib uri<span style="color: #339933;">=</span><span style="color: #0000ff;">&quot;http://www.springframework.org/tags&quot;</span> prefix<span style="color: #339933;">=</span><span style="color: #0000ff;">&quot;spring&quot;</span><span style="color: #339933;">%&gt;</span>
<span style="color: #339933;">&lt;%</span>@taglib uri<span style="color: #339933;">=</span><span style="color: #0000ff;">&quot;http://www.springframework.org/tags/form&quot;</span> prefix<span style="color: #339933;">=</span><span style="color: #0000ff;">&quot;form&quot;</span><span style="color: #339933;">%&gt;</span>
&nbsp;
<span style="color: #339933;">&lt;!</span>DOCTYPE html <span style="color: #000000; font-weight: bold;">PUBLIC</span> <span style="color: #0000ff;">&quot;-//W3C//DTD HTML 4.01 Transitional//EN&quot;</span> <span style="color: #0000ff;">&quot;http://www.w3.org/TR/html4/loose.dtd&quot;</span><span style="color: #339933;">&gt;</span>
<span style="color: #339933;">&lt;</span>html<span style="color: #339933;">&gt;</span>
<span style="color: #339933;">&lt;</span>head<span style="color: #339933;">&gt;</span>
<span style="color: #339933;">&lt;</span>meta http<span style="color: #339933;">-</span>equiv<span style="color: #339933;">=</span><span style="color: #0000ff;">&quot;Content-Type&quot;</span> content<span style="color: #339933;">=</span><span style="color: #0000ff;">&quot;text/html; charset=UTF-8&quot;</span><span style="color: #339933;">&gt;</span>
<span style="color: #339933;">&lt;</span>title<span style="color: #339933;">&gt;&lt;</span>spring<span style="color: #339933;">:</span>message code<span style="color: #339933;">=</span><span style="color: #0000ff;">&quot;unoauno.titulo&quot;</span><span style="color: #339933;">/&gt;&lt;/</span>title<span style="color: #339933;">&gt;</span>
<span style="color: #339933;">&lt;</span>link rel<span style="color: #339933;">=</span><span style="color: #0000ff;">&quot;stylesheet&quot;</span> type<span style="color: #339933;">=</span><span style="color: #0000ff;">&quot;text/css&quot;</span> href<span style="color: #339933;">=</span><span style="color: #0000ff;">&quot;css/estilo.css&quot;</span><span style="color: #339933;">/&gt;</span>
<span style="color: #339933;">&lt;/</span>head<span style="color: #339933;">&gt;</span>
<span style="color: #339933;">&lt;</span>body<span style="color: #339933;">&gt;</span>
 <span style="color: #339933;">&lt;</span>div id<span style="color: #339933;">=</span><span style="color: #0000ff;">&quot;contenedor&quot;</span> <span style="color: #339933;">&gt;</span>
&nbsp;
   <span style="color: #339933;">&lt;</span>h2<span style="color: #339933;">&gt;&lt;</span>spring<span style="color: #339933;">:</span>message code<span style="color: #339933;">=</span><span style="color: #0000ff;">&quot;unoauno.titulo&quot;</span><span style="color: #339933;">/&gt;&lt;/</span>h2<span style="color: #339933;">&gt;</span>
&nbsp;
   <span style="color: #339933;">&lt;</span>form<span style="color: #339933;">:</span>form action<span style="color: #339933;">=</span><span style="color: #0000ff;">&quot;formularioestudiante.html&quot;</span>  method<span style="color: #339933;">=</span><span style="color: #0000ff;">&quot;post&quot;</span> commandName<span style="color: #339933;">=</span><span style="color: #0000ff;">&quot;datosestudiante&quot;</span><span style="color: #339933;">&gt;</span> 
   <span style="color: #339933;">&lt;</span>div <span style="color: #000000; font-weight: bold;">class</span><span style="color: #339933;">=</span><span style="color: #0000ff;">&quot;campo&quot;</span><span style="color: #339933;">&gt;</span>
    <span style="color: #339933;">&lt;</span>spring<span style="color: #339933;">:</span>message code<span style="color: #339933;">=</span><span style="color: #0000ff;">&quot;unoauno.nombre&quot;</span><span style="color: #339933;">/&gt;</span>
    <span style="color: #339933;">&lt;</span>br<span style="color: #339933;">/&gt;</span>
    <span style="color: #339933;">&lt;</span>form<span style="color: #339933;">:</span>input path<span style="color: #339933;">=</span><span style="color: #0000ff;">&quot;nombre&quot;</span><span style="color: #339933;">/&gt;</span>
&nbsp;
   <span style="color: #339933;">&lt;/</span>div<span style="color: #339933;">&gt;</span>
&nbsp;
   <span style="color: #339933;">&lt;</span>div <span style="color: #000000; font-weight: bold;">class</span><span style="color: #339933;">=</span><span style="color: #0000ff;">&quot;campo&quot;</span><span style="color: #339933;">&gt;</span>
    <span style="color: #339933;">&lt;</span>spring<span style="color: #339933;">:</span>message code<span style="color: #339933;">=</span><span style="color: #0000ff;">&quot;unoauno.edad&quot;</span><span style="color: #339933;">/&gt;</span>
    <span style="color: #339933;">&lt;</span>br<span style="color: #339933;">/&gt;</span>
    <span style="color: #339933;">&lt;</span>form<span style="color: #339933;">:</span>input path<span style="color: #339933;">=</span><span style="color: #0000ff;">&quot;edad&quot;</span><span style="color: #339933;">/&gt;</span>
   <span style="color: #339933;">&lt;/</span>div<span style="color: #339933;">&gt;</span>
&nbsp;
   <span style="color: #339933;">&lt;</span>div <span style="color: #000000; font-weight: bold;">class</span><span style="color: #339933;">=</span><span style="color: #0000ff;">&quot;campo&quot;</span><span style="color: #339933;">&gt;</span>
    <span style="color: #339933;">&lt;</span>spring<span style="color: #339933;">:</span>message code<span style="color: #339933;">=</span><span style="color: #0000ff;">&quot;unoauno.calle&quot;</span><span style="color: #339933;">/&gt;</span>
    <span style="color: #339933;">&lt;</span>br<span style="color: #339933;">/&gt;</span>
    <span style="color: #339933;">&lt;</span>form<span style="color: #339933;">:</span>input path<span style="color: #339933;">=</span><span style="color: #0000ff;">&quot;calle&quot;</span><span style="color: #339933;">/&gt;</span> 
   <span style="color: #339933;">&lt;/</span>div<span style="color: #339933;">&gt;</span>
&nbsp;
   <span style="color: #339933;">&lt;</span>div <span style="color: #000000; font-weight: bold;">class</span><span style="color: #339933;">=</span><span style="color: #0000ff;">&quot;campo&quot;</span><span style="color: #339933;">&gt;</span>
    <span style="color: #339933;">&lt;</span>spring<span style="color: #339933;">:</span>message code<span style="color: #339933;">=</span><span style="color: #0000ff;">&quot;unoauno.localidad&quot;</span><span style="color: #339933;">/&gt;</span>
    <span style="color: #339933;">&lt;</span>br<span style="color: #339933;">/&gt;</span>
    <span style="color: #339933;">&lt;</span>form<span style="color: #339933;">:</span>input path<span style="color: #339933;">=</span><span style="color: #0000ff;">&quot;localidad&quot;</span><span style="color: #339933;">/&gt;</span>
   <span style="color: #339933;">&lt;/</span>div<span style="color: #339933;">&gt;</span>
&nbsp;
&nbsp;
   <span style="color: #339933;">&lt;</span>input type<span style="color: #339933;">=</span><span style="color: #0000ff;">&quot;hidden&quot;</span> name<span style="color: #339933;">=</span><span style="color: #0000ff;">&quot;method&quot;</span> value<span style="color: #339933;">=</span><span style="color: #0000ff;">&quot;introducirDatos&quot;</span><span style="color: #339933;">/&gt;</span>
&nbsp;
   <span style="color: #339933;">&lt;</span>input type<span style="color: #339933;">=</span><span style="color: #0000ff;">&quot;submit&quot;</span> value<span style="color: #339933;">=</span><span style="color: #0000ff;">&quot;enviar&quot;</span> <span style="color: #000000; font-weight: bold;">class</span><span style="color: #339933;">=</span><span style="color: #0000ff;">&quot;boton&quot;</span><span style="color: #339933;">/&gt;</span>
&nbsp;
&nbsp;
   <span style="color: #339933;">&lt;/</span>form<span style="color: #339933;">:</span>form<span style="color: #339933;">&gt;</span>
&nbsp;
   <span style="color: #339933;">&lt;</span>div id<span style="color: #339933;">=</span><span style="color: #0000ff;">&quot;pie&quot;</span><span style="color: #339933;">&gt;</span>
    <span style="color: #339933;">&lt;</span>p<span style="color: #339933;">&gt;</span>www.<span style="color: #006633;">railsymas</span>.<span style="color: #006633;">com</span><span style="color: #339933;">&lt;/</span>p<span style="color: #339933;">&gt;</span>
   <span style="color: #339933;">&lt;/</span>div<span style="color: #339933;">&gt;</span>
&nbsp;
 <span style="color: #339933;">&lt;/</span>div<span style="color: #339933;">&gt;</span>
<span style="color: #339933;">&lt;/</span>body<span style="color: #339933;">&gt;</span>
<span style="color: #339933;">&lt;/</span>html<span style="color: #339933;">&gt;</span></pre></td></tr></table></div>

<p>En el formulario llamamos al método introducirDatos</p>
<p>Mensajes utilizados en las vistas de los ficheros jsp dentro del fichero messages_es_xx.properties</p>

<div class="wp_syntax"><table><tr><td class="line_numbers"><pre>1
2
3
4
5
6
7
</pre></td><td class="code"><pre class="xml" style="font-family:monospace;">unoauno.titulo = formulario uno a uno spring hibernate
unoauno.nombre = Introduce tu nombre:
unoauno.edad =  Introduce tu edad:
unoauno.calle = Introduce la tu calle:
unoauno.localidad = Intoduce tu localidad:
&nbsp;
unoanuno.resultado = Listados estudiantes y direcciones</pre></td></tr></table></div>

<p>En la siguiente imagen se muestra al usuario seleccionando un icono para lanzar la acción<br />
de creación del fichero excel</p>
<p><img src="http://www.railsymas.com/wp-content/uploads/2011/10/hiberex2.png" alt="" title="hiberex2" width="612" height="301" class="alignnone size-full wp-image-2463" /></p>
<p>Códigio del formulario resultadoestudiante.jsp</p>

<div class="wp_syntax"><table><tr><td class="line_numbers"><pre>1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
</pre></td><td class="code"><pre class="java" style="font-family:monospace;"><span style="color: #339933;">&lt;%</span>@ page language<span style="color: #339933;">=</span><span style="color: #0000ff;">&quot;java&quot;</span> contentType<span style="color: #339933;">=</span><span style="color: #0000ff;">&quot;text/html; charset=UTF-8&quot;</span> 
    pageEncoding<span style="color: #339933;">=</span><span style="color: #0000ff;">&quot;UTF-8&quot;</span><span style="color: #339933;">%&gt;</span>
<span style="color: #339933;">&lt;%</span>@taglib uri<span style="color: #339933;">=</span><span style="color: #0000ff;">&quot;http://www.springframework.org/tags&quot;</span> prefix<span style="color: #339933;">=</span><span style="color: #0000ff;">&quot;spring&quot;</span> <span style="color: #339933;">%&gt;</span>
<span style="color: #339933;">&lt;%</span>@taglib uri<span style="color: #339933;">=</span><span style="color: #0000ff;">&quot;http://java.sun.com/jsp/jstl/core&quot;</span> prefix<span style="color: #339933;">=</span><span style="color: #0000ff;">&quot;c&quot;</span> <span style="color: #339933;">%&gt;</span>
<span style="color: #339933;">&lt;%</span>@taglib uri<span style="color: #339933;">=</span><span style="color: #0000ff;">&quot;http://www.springframework.org/tags/form&quot;</span> prefix<span style="color: #339933;">=</span><span style="color: #0000ff;">&quot;form&quot;</span> <span style="color: #339933;">%&gt;</span>
<span style="color: #339933;">&lt;!</span>DOCTYPE html <span style="color: #000000; font-weight: bold;">PUBLIC</span> <span style="color: #0000ff;">&quot;-//W3C//DTD HTML 4.01 Transitional//EN&quot;</span>
 <span style="color: #0000ff;">&quot;http://www.w3.org/TR/html4/loose.dtd&quot;</span><span style="color: #339933;">&gt;</span>
<span style="color: #339933;">&lt;</span>html<span style="color: #339933;">&gt;</span>
<span style="color: #339933;">&lt;</span>head<span style="color: #339933;">&gt;</span>
<span style="color: #339933;">&lt;</span>meta http<span style="color: #339933;">-</span>equiv<span style="color: #339933;">=</span><span style="color: #0000ff;">&quot;Content-Type&quot;</span> content<span style="color: #339933;">=</span><span style="color: #0000ff;">&quot;text/html; charset=UTF-8&quot;</span><span style="color: #339933;">&gt;</span>
<span style="color: #339933;">&lt;</span>link rel<span style="color: #339933;">=</span><span style="color: #0000ff;">&quot;stylesheet&quot;</span> href<span style="color: #339933;">=</span><span style="color: #0000ff;">&quot;css/estilo.css&quot;</span> type<span style="color: #339933;">=</span><span style="color: #0000ff;">&quot;text/css&quot;</span><span style="color: #339933;">/&gt;</span>
<span style="color: #339933;">&lt;</span>title<span style="color: #339933;">&gt;&lt;</span>spring<span style="color: #339933;">:</span>message code<span style="color: #339933;">=</span><span style="color: #0000ff;">&quot;unoanuno.resultado&quot;</span><span style="color: #339933;">/&gt;&lt;/</span>title<span style="color: #339933;">&gt;</span>
<span style="color: #339933;">&lt;/</span>head<span style="color: #339933;">&gt;</span>
<span style="color: #339933;">&lt;</span>body<span style="color: #339933;">&gt;</span>
&nbsp;
 <span style="color: #339933;">&lt;</span>div id<span style="color: #339933;">=</span><span style="color: #0000ff;">&quot;contenedor&quot;</span><span style="color: #339933;">&gt;</span>
&nbsp;
&nbsp;
&nbsp;
&nbsp;
 <span style="color: #339933;">&lt;</span>div id<span style="color: #339933;">=</span><span style="color: #0000ff;">&quot;enlaceexcel&quot;</span><span style="color: #339933;">&gt;</span>
  <span style="color: #339933;">&lt;</span>a href<span style="color: #339933;">=</span><span style="color: #0000ff;">&quot;&lt;c:url value=&quot;</span>formularioestudiante.<span style="color: #006633;">html</span><span style="color: #339933;">?</span>method<span style="color: #339933;">=</span>generarExcel<span style="color: #0000ff;">&quot;/&gt;&quot;</span><span style="color: #339933;">&gt;&lt;/</span>a<span style="color: #339933;">&gt;</span>
 <span style="color: #339933;">&lt;/</span>div<span style="color: #339933;">&gt;</span>
&nbsp;
&nbsp;
&nbsp;
 <span style="color: #339933;">&lt;</span>div id<span style="color: #339933;">=</span><span style="color: #0000ff;">&quot;borrar&quot;</span><span style="color: #339933;">&gt;</span>
   <span style="color: #339933;">&amp;</span>nbsp<span style="color: #339933;">;</span>
 <span style="color: #339933;">&lt;/</span>div<span style="color: #339933;">&gt;</span>
&nbsp;
 <span style="color: #339933;">&lt;</span>div <span style="color: #000000; font-weight: bold;">class</span><span style="color: #339933;">=</span><span style="color: #0000ff;">&quot;campo&quot;</span><span style="color: #339933;">&gt;</span>
&nbsp;
 <span style="color: #339933;">&lt;</span>c<span style="color: #339933;">:</span>out value<span style="color: #339933;">=</span><span style="color: #0000ff;">&quot;listado de  estudiantes&quot;</span><span style="color: #339933;">/&gt;</span>
&nbsp;
 <span style="color: #339933;">&lt;</span>br<span style="color: #339933;">/&gt;</span>
&nbsp;
 <span style="color: #339933;">&lt;</span>div <span style="color: #000000; font-weight: bold;">class</span><span style="color: #339933;">=</span><span style="color: #0000ff;">&quot;tabla&quot;</span><span style="color: #339933;">&gt;</span>
&nbsp;
 <span style="color: #339933;">&lt;</span>table title<span style="color: #339933;">=</span><span style="color: #0000ff;">&quot;listado de estudiantes&quot;</span><span style="color: #339933;">&gt;</span>
 <span style="color: #339933;">&lt;</span>tr<span style="color: #339933;">&gt;</span>
 <span style="color: #339933;">&lt;</span>th<span style="color: #339933;">&gt;</span>nombre<span style="color: #339933;">&lt;/</span>th<span style="color: #339933;">&gt;</span>
 <span style="color: #339933;">&lt;</span>th<span style="color: #339933;">&gt;</span>edad<span style="color: #339933;">&lt;/</span>th<span style="color: #339933;">&gt;</span> 
 <span style="color: #339933;">&lt;/</span>tr<span style="color: #339933;">&gt;</span>
 <span style="color: #339933;">&lt;</span>c<span style="color: #339933;">:</span><span style="color: #000000; font-weight: bold;">forEach</span> items<span style="color: #339933;">=</span><span style="color: #0000ff;">&quot;${estudiantes}&quot;</span> var<span style="color: #339933;">=</span><span style="color: #0000ff;">&quot;estudiante&quot;</span><span style="color: #339933;">&gt;</span>
&nbsp;
  <span style="color: #339933;">&lt;</span>tr<span style="color: #339933;">&gt;</span>
&nbsp;
  <span style="color: #339933;">&lt;</span>td <span style="color: #000000; font-weight: bold;">class</span><span style="color: #339933;">=</span><span style="color: #0000ff;">&quot;impar&quot;</span><span style="color: #339933;">&gt;</span>  <span style="color: #339933;">&lt;</span>c<span style="color: #339933;">:</span>out value<span style="color: #339933;">=</span><span style="color: #0000ff;">&quot;${estudiante.nombre}&quot;</span><span style="color: #339933;">/&gt;</span> <span style="color: #339933;">&lt;/</span>td<span style="color: #339933;">&gt;</span>
  <span style="color: #339933;">&lt;</span>td <span style="color: #000000; font-weight: bold;">class</span><span style="color: #339933;">=</span><span style="color: #0000ff;">&quot;par&quot;</span><span style="color: #339933;">&gt;</span>  <span style="color: #339933;">&lt;</span>c<span style="color: #339933;">:</span>out value<span style="color: #339933;">=</span><span style="color: #0000ff;">&quot;${estudiante.edad}&quot;</span><span style="color: #339933;">/&gt;</span> <span style="color: #339933;">&lt;/</span>td<span style="color: #339933;">&gt;</span>
  <span style="color: #339933;">&lt;/</span>tr<span style="color: #339933;">&gt;</span>
 <span style="color: #339933;">&lt;/</span>c<span style="color: #339933;">:</span>forEach<span style="color: #339933;">&gt;</span>
&nbsp;
 <span style="color: #339933;">&lt;/</span>table<span style="color: #339933;">&gt;</span>
 <span style="color: #339933;">&lt;/</span>div<span style="color: #339933;">&gt;</span>
&nbsp;
&nbsp;
 <span style="color: #339933;">&lt;/</span>div<span style="color: #339933;">&gt;</span>
&nbsp;
 <span style="color: #339933;">&lt;</span>div <span style="color: #000000; font-weight: bold;">class</span><span style="color: #339933;">=</span><span style="color: #0000ff;">&quot;campo&quot;</span><span style="color: #339933;">&gt;</span>
&nbsp;
 <span style="color: #339933;">&lt;</span>c<span style="color: #339933;">:</span>out value<span style="color: #339933;">=</span><span style="color: #0000ff;">&quot;listado de direcciones&quot;</span><span style="color: #339933;">/&gt;</span>
&nbsp;
 <span style="color: #339933;">&lt;</span>br<span style="color: #339933;">/&gt;</span>
&nbsp;
 <span style="color: #339933;">&lt;</span>div <span style="color: #000000; font-weight: bold;">class</span><span style="color: #339933;">=</span><span style="color: #0000ff;">&quot;tabla&quot;</span><span style="color: #339933;">&gt;</span>
&nbsp;
 <span style="color: #339933;">&lt;</span>table title<span style="color: #339933;">=</span><span style="color: #0000ff;">&quot;listado de direcciones&quot;</span><span style="color: #339933;">&gt;</span>
&nbsp;
 <span style="color: #339933;">&lt;</span>tr<span style="color: #339933;">&gt;</span>
 <span style="color: #339933;">&lt;</span>th<span style="color: #339933;">&gt;</span>calle<span style="color: #339933;">&lt;/</span>th<span style="color: #339933;">&gt;</span>
 <span style="color: #339933;">&lt;</span>th<span style="color: #339933;">&gt;</span>localidad<span style="color: #339933;">&lt;/</span>th<span style="color: #339933;">&gt;</span> 
 <span style="color: #339933;">&lt;/</span>tr<span style="color: #339933;">&gt;</span>
&nbsp;
 <span style="color: #339933;">&lt;</span>c<span style="color: #339933;">:</span><span style="color: #000000; font-weight: bold;">forEach</span> items<span style="color: #339933;">=</span><span style="color: #0000ff;">&quot;${direcciones}&quot;</span> var<span style="color: #339933;">=</span><span style="color: #0000ff;">&quot;direccion&quot;</span><span style="color: #339933;">&gt;</span>
 <span style="color: #339933;">&lt;</span>tr<span style="color: #339933;">&gt;</span> 
 <span style="color: #339933;">&lt;</span>td <span style="color: #000000; font-weight: bold;">class</span><span style="color: #339933;">=</span><span style="color: #0000ff;">&quot;impar&quot;</span><span style="color: #339933;">&gt;</span> <span style="color: #339933;">&lt;</span>c<span style="color: #339933;">:</span>out value<span style="color: #339933;">=</span><span style="color: #0000ff;">&quot;${direccion.calle}&quot;</span><span style="color: #339933;">/&gt;</span> <span style="color: #339933;">&lt;/</span>td<span style="color: #339933;">&gt;</span>
 <span style="color: #339933;">&lt;</span>td <span style="color: #000000; font-weight: bold;">class</span><span style="color: #339933;">=</span><span style="color: #0000ff;">&quot;par&quot;</span><span style="color: #339933;">&gt;</span> <span style="color: #339933;">&lt;</span>c<span style="color: #339933;">:</span>out value<span style="color: #339933;">=</span><span style="color: #0000ff;">&quot;${direccion.localidad}&quot;</span><span style="color: #339933;">/&gt;</span> <span style="color: #339933;">&lt;/</span>td<span style="color: #339933;">&gt;</span>
 <span style="color: #339933;">&lt;/</span>tr<span style="color: #339933;">&gt;</span> 
 <span style="color: #339933;">&lt;/</span>c<span style="color: #339933;">:</span>forEach<span style="color: #339933;">&gt;</span>
&nbsp;
 <span style="color: #339933;">&lt;/</span>table<span style="color: #339933;">&gt;</span>
&nbsp;
 <span style="color: #339933;">&lt;</span>a href<span style="color: #339933;">=</span><span style="color: #0000ff;">&quot;&lt;c:url value=&quot;</span><span style="color: #339933;">/</span>ejercicios.<span style="color: #006633;">html</span><span style="color: #0000ff;">&quot;/&gt;&quot;</span><span style="color: #339933;">&gt;</span>Regreso a ejercicios<span style="color: #339933;">&lt;/</span>a<span style="color: #339933;">&gt;</span>
&nbsp;
 <span style="color: #339933;">&lt;/</span>div<span style="color: #339933;">&gt;</span>
&nbsp;
&nbsp;
&nbsp;
 <span style="color: #339933;">&lt;/</span>div<span style="color: #339933;">&gt;</span>
&nbsp;
&nbsp;
&nbsp;
&nbsp;
 <span style="color: #339933;">&lt;</span>div id<span style="color: #339933;">=</span><span style="color: #0000ff;">&quot;pie&quot;</span><span style="color: #339933;">&gt;</span>
   <span style="color: #339933;">&lt;</span>p<span style="color: #339933;">&gt;</span>www.<span style="color: #006633;">railsymas</span>.<span style="color: #006633;">com</span><span style="color: #339933;">&lt;/</span>p<span style="color: #339933;">&gt;</span>
 <span style="color: #339933;">&lt;/</span>div<span style="color: #339933;">&gt;</span>
 <span style="color: #339933;">&lt;/</span>div<span style="color: #339933;">&gt;</span>
&nbsp;
<span style="color: #339933;">&lt;/</span>body<span style="color: #339933;">&gt;</span>
<span style="color: #339933;">&lt;/</span>html<span style="color: #339933;">&gt;</span></pre></td></tr></table></div>

<p>En la siguiente imagen se muestra la pantalla contextual de creación del fichero excel estudiante para guardar o visualizar</p>
<p><img src="http://www.railsymas.com/wp-content/uploads/2011/10/hiberex3.png" alt="" title="hiberex3" width="658" height="368" class="alignnone size-full wp-image-2464" /></p>
<p>Una vez abierto el fichero excel se visualizan los datos cargados</p>
<p><img src="http://www.railsymas.com/wp-content/uploads/2011/10/hiberex4.png" alt="" title="hiberex4" width="529" height="234" class="alignnone size-full wp-image-2465" /></p>
<p>Basándonos en el ejemplo  <a href="http://www.railsymas.com/2011/07/25/spring-framework-mvc-hibernate-uno-a-uno/">hibernate uno a uno </a></p>
<p>Una vez arrancado nuestro proyecto en la realización del ejemplo en el navegador tendríamos<br />
urlproyecto\formularioestudiante.html?method=introducirEstudiante</p>
<p>El bean encargado de recoger la acción declarado en el fichero de configuración dispatcher-servlet.xml</p>

<div class="wp_syntax"><table><tr><td class="line_numbers"><pre>1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
</pre></td><td class="code"><pre class="xml" style="font-family:monospace;">&nbsp;
 <span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;bean</span> <span style="color: #000066;">id</span>=<span style="color: #ff0000;">&quot;template&quot;</span> <span style="color: #000066;">class</span>=<span style="color: #ff0000;">&quot;org.springframework.orm.hibernate3.HibernateTemplate&quot;</span><span style="color: #000000; font-weight: bold;">&gt;</span></span>
      <span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;property</span> <span style="color: #000066;">name</span>=<span style="color: #ff0000;">&quot;sessionFactory&quot;</span> <span style="color: #000066;">ref</span>=<span style="color: #ff0000;">&quot;conexionFactoria&quot;</span><span style="color: #000000; font-weight: bold;">/&gt;</span></span>
    <span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;/bean<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>
&nbsp;
 <span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;bean</span> <span style="color: #000066;">id</span>=<span style="color: #ff0000;">&quot;estudianteDao&quot;</span> <span style="color: #000066;">class</span>=<span style="color: #ff0000;">&quot;recursos.UnoaunoImpl&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;property</span> <span style="color: #000066;">name</span>=<span style="color: #ff0000;">&quot;hibernateTemplate&quot;</span> <span style="color: #000066;">ref</span>=<span style="color: #ff0000;">&quot;template&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;/bean<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>
&nbsp;
&nbsp;
&nbsp;
    <span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;bean</span> <span style="color: #000066;">name</span>=<span style="color: #ff0000;">&quot;/formularioestudiante.html&quot;</span> <span style="color: #000066;">class</span>=<span style="color: #ff0000;">&quot;controlador.ControladorEstudiante&quot;</span><span style="color: #000000; font-weight: bold;">&gt;</span></span>
      <span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;property</span> <span style="color: #000066;">name</span>=<span style="color: #ff0000;">&quot;methodNameResolver&quot;</span> <span style="color: #000066;">ref</span>=<span style="color: #ff0000;">&quot;paramResolver&quot;</span><span style="color: #000000; font-weight: bold;">/&gt;</span></span>
      <span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;property</span> <span style="color: #000066;">name</span>=<span style="color: #ff0000;">&quot;estudianteDao&quot;</span> <span style="color: #000066;">ref</span>=<span style="color: #ff0000;">&quot;estudianteDao&quot;</span><span style="color: #000000; font-weight: bold;">/&gt;</span></span>
    <span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;/bean<span style="color: #000000; font-weight: bold;">&gt;</span></span></span></pre></td></tr></table></div>

<p>La propiedad estudianteDao nos permite trabajar con una sesión factoria, el controlador estudiante recibe la petición para ser tratada.</p>
<p>Código controlador estudiante</p>

<div class="wp_syntax"><table><tr><td class="line_numbers"><pre>1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
</pre></td><td class="code"><pre class="java" style="font-family:monospace;"><span style="color: #000000; font-weight: bold;">package</span> <span style="color: #006699;">controlador</span><span style="color: #339933;">;</span>
&nbsp;
<span style="color: #000000; font-weight: bold;">import</span> <span style="color: #006699;">org.springframework.web.servlet.ModelAndView</span><span style="color: #339933;">;</span>
&nbsp;
<span style="color: #000000; font-weight: bold;">import</span> <span style="color: #006699;">org.springframework.web.servlet.mvc.multiaction.MultiActionController</span><span style="color: #339933;">;</span>
&nbsp;
<span style="color: #000000; font-weight: bold;">import</span> <span style="color: #006699;">javax.servlet.http.HttpServletRequest</span><span style="color: #339933;">;</span>
<span style="color: #000000; font-weight: bold;">import</span> <span style="color: #006699;">javax.servlet.http.HttpServletResponse</span><span style="color: #339933;">;</span>
&nbsp;
<span style="color: #000000; font-weight: bold;">import</span> <span style="color: #006699;">ClasesBean.DatosEstudiante</span><span style="color: #339933;">;</span>
<span style="color: #000000; font-weight: bold;">import</span> <span style="color: #006699;">modelos.Direccion</span><span style="color: #339933;">;</span>
<span style="color: #000000; font-weight: bold;">import</span> <span style="color: #006699;">modelos.Estudiante</span><span style="color: #339933;">;</span>
<span style="color: #000000; font-weight: bold;">import</span> <span style="color: #006699;">recursos.Unoauno</span><span style="color: #339933;">;</span>
<span style="color: #000000; font-weight: bold;">import</span> <span style="color: #006699;">org.springframework.ui.ModelMap</span><span style="color: #339933;">;</span>
<span style="color: #000000; font-weight: bold;">import</span> <span style="color: #006699;">java.util.Map</span><span style="color: #339933;">;</span>
<span style="color: #000000; font-weight: bold;">import</span> <span style="color: #006699;">java.util.List</span><span style="color: #339933;">;</span>
<span style="color: #000000; font-weight: bold;">import</span> <span style="color: #006699;">java.util.HashMap</span><span style="color: #339933;">;</span>
&nbsp;
<span style="color: #000000; font-weight: bold;">import</span> <span style="color: #006699;">recursos.GenerarExcel</span><span style="color: #339933;">;</span>
&nbsp;
<span style="color: #000000; font-weight: bold;">public</span> <span style="color: #000000; font-weight: bold;">class</span> ControladorEstudiante <span style="color: #000000; font-weight: bold;">extends</span> MultiActionController 
<span style="color: #009900;">&#123;</span>
&nbsp;
	<span style="color: #000000; font-weight: bold;">private</span> Unoauno estudianteDao<span style="color: #339933;">;</span>
&nbsp;
&nbsp;
	<span style="color: #000000; font-weight: bold;">public</span> Unoauno getEstudianteDao<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> estudianteDao<span style="color: #339933;">;</span>
	<span style="color: #009900;">&#125;</span>
&nbsp;
&nbsp;
	<span style="color: #000000; font-weight: bold;">public</span> <span style="color: #000066; font-weight: bold;">void</span> setEstudianteDao<span style="color: #009900;">&#40;</span>Unoauno estudianteDao<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;">estudianteDao</span> <span style="color: #339933;">=</span> estudianteDao<span style="color: #339933;">;</span>
	<span style="color: #009900;">&#125;</span>
&nbsp;
    <span style="color: #000000; font-weight: bold;">public</span> ModelAndView introducirDatos <span style="color: #009900;">&#40;</span>HttpServletRequest request, HttpServletResponse response, DatosEstudiante datosestudiante<span style="color: #009900;">&#41;</span> <span style="color: #000000; font-weight: bold;">throws</span> <span style="color: #003399;">Exception</span>
    <span style="color: #009900;">&#123;</span>
&nbsp;
&nbsp;
    	Direccion direccion <span style="color: #339933;">=</span> <span style="color: #000000; font-weight: bold;">new</span> Direccion<span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
    	Estudiante estudiante <span style="color: #339933;">=</span> <span style="color: #000000; font-weight: bold;">new</span> Estudiante<span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
&nbsp;
    	direccion.<span style="color: #006633;">setCalle</span><span style="color: #009900;">&#40;</span>datosestudiante.<span style="color: #006633;">getCalle</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
    	direccion.<span style="color: #006633;">setLocalidad</span><span style="color: #009900;">&#40;</span>datosestudiante.<span style="color: #006633;">getLocalidad</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
    	estudiante.<span style="color: #006633;">setNombre</span><span style="color: #009900;">&#40;</span>datosestudiante.<span style="color: #006633;">getNombre</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
    	estudiante.<span style="color: #006633;">setEdad</span><span style="color: #009900;">&#40;</span>datosestudiante.<span style="color: #006633;">getEdad</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
    	estudiante.<span style="color: #006633;">setEstudiantedireccion</span><span style="color: #009900;">&#40;</span>direccion<span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
&nbsp;
    	estudianteDao.<span style="color: #006633;">introducirEstudiante</span><span style="color: #009900;">&#40;</span>estudiante<span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
&nbsp;
&nbsp;
&nbsp;
    	ModelMap mapa <span style="color: #339933;">=</span> <span style="color: #000000; font-weight: bold;">new</span> ModelMap<span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
&nbsp;
    	mapa.<span style="color: #006633;">addAttribute</span><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">&quot;estudiantes&quot;</span>,estudianteDao.<span style="color: #006633;">listadoEstudiantes</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
&nbsp;
    	mapa.<span style="color: #006633;">addAttribute</span><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">&quot;direcciones&quot;</span>,estudianteDao.<span style="color: #006633;">listadoDireccion</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
&nbsp;
    	ModelAndView vista <span style="color: #339933;">=</span> <span style="color: #000000; font-weight: bold;">new</span> ModelAndView<span style="color: #009900;">&#40;</span><span style="color: #0000ff;">&quot;resultadoestudiante&quot;</span>,mapa<span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
&nbsp;
    	<span style="color: #000000; font-weight: bold;">return</span> vista<span style="color: #339933;">;</span>
    <span style="color: #009900;">&#125;</span>
&nbsp;
&nbsp;
&nbsp;
&nbsp;
    <span style="color: #000000; font-weight: bold;">public</span> <span style="color: #000066; font-weight: bold;">void</span> generarExcel <span style="color: #009900;">&#40;</span>HttpServletRequest request, HttpServletResponse response <span style="color: #009900;">&#41;</span> <span style="color: #000000; font-weight: bold;">throws</span> <span style="color: #003399;">Exception</span>
    <span style="color: #009900;">&#123;</span>
    	List<span style="color: #339933;">&lt;</span>Estudiante<span style="color: #339933;">&gt;</span> estudiantes <span style="color: #339933;">=</span> estudianteDao.<span style="color: #006633;">listadoEstudiantes</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
    	List<span style="color: #339933;">&lt;</span>Direccion<span style="color: #339933;">&gt;</span> direcciones <span style="color: #339933;">=</span> estudianteDao.<span style="color: #006633;">listadoDireccion</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
&nbsp;
    	<span style="color: #003399;">Map</span> modelmap <span style="color: #339933;">=</span> <span style="color: #000000; font-weight: bold;">new</span> <span style="color: #003399;">HashMap</span> <span style="color: #339933;">&lt;</span>String,List<span style="color: #339933;">&gt;</span> <span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
&nbsp;
    	modelmap.<span style="color: #006633;">put</span><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">&quot;estudiantes&quot;</span>, estudiantes<span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
    	modelmap.<span style="color: #006633;">put</span><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">&quot;direcciones&quot;</span>,direcciones<span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
&nbsp;
    	GenerarExcel excel <span style="color: #339933;">=</span> <span style="color: #000000; font-weight: bold;">new</span> GenerarExcel<span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
&nbsp;
    	excel.<span style="color: #006633;">llamandoBuildExcelDocument</span><span style="color: #009900;">&#40;</span>request, response, modelmap<span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
&nbsp;
&nbsp;
    	<span style="color: #003399;">System</span>.<span style="color: #006633;">out</span>.<span style="color: #006633;">println</span><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">&quot;generar excel&quot;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
&nbsp;
&nbsp;
&nbsp;
    <span style="color: #009900;">&#125;</span>
&nbsp;
&nbsp;
	<span style="color: #000000; font-weight: bold;">public</span> ModelAndView introducirEstudiante <span style="color: #009900;">&#40;</span>HttpServletRequest request, HttpServletResponse response, DatosEstudiante datosestudiante<span style="color: #009900;">&#41;</span> <span style="color: #000000; font-weight: bold;">throws</span> <span style="color: #003399;">Exception</span>
	<span style="color: #009900;">&#123;</span>
	  	<span style="color: #000000; font-weight: bold;">return</span> <span style="color: #000000; font-weight: bold;">new</span> ModelAndView<span style="color: #009900;">&#40;</span><span style="color: #0000ff;">&quot;formularioestudiante&quot;</span>,<span style="color: #0000ff;">&quot;datosestudiante&quot;</span>,datosestudiante<span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
	<span style="color: #009900;">&#125;</span>
&nbsp;
&nbsp;
&nbsp;
&nbsp;
&nbsp;
<span style="color: #009900;">&#125;</span></pre></td></tr></table></div>

<p>La clase controlador estudiante extiende de multiactionController que ya habíamos visto su funcionamiento en un post anterior</p>
<p><a href="http://www.railsymas.com/2011/03/24/formulario-multiactioncontroller-spring-framework/">ejemplo de multiactionController</a></p>
<p>una vez que introducimos los datos en el sistema de bases de datos mediante hibernate mostramos la vista resultadoestudiante.jsp</p>
<p>Dentro del package recursos tenemos la clase encargada de generar el fichero excel</p>

<div class="wp_syntax"><table><tr><td class="line_numbers"><pre>1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
</pre></td><td class="code"><pre class="java" style="font-family:monospace;"><span style="color: #000000; font-weight: bold;">package</span> <span style="color: #006699;">recursos</span><span style="color: #339933;">;</span>
&nbsp;
&nbsp;
&nbsp;
<span style="color: #000000; font-weight: bold;">import</span> <span style="color: #006699;">java.util.Iterator</span><span style="color: #339933;">;</span>
<span style="color: #000000; font-weight: bold;">import</span> <span style="color: #006699;">java.util.Map</span><span style="color: #339933;">;</span>
<span style="color: #000000; font-weight: bold;">import</span> <span style="color: #006699;">java.util.List</span><span style="color: #339933;">;</span>
&nbsp;
<span style="color: #000000; font-weight: bold;">import</span> <span style="color: #006699;">javax.servlet.ServletOutputStream</span><span style="color: #339933;">;</span>
<span style="color: #000000; font-weight: bold;">import</span> <span style="color: #006699;">javax.servlet.http.HttpServletRequest</span><span style="color: #339933;">;</span>
<span style="color: #000000; font-weight: bold;">import</span> <span style="color: #006699;">javax.servlet.http.HttpServletResponse</span><span style="color: #339933;">;</span>
&nbsp;
<span style="color: #000000; font-weight: bold;">import</span> <span style="color: #006699;">org.apache.poi.hssf.usermodel.HSSFWorkbook</span><span style="color: #339933;">;</span>
<span style="color: #000000; font-weight: bold;">import</span> <span style="color: #006699;">org.apache.poi.hssf.usermodel.HSSFSheet</span><span style="color: #339933;">;</span>
<span style="color: #000000; font-weight: bold;">import</span> <span style="color: #006699;">org.apache.poi.hssf.usermodel.HSSFCellStyle</span><span style="color: #339933;">;</span>
<span style="color: #000000; font-weight: bold;">import</span> <span style="color: #006699;">org.apache.poi.hssf.usermodel.HSSFRow</span><span style="color: #339933;">;</span>
&nbsp;
&nbsp;
&nbsp;
<span style="color: #000000; font-weight: bold;">import</span> <span style="color: #006699;">modelos.Estudiante</span><span style="color: #339933;">;</span>
<span style="color: #000000; font-weight: bold;">import</span> <span style="color: #006699;">modelos.Direccion</span><span style="color: #339933;">;</span>
&nbsp;
&nbsp;
<span style="color: #000000; font-weight: bold;">import</span> <span style="color: #006699;">org.springframework.web.servlet.view.document.AbstractExcelView</span><span style="color: #339933;">;</span>
&nbsp;
<span style="color: #000000; font-weight: bold;">import</span> <span style="color: #006699;">java.io.ByteArrayOutputStream</span><span style="color: #339933;">;</span>
&nbsp;
&nbsp;
<span style="color: #000000; font-weight: bold;">public</span> <span style="color: #000000; font-weight: bold;">class</span> GenerarExcel  <span style="color: #000000; font-weight: bold;">extends</span> AbstractExcelView
<span style="color: #009900;">&#123;</span>   
&nbsp;
&nbsp;
	<span style="color: #000000; font-weight: bold;">private</span> <span style="color: #003399;">ByteArrayOutputStream</span> fichero <span style="color: #339933;">=</span> <span style="color: #000000; font-weight: bold;">new</span> <span style="color: #003399;">ByteArrayOutputStream</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
    <span style="color: #000000; font-weight: bold;">private</span> <span style="color: #000066; font-weight: bold;">int</span> numerofilas<span style="color: #339933;">;</span> 
&nbsp;
	@SuppressWarnings<span style="color: #009900;">&#40;</span><span style="color: #0000ff;">&quot;deprecation&quot;</span><span style="color: #009900;">&#41;</span>
	@Override
	<span style="color: #000000; font-weight: bold;">protected</span> <span style="color: #000066; font-weight: bold;">void</span> buildExcelDocument<span style="color: #009900;">&#40;</span><span style="color: #003399;">Map</span> model, HSSFWorkbook libro ,
			HttpServletRequest request, HttpServletResponse response<span style="color: #009900;">&#41;</span> <span style="color: #000000; font-weight: bold;">throws</span> <span style="color: #003399;">Exception</span> 
    <span style="color: #009900;">&#123;</span>
		<span style="color: #666666; font-style: italic;">// TODO Auto-generated method stub</span>
&nbsp;
		<span style="color: #003399;">List</span> <span style="color: #339933;">&lt;</span>Estudiante<span style="color: #339933;">&gt;</span> estudiantes <span style="color: #339933;">=</span> <span style="color: #009900;">&#40;</span><span style="color: #003399;">List</span><span style="color: #009900;">&#41;</span> model.<span style="color: #006633;">get</span><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">&quot;estudiantes&quot;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
		<span style="color: #003399;">List</span> <span style="color: #339933;">&lt;</span>Direccion<span style="color: #339933;">&gt;</span> direcciones <span style="color: #339933;">=</span> <span style="color: #009900;">&#40;</span><span style="color: #003399;">List</span><span style="color: #009900;">&#41;</span> model.<span style="color: #006633;">get</span><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">&quot;direcciones&quot;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
&nbsp;
		HSSFCellStyle estilo <span style="color: #339933;">=</span> libro.<span style="color: #006633;">createCellStyle</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
&nbsp;
&nbsp;
		<span style="color: #666666; font-style: italic;">//creación de una hoja</span>
		HSSFSheet hoja <span style="color: #339933;">=</span> libro.<span style="color: #006633;">createSheet</span><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">&quot;libro estudiantes&quot;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
&nbsp;
&nbsp;
&nbsp;
		<span style="color: #666666; font-style: italic;">//creamos la fila cabecera</span>
		HSSFRow fila0 <span style="color: #339933;">=</span>  hoja.<span style="color: #006633;">createRow</span><span style="color: #009900;">&#40;</span><span style="color: #cc66cc;">0</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
&nbsp;
&nbsp;
		fila0.<span style="color: #006633;">createCell</span><span style="color: #009900;">&#40;</span><span style="color: #cc66cc;">0</span><span style="color: #009900;">&#41;</span>.<span style="color: #006633;">setCellValue</span><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">&quot;nombre&quot;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
		fila0.<span style="color: #006633;">createCell</span><span style="color: #009900;">&#40;</span><span style="color: #cc66cc;">1</span><span style="color: #009900;">&#41;</span>.<span style="color: #006633;">setCellValue</span><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">&quot;edad&quot;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
&nbsp;
		<span style="color: #000000; font-weight: bold;">this</span>.<span style="color: #006633;">numerofilas</span> <span style="color: #339933;">=</span> <span style="color: #cc66cc;">1</span><span style="color: #339933;">;</span>
&nbsp;
&nbsp;
		<span style="color: #000000; font-weight: bold;">for</span> <span style="color: #009900;">&#40;</span><span style="color: #003399;">Iterator</span> iterador <span style="color: #339933;">=</span> estudiantes.<span style="color: #006633;">iterator</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span> iterador.<span style="color: #006633;">hasNext</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span><span style="color: #009900;">&#41;</span>
		<span style="color: #009900;">&#123;</span>
			Estudiante estudiante <span style="color: #339933;">=</span> <span style="color: #009900;">&#40;</span>Estudiante<span style="color: #009900;">&#41;</span> iterador.<span style="color: #006633;">next</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
&nbsp;
			HSSFRow fila <span style="color: #339933;">=</span> hoja.<span style="color: #006633;">createRow</span><span style="color: #009900;">&#40;</span><span style="color: #000000; font-weight: bold;">this</span>.<span style="color: #006633;">numerofilas</span> <span style="color: #339933;">++</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
&nbsp;
			fila.<span style="color: #006633;">createCell</span><span style="color: #009900;">&#40;</span><span style="color: #cc66cc;">0</span><span style="color: #009900;">&#41;</span>.<span style="color: #006633;">setCellValue</span><span style="color: #009900;">&#40;</span>estudiante.<span style="color: #006633;">getNombre</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
			fila.<span style="color: #006633;">createCell</span><span style="color: #009900;">&#40;</span><span style="color: #cc66cc;">1</span><span style="color: #009900;">&#41;</span>.<span style="color: #006633;">setCellValue</span><span style="color: #009900;">&#40;</span>estudiante.<span style="color: #006633;">getEdad</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
		<span style="color: #009900;">&#125;</span>
&nbsp;
&nbsp;
		<span style="color: #000000; font-weight: bold;">try</span>
		<span style="color: #009900;">&#123;</span>
&nbsp;
&nbsp;
		   libro.<span style="color: #006633;">write</span><span style="color: #009900;">&#40;</span>fichero<span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
&nbsp;
		   fichero.<span style="color: #006633;">close</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
&nbsp;
&nbsp;
		   response.<span style="color: #006633;">setContentType</span><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">&quot;application/vnd.ms-excel&quot;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
&nbsp;
		    response.<span style="color: #006633;">setContentLength</span><span style="color: #009900;">&#40;</span><span style="color: #000000; font-weight: bold;">this</span>.<span style="color: #006633;">fichero</span>.<span style="color: #006633;">size</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
&nbsp;
		    response.<span style="color: #006633;">setHeader</span><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">&quot;Content-disposition&quot;</span>,<span style="color: #0000ff;">&quot;attachment; filename=estudiantes.xls&quot;</span> <span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
&nbsp;
		    ServletOutputStream out <span style="color: #339933;">=</span> response.<span style="color: #006633;">getOutputStream</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
&nbsp;
		    <span style="color: #000000; font-weight: bold;">this</span>.<span style="color: #006633;">fichero</span>.<span style="color: #006633;">writeTo</span><span style="color: #009900;">&#40;</span>out<span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
&nbsp;
		    out.<span style="color: #006633;">flush</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
&nbsp;
		<span style="color: #009900;">&#125;</span>
		<span style="color: #000000; font-weight: bold;">catch</span> <span style="color: #009900;">&#40;</span><span style="color: #003399;">Exception</span> e<span style="color: #009900;">&#41;</span> 
		<span style="color: #009900;">&#123;</span>  
			<span style="color: #003399;">System</span>.<span style="color: #006633;">out</span>.<span style="color: #006633;">print</span><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">&quot;error&quot;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
&nbsp;
		<span style="color: #009900;">&#125;</span>
&nbsp;
&nbsp;
&nbsp;
&nbsp;
	<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> llamandoBuildExcelDocument <span style="color: #009900;">&#40;</span> HttpServletRequest request, HttpServletResponse response, <span style="color: #003399;">Map</span> model<span style="color: #009900;">&#41;</span> <span style="color: #000000; font-weight: bold;">throws</span> <span style="color: #003399;">Exception</span>
	<span style="color: #009900;">&#123;</span>   
&nbsp;
		<span style="color: #666666; font-style: italic;">//creamos el libro</span>
		HSSFWorkbook libro <span style="color: #339933;">=</span> <span style="color: #000000; font-weight: bold;">new</span> HSSFWorkbook <span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>	
&nbsp;
&nbsp;
&nbsp;
&nbsp;
&nbsp;
		buildExcelDocument<span style="color: #009900;">&#40;</span>model,libro,request, response<span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
&nbsp;
	<span style="color: #009900;">&#125;</span>
&nbsp;
&nbsp;
&nbsp;
&nbsp;
<span style="color: #009900;">&#125;</span></pre></td></tr></table></div>

<p>Clase dentro del package de recursos unoauno.java</p>

<div class="wp_syntax"><table><tr><td class="line_numbers"><pre>1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
</pre></td><td class="code"><pre class="java" style="font-family:monospace;"><span style="color: #000000; font-weight: bold;">package</span> <span style="color: #006699;">recursos</span><span style="color: #339933;">;</span>
&nbsp;
&nbsp;
<span style="color: #000000; font-weight: bold;">import</span> <span style="color: #006699;">java.util.List</span><span style="color: #339933;">;</span>
<span style="color: #000000; font-weight: bold;">import</span> <span style="color: #006699;">modelos.Direccion</span><span style="color: #339933;">;</span>
<span style="color: #000000; font-weight: bold;">import</span> <span style="color: #006699;">modelos.Estudiante</span><span style="color: #339933;">;</span>
&nbsp;
<span style="color: #000000; font-weight: bold;">public</span> <span style="color: #000000; font-weight: bold;">interface</span> Unoauno <span style="color: #009900;">&#123;</span>
&nbsp;
	<span style="color: #000000; font-weight: bold;">public</span> <span style="color: #000066; font-weight: bold;">void</span> introducirEstudiante<span style="color: #009900;">&#40;</span>Estudiante estudiante<span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
&nbsp;
	<span style="color: #000000; font-weight: bold;">public</span> List<span style="color: #339933;">&lt;</span>Estudiante<span style="color: #339933;">&gt;</span> listadoEstudiantes <span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
	<span style="color: #000000; font-weight: bold;">public</span> List<span style="color: #339933;">&lt;</span>Direccion<span style="color: #339933;">&gt;</span> listadoDireccion<span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
&nbsp;
<span style="color: #009900;">&#125;</span></pre></td></tr></table></div>

<p>Clase encargada de la implementación de la interface Unoauno</p>

<div class="wp_syntax"><table><tr><td class="line_numbers"><pre>1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
</pre></td><td class="code"><pre class="java" style="font-family:monospace;"><span style="color: #000000; font-weight: bold;">package</span> <span style="color: #006699;">recursos</span><span style="color: #339933;">;</span>
&nbsp;
<span style="color: #000000; font-weight: bold;">import</span> <span style="color: #006699;">modelos.Direccion</span><span style="color: #339933;">;</span>
<span style="color: #000000; font-weight: bold;">import</span> <span style="color: #006699;">modelos.Estudiante</span><span style="color: #339933;">;</span>
<span style="color: #000000; font-weight: bold;">import</span> <span style="color: #006699;">java.util.List</span><span style="color: #339933;">;</span>
<span style="color: #000000; font-weight: bold;">import</span> <span style="color: #006699;">org.springframework.orm.hibernate3.HibernateTemplate</span><span style="color: #339933;">;</span>
&nbsp;
&nbsp;
<span style="color: #000000; font-weight: bold;">public</span> <span style="color: #000000; font-weight: bold;">class</span> UnoaunoImpl <span style="color: #000000; font-weight: bold;">implements</span> Unoauno
<span style="color: #009900;">&#123;</span>
	<span style="color: #000000; font-weight: bold;">private</span> HibernateTemplate hibernateTemplate<span style="color: #339933;">;</span>
&nbsp;
	<span style="color: #000000; font-weight: bold;">public</span> HibernateTemplate getHibernateTemplate<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> hibernateTemplate<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> setHibernateTemplate<span style="color: #009900;">&#40;</span>HibernateTemplate hibernateTemplate<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;">hibernateTemplate</span> <span style="color: #339933;">=</span> hibernateTemplate<span style="color: #339933;">;</span>
	<span style="color: #009900;">&#125;</span>
	@SuppressWarnings<span style="color: #009900;">&#40;</span><span style="color: #0000ff;">&quot;unchecked&quot;</span><span style="color: #009900;">&#41;</span>
	<span style="color: #000000; font-weight: bold;">public</span> <span style="color: #003399;">List</span> <span style="color: #339933;">&lt;</span>Estudiante<span style="color: #339933;">&gt;</span> listadoEstudiantes<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> <span style="color: #009900;">&#40;</span>List<span style="color: #339933;">&lt;</span>Estudiante<span style="color: #339933;">&gt;</span><span style="color: #009900;">&#41;</span> hibernateTemplate.<span style="color: #006633;">find</span><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">&quot;from Estudiante&quot;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
	<span style="color: #009900;">&#125;</span>
&nbsp;
	@SuppressWarnings<span style="color: #009900;">&#40;</span><span style="color: #0000ff;">&quot;unchecked&quot;</span><span style="color: #009900;">&#41;</span>
	<span style="color: #000000; font-weight: bold;">public</span> <span style="color: #003399;">List</span> <span style="color: #339933;">&lt;</span>Direccion<span style="color: #339933;">&gt;</span> listadoDireccion<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> <span style="color: #009900;">&#40;</span>List<span style="color: #339933;">&lt;</span>Direccion<span style="color: #339933;">&gt;</span><span style="color: #009900;">&#41;</span> hibernateTemplate.<span style="color: #006633;">find</span><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">&quot;from Direccion&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> <span style="color: #000066; font-weight: bold;">void</span> introducirEstudiante <span style="color: #009900;">&#40;</span>Estudiante estudiante<span style="color: #009900;">&#41;</span>
	<span style="color: #009900;">&#123;</span>
		hibernateTemplate.<span style="color: #006633;">saveOrUpdate</span><span style="color: #009900;">&#40;</span>estudiante<span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
	<span style="color: #009900;">&#125;</span>
&nbsp;
&nbsp;
&nbsp;
<span style="color: #009900;">&#125;</span></pre></td></tr></table></div>

<p>El objetivo del ejemplo era crear la interconexión entre diferentes tecnologías para llegar a una situación cotidiana a nivel de empresa pero sin pretender ser un estudio exaustivo en la introducción de liberías para excel en java por ello introducimos un enlace a un sitio donde amplian información </p>
<p><a href="http://www.roseindia.net/answers/viewqa/Java-Beginners/14883-how-to-use-Excel-Templet-to-write-excel-file-using-java..html">Rose India</a></p>
<p>Se intenta simpre evitar poner cosas que no esten en español pero en este caso por las ventajas que suponen para el lector se pone un enlace a una web en inglés pero hay que decir que es sencillo.</p>
<img src="http://feeds.feedburner.com/~r/railsymas/~4/Rap-CjdtGbo" height="1" width="1"/>]]></content:encoded>
			<wfw:commentRss>http://www.railsymas.com/2011/10/26/exportando-datos-a-excel-con-spring-framework/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Escuela de diseño gráfico (green apple school)</title>
		<link>http://www.railsymas.com/2011/10/07/escuela-de-diseno-grafico-green-apple-school/</link>
		<comments>http://www.railsymas.com/2011/10/07/escuela-de-diseno-grafico-green-apple-school/#comments</comments>
		<pubDate>Fri, 07 Oct 2011 17:23:48 +0000</pubDate>
		<dc:creator>admin</dc:creator>
				<category><![CDATA[Diseño]]></category>

		<guid isPermaLink="false">http://www.railsymas.com/?p=2448</guid>
		<description><![CDATA[Aunque siempre es recomendable trabajar uno mismo conceptos de diseño gráfico suele ser común que nuestros estudios no hemos recibido una formación teórica y práctica conveniente porque procedemos de mundos ajenos a dicha temática pero sin embargo estamos interesados en formarnos Direccion web Green apple school Ubicados en españa concretamente gijón asturias tenemos una escuela [...]]]></description>
			<content:encoded><![CDATA[<p> Aunque siempre es recomendable trabajar uno mismo conceptos de diseño gráfico suele ser común que nuestros estudios no hemos recibido una formación teórica y práctica conveniente porque procedemos de mundos ajenos a dicha temática pero sin embargo estamos interesados en formarnos</p>
<p><img src="http://www.railsymas.com/wp-content/uploads/2011/10/manzana.jpg" alt="" title="manzana" width="180" height="180" class="alignnone size-full wp-image-2451" /></p>
<p>Direccion web <a href="http://www.greenappleschool.es/">Green apple school</a></p>
<p> <span id="more-2448"></span></p>
<p> Ubicados en españa concretamente gijón asturias tenemos una escuela de formación en múltiples materias dentro del ámbito del diseño gráfico.</p>
<p><img src="http://www.railsymas.com/wp-content/uploads/2011/10/cursongreen.png" alt="" title="cursongreen" width="660" height="420" class="alignnone size-full wp-image-2454" /></p>
<img src="http://feeds.feedburner.com/~r/railsymas/~4/twz327ypQOc" height="1" width="1"/>]]></content:encoded>
			<wfw:commentRss>http://www.railsymas.com/2011/10/07/escuela-de-diseno-grafico-green-apple-school/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
	<copyright>copyright railsymas.com</copyright><media:credit role="author">admin</media:credit><media:rating>nonadult</media:rating></channel>
</rss>

