<?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>Sun, 22 Aug 2010 21:24:20 +0000</lastBuildDate>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.0.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>Varias clases en un mismo div</title>
		<link>http://www.railsymas.com/2010/08/22/varias-clases-en-un-mismo-div/</link>
		<comments>http://www.railsymas.com/2010/08/22/varias-clases-en-un-mismo-div/#comments</comments>
		<pubDate>Sun, 22 Aug 2010 20:15:53 +0000</pubDate>
		<dc:creator>admin</dc:creator>
				<category><![CDATA[Nuevas Tecnologías]]></category>
		<category><![CDATA[Pequeñas recetas]]></category>

		<guid isPermaLink="false">http://www.railsymas.com/?p=1920</guid>
		<description><![CDATA[Un ejemplo de utilización de varias clases, aplicadas a una misma capa 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 &#60;style type=&#34;text/css&#34;&#62; &#160; .cuadrado{ width:200px; height:200px; } &#160; .fondorojo { background-color:red; } &#160; .esquinas [...]]]></description>
			<content:encoded><![CDATA[<p>  Un ejemplo de utilización de varias clases, aplicadas a una misma capa</p>
<p>  <span id="more-1920"></span></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
</pre></td><td class="code"><pre class="html" style="font-family:monospace;">&lt;style type=&quot;text/css&quot;&gt;
&nbsp;
  .cuadrado{
     width:200px;
     height:200px;
  }
&nbsp;
  .fondorojo {
     background-color:red;
   }
&nbsp;
  .esquinas {
&nbsp;
     -moz-border-radius-topright:1em;
     -moz-border-radius-topleft:1em;
     -moz-border-radius-bottomright:1em;
     -moz-border-radius-bottomleft:1em; 
&nbsp;
   }
&nbsp;
&lt;/style&gt;
&lt;/head&gt;
&lt;body&gt;
&nbsp;
 &lt;div class=&quot;cuadrado fondorojo esquinas&quot;&gt;
  &amp;nbsp;
 &lt;/div&gt;
&nbsp;
&lt;/body&gt;</pre></td></tr></table></div>

<p>Resultado, con el redondeado de esquinas para firefox</p>
<p><a href="http://www.railsymas.com/wp-content/uploads/2010/08/capamoz.png"><img src="http://www.railsymas.com/wp-content/uploads/2010/08/capamoz.png" alt="" title="capamoz" width="214" height="216" class="alignnone size-full wp-image-1924" /></a></p>
<img src="http://feeds.feedburner.com/~r/railsymas/~4/YmRRodMieig" height="1" width="1"/>]]></content:encoded>
			<wfw:commentRss>http://www.railsymas.com/2010/08/22/varias-clases-en-un-mismo-div/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Interesante sitio de iconos para portafolios</title>
		<link>http://www.railsymas.com/2010/07/27/interesante-sitio-de-iconos-para-portafolios/</link>
		<comments>http://www.railsymas.com/2010/07/27/interesante-sitio-de-iconos-para-portafolios/#comments</comments>
		<pubDate>Tue, 27 Jul 2010 22:41:56 +0000</pubDate>
		<dc:creator>admin</dc:creator>
				<category><![CDATA[Diseño]]></category>

		<guid isPermaLink="false">http://www.railsymas.com/?p=1892</guid>
		<description><![CDATA[Selección de iconos para la realización de portafolios web. http://designm.ag/resources/portfolio-icon-sets/]]></description>
			<content:encoded><![CDATA[<p>Selección de iconos  para la realización de portafolios web.</p>
<p><span id="more-1892"></span></p>
<p><a href="http://designm.ag/resources/portfolio-icon-sets/ ">http://designm.ag/resources/portfolio-icon-sets/</a></p>
<img src="http://feeds.feedburner.com/~r/railsymas/~4/XBRvYBJEk1k" height="1" width="1"/>]]></content:encoded>
			<wfw:commentRss>http://www.railsymas.com/2010/07/27/interesante-sitio-de-iconos-para-portafolios/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Conexión jdbc en jsf</title>
		<link>http://www.railsymas.com/2010/07/25/conexion-jdbc-en-jsf/</link>
		<comments>http://www.railsymas.com/2010/07/25/conexion-jdbc-en-jsf/#comments</comments>
		<pubDate>Sun, 25 Jul 2010 20:25:49 +0000</pubDate>
		<dc:creator>admin</dc:creator>
				<category><![CDATA[jsf (java server faces)]]></category>

		<guid isPermaLink="false">http://www.railsymas.com/?p=1872</guid>
		<description><![CDATA[Ejemplo de conexión de una base de datos con el framework java server faces La conexión se realiza mediante un fichero de configuración datasource, siendo más flexible para el desarrollo de una aplicación, ya que si en las clases de modelos se tienen que hacer en todas y cada una de ellas una configuración de [...]]]></description>
			<content:encoded><![CDATA[<p> Ejemplo de conexión de una base de datos con el framework java server faces</p>
<p> <span id="more-1872"></span></p>
<p> La conexión se realiza mediante un fichero de configuración datasource, siendo más flexible para el desarrollo de una aplicación, ya que si en las clases de modelos se tienen que hacer en todas y cada una de ellas una configuración de los drivers específica de la aplicación, se pierde flexibilidad a la hora de extender y ampliar.</p>
<p>incorporación en el archivo web.xml del Conector</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;">  <span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;resource-ref<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>
      <span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;description<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>DB Connection<span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;/description<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>
      <span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;res-ref-name<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>jdbc/datasource<span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;/res-ref-name<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>
      <span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;res-type<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>javax.sql.DataSource<span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;/res-type<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>
      <span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;res-auth<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>Container<span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;/res-auth<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>     
  <span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;/resource-ref<span style="color: #000000; font-weight: bold;">&gt;</span></span></span></pre></td></tr></table></div>

<p>Configuración del fichero context.xml , igual que los ejemplos explicados de j2ee</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
</pre></td><td class="code"><pre class="xml" style="font-family:monospace;"><span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;?xml</span> <span style="color: #000066;">version</span>=<span style="color: #ff0000;">&quot;1.0&quot;</span> <span style="color: #000066;">encoding</span>=<span style="color: #ff0000;">&quot;UTF-8&quot;</span><span style="color: #000000; font-weight: bold;">?&gt;</span></span>
<span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;Context</span> <span style="color: #000066;">path</span>=<span style="color: #ff0000;">&quot;/DBTest&quot;</span> <span style="color: #000066;">docBase</span>=<span style="color: #ff0000;">&quot;DBTest&quot;</span></span>
<span style="color: #009900;">        <span style="color: #000066;">debug</span>=<span style="color: #ff0000;">&quot;5&quot;</span> <span style="color: #000066;">reloadable</span>=<span style="color: #ff0000;">&quot;true&quot;</span> <span style="color: #000066;">crossContext</span>=<span style="color: #ff0000;">&quot;true&quot;</span><span style="color: #000000; font-weight: bold;">&gt;</span></span>
&nbsp;
    <span style="color: #808080; font-style: italic;">&lt;!-- maxActive: Maximum number of dB connections in pool. Make sure you</span>
<span style="color: #808080; font-style: italic;">         configure your mysqld max_connections large enough to handle</span>
<span style="color: #808080; font-style: italic;">         all of your db connections. Set to -1 for no limit.</span>
<span style="color: #808080; font-style: italic;">         --&gt;</span>
&nbsp;
    <span style="color: #808080; font-style: italic;">&lt;!-- maxIdle: Maximum number of idle dB connections to retain in pool.</span>
<span style="color: #808080; font-style: italic;">         Set to -1 for no limit.  See also the DBCP documentation on this</span>
<span style="color: #808080; font-style: italic;">         and the minEvictableIdleTimeMillis configuration parameter.</span>
<span style="color: #808080; font-style: italic;">         --&gt;</span>
&nbsp;
    <span style="color: #808080; font-style: italic;">&lt;!-- maxWait: Maximum time to wait for a dB connection to become available</span>
<span style="color: #808080; font-style: italic;">         in ms, in this example 10 seconds. An Exception is thrown if</span>
<span style="color: #808080; font-style: italic;">         this timeout is exceeded.  Set to -1 to wait indefinitely.</span>
<span style="color: #808080; font-style: italic;">         --&gt;</span>
&nbsp;
    <span style="color: #808080; font-style: italic;">&lt;!-- username and password: MySQL dB username and password for dB connections  --&gt;</span>
&nbsp;
    <span style="color: #808080; font-style: italic;">&lt;!-- driverClassName: Class name for the old mm.mysql JDBC driver is</span>
<span style="color: #808080; font-style: italic;">         org.gjt.mm.mysql.Driver - we recommend using Connector/J though.</span>
<span style="color: #808080; font-style: italic;">         Class name for the official MySQL Connector/J driver is com.mysql.jdbc.Driver.</span>
<span style="color: #808080; font-style: italic;">         --&gt;</span>
&nbsp;
    <span style="color: #808080; font-style: italic;">&lt;!-- url: The JDBC connection url for connecting to your MySQL dB.</span>
<span style="color: #808080; font-style: italic;">         --&gt;</span>
&nbsp;
  <span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;Resource</span> <span style="color: #000066;">name</span>=<span style="color: #ff0000;">&quot;jdbc/datasource&quot;</span> <span style="color: #000066;">auth</span>=<span style="color: #ff0000;">&quot;Container&quot;</span> <span style="color: #000066;">type</span>=<span style="color: #ff0000;">&quot;javax.sql.DataSource&quot;</span></span>
<span style="color: #009900;">               <span style="color: #000066;">maxActive</span>=<span style="color: #ff0000;">&quot;100&quot;</span> <span style="color: #000066;">maxIdle</span>=<span style="color: #ff0000;">&quot;30&quot;</span> <span style="color: #000066;">maxWait</span>=<span style="color: #ff0000;">&quot;10000&quot;</span></span>
<span style="color: #009900;">               <span style="color: #000066;">username</span>=<span style="color: #ff0000;">&quot;root&quot;</span> <span style="color: #000066;">password</span>=<span style="color: #ff0000;">&quot;root&quot;</span> <span style="color: #000066;">driverClassName</span>=<span style="color: #ff0000;">&quot;com.mysql.jdbc.Driver&quot;</span></span>
<span style="color: #009900;">               <span style="color: #000066;">url</span>=<span style="color: #ff0000;">&quot;jdbc:mysql://localhost:3306/libros_jdbc&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;/Context<span style="color: #000000; font-weight: bold;">&gt;</span></span></span></pre></td></tr></table></div>

<p>una vez creado los elementos necesarios para la conexión ya explicados en otros post creamos los formularios de recogida de datos y los bean asociados a los formularios</p>
<p>Bean libro.java asociado al formulariojdbc.jsp, creamos las propiedades de la tabla libros con los tres campos y sus correspondientes getters y setters</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
</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;">beans</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> Libros <span style="color: #009900;">&#123;</span>
&nbsp;
	<span style="color: #000000; font-weight: bold;">private</span> <span style="color: #003399;">String</span> titulo<span style="color: #339933;">;</span>
	<span style="color: #000000; font-weight: bold;">private</span> <span style="color: #003399;">String</span> autor<span style="color: #339933;">;</span>
	<span style="color: #000000; font-weight: bold;">private</span> <span style="color: #003399;">String</span> tematica<span style="color: #339933;">;</span>
&nbsp;
	<span style="color: #000000; font-weight: bold;">public</span> <span style="color: #003399;">String</span> getTitulo<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> titulo<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> setTitulo<span style="color: #009900;">&#40;</span><span style="color: #003399;">String</span> titulo<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;">titulo</span> <span style="color: #339933;">=</span> titulo<span style="color: #339933;">;</span>
	<span style="color: #009900;">&#125;</span>
	<span style="color: #000000; font-weight: bold;">public</span> <span style="color: #003399;">String</span> getAutor<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> autor<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> setAutor<span style="color: #009900;">&#40;</span><span style="color: #003399;">String</span> autor<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;">autor</span> <span style="color: #339933;">=</span> autor<span style="color: #339933;">;</span>
	<span style="color: #009900;">&#125;</span>
	<span style="color: #000000; font-weight: bold;">public</span> <span style="color: #003399;">String</span> getTematica<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> tematica<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> setTematica<span style="color: #009900;">&#40;</span><span style="color: #003399;">String</span> tematica<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;">tematica</span> <span style="color: #339933;">=</span> tematica<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>Este bean es el encargado de recoger los datos del formulario, el formulario de jsf cuando detecta una etiqueta que hace referencia a un bean mediante el lenguaje de expresión intenta conectarse  siendo necesario dar de alta en el fichero faces-config.xml el bean libros</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;"> <span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;managed-bean<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>
    <span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;managed-bean-name<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>libroBean<span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;/managed-bean-name<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>
    <span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;managed-bean-class<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>beans.Libros<span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;/managed-bean-class<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>
    <span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;managed-bean-scope<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>request<span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;/managed-bean-scope<span style="color: #000000; font-weight: bold;">&gt;</span></span></span> 
    <span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;/managed-bean<span style="color: #000000; font-weight: bold;">&gt;</span></span></span></pre></td></tr></table></div>

<p>nombre del bean para ser usado, path y ámbito</p>
<p>Código del formulariojdbc.jsf  encargado de recoger los datos correspondientes al libro</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: #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 prefix<span style="color: #339933;">=</span><span style="color: #0000ff;">&quot;f&quot;</span>  uri<span style="color: #339933;">=</span><span style="color: #0000ff;">&quot;http://java.sun.com/jsf/core&quot;</span><span style="color: #339933;">%&gt;</span>
<span style="color: #339933;">&lt;%</span>@ taglib prefix<span style="color: #339933;">=</span><span style="color: #0000ff;">&quot;h&quot;</span>  uri<span style="color: #339933;">=</span><span style="color: #0000ff;">&quot;http://java.sun.com/jsf/html&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>f<span style="color: #339933;">:</span>view<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> 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>title<span style="color: #339933;">&gt;</span>formulario jsf jdbc<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>h2<span style="color: #339933;">&gt;&lt;</span>h<span style="color: #339933;">:</span>outputText value<span style="color: #339933;">=</span><span style="color: #0000ff;">&quot;formulario libros&quot;</span><span style="color: #339933;">/&gt;&lt;/</span>h2<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>
<span style="color: #339933;">&lt;</span>h<span style="color: #339933;">:</span>form<span style="color: #339933;">&gt;</span>
<span style="color: #339933;">&lt;</span>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>h<span style="color: #339933;">:</span>outputText value<span style="color: #339933;">=</span><span style="color: #0000ff;">&quot;introduce el título&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>h<span style="color: #339933;">:</span>inputText value<span style="color: #339933;">=</span><span style="color: #0000ff;">&quot;#{libroBean.titulo}&quot;</span><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>h<span style="color: #339933;">:</span>outputText value<span style="color: #339933;">=</span><span style="color: #0000ff;">&quot;introduce el autor&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>h<span style="color: #339933;">:</span>inputText value<span style="color: #339933;">=</span><span style="color: #0000ff;">&quot;#{libroBean.autor}&quot;</span><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>h<span style="color: #339933;">:</span>outputText value<span style="color: #339933;">=</span><span style="color: #0000ff;">&quot;introduce la temática&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>h<span style="color: #339933;">:</span>inputText value<span style="color: #339933;">=</span><span style="color: #0000ff;">&quot;#{libroBean.tematica}&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>h<span style="color: #339933;">:</span>commandButton action<span style="color: #339933;">=</span><span style="color: #0000ff;">&quot;almacenaraction&quot;</span> actionListener<span style="color: #339933;">=</span><span style="color: #0000ff;">&quot;#{almacenarlibro.insertarLibro}&quot;</span> value<span style="color: #339933;">=</span><span style="color: #0000ff;">&quot;enviar&quot;</span> styleClass<span style="color: #339933;">=</span><span style="color: #0000ff;">&quot;boton&quot;</span><span style="color: #339933;">/&gt;</span>
<span style="color: #339933;">&lt;/</span>h<span style="color: #339933;">:</span>form<span style="color: #339933;">&gt;</span>
<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>f<span style="color: #339933;">:</span>view<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>Bean encargado de la tramitación de los datos a la base de datos</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;"> <span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;managed-bean<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>
    <span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;managed-bean-name<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>almacenarlibro<span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;/managed-bean-name<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>
    <span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;managed-bean-class<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>conexion.OperacionesConexion<span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;/managed-bean-class<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>
    <span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;managed-bean-scope<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>request<span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;/managed-bean-scope<span style="color: #000000; font-weight: bold;">&gt;</span></span></span> 
    <span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;/managed-bean<span style="color: #000000; font-weight: bold;">&gt;</span></span></span></pre></td></tr></table></div>

<p>Imagen correspondiente al formulariojdbc.jsp<br />
<br/><br />
<a href="http://www.railsymas.com/wp-content/uploads/2010/07/forjsfdat.png"><img src="http://www.railsymas.com/wp-content/uploads/2010/07/forjsfdat.png" alt="" title="forjsfdat" width="580" height="300" class="alignnone size-full wp-image-1884" /></a></p>
<p>Código de la página listadojsf</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 prefix<span style="color: #339933;">=</span><span style="color: #0000ff;">&quot;f&quot;</span>  uri<span style="color: #339933;">=</span><span style="color: #0000ff;">&quot;http://java.sun.com/jsf/core&quot;</span><span style="color: #339933;">%&gt;</span>
<span style="color: #339933;">&lt;%</span>@ taglib prefix<span style="color: #339933;">=</span><span style="color: #0000ff;">&quot;h&quot;</span>  uri<span style="color: #339933;">=</span><span style="color: #0000ff;">&quot;http://java.sun.com/jsf/html&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>f<span style="color: #339933;">:</span>view<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;</span>Listado libros<span style="color: #339933;">&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> 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>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;</span>Listado libros jdbc jsf<span style="color: #339933;">&lt;/</span>h2<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;tabla&quot;</span><span style="color: #339933;">&gt;</span>
<span style="color: #339933;">&lt;</span>h<span style="color: #339933;">:</span>dataTable styleClass<span style="color: #339933;">=</span><span style="color: #0000ff;">&quot;tabla&quot;</span> value<span style="color: #339933;">=</span><span style="color: #0000ff;">&quot;#{almacenarlibro.listalibros}&quot;</span> var<span style="color: #339933;">=</span><span style="color: #0000ff;">&quot;libro&quot;</span> headerClass<span style="color: #339933;">=</span><span style="color: #0000ff;">&quot;cabeceratabla&quot;</span>
 columnClasses<span style="color: #339933;">=</span><span style="color: #0000ff;">&quot;impar,par,impar&quot;</span> cellspacing<span style="color: #339933;">=</span><span style="color: #0000ff;">&quot;2&quot;</span>  footerClass<span style="color: #339933;">=</span><span style="color: #0000ff;">&quot;pietabla&quot;</span><span style="color: #339933;">&gt;</span>
&nbsp;
  <span style="color: #339933;">&lt;</span>h<span style="color: #339933;">:</span>column<span style="color: #339933;">&gt;</span>
&nbsp;
  <span style="color: #339933;">&lt;</span>f<span style="color: #339933;">:</span>facet name<span style="color: #339933;">=</span><span style="color: #0000ff;">&quot;header&quot;</span><span style="color: #339933;">&gt;</span>
&nbsp;
  <span style="color: #339933;">&lt;</span>h<span style="color: #339933;">:</span>outputText<span style="color: #339933;">&gt;</span>T<span style="color: #339933;">&amp;</span>iacute<span style="color: #339933;">;</span>tulo<span style="color: #339933;">&lt;/</span>h<span style="color: #339933;">:</span>outputText<span style="color: #339933;">&gt;</span>
&nbsp;
  <span style="color: #339933;">&lt;/</span>f<span style="color: #339933;">:</span>facet<span style="color: #339933;">&gt;</span>
&nbsp;
  <span style="color: #339933;">&lt;</span>h<span style="color: #339933;">:</span>outputText value<span style="color: #339933;">=</span><span style="color: #0000ff;">&quot;#{libro.titulo}&quot;</span><span style="color: #339933;">/&gt;</span>
&nbsp;
&nbsp;
  <span style="color: #339933;">&lt;/</span>h<span style="color: #339933;">:</span>column<span style="color: #339933;">&gt;</span>
  <span style="color: #339933;">&lt;</span>h<span style="color: #339933;">:</span>column<span style="color: #339933;">&gt;</span>
  <span style="color: #339933;">&lt;</span>f<span style="color: #339933;">:</span>facet name<span style="color: #339933;">=</span><span style="color: #0000ff;">&quot;header&quot;</span><span style="color: #339933;">&gt;</span>
  <span style="color: #339933;">&lt;</span>h<span style="color: #339933;">:</span>outputText<span style="color: #339933;">&gt;</span>Autor<span style="color: #339933;">&lt;/</span>h<span style="color: #339933;">:</span>outputText<span style="color: #339933;">&gt;</span>
  <span style="color: #339933;">&lt;/</span>f<span style="color: #339933;">:</span>facet<span style="color: #339933;">&gt;</span>
  <span style="color: #339933;">&lt;</span>h<span style="color: #339933;">:</span>outputText value<span style="color: #339933;">=</span><span style="color: #0000ff;">&quot;#{libro.autor}&quot;</span><span style="color: #339933;">/&gt;</span> 
  <span style="color: #339933;">&lt;/</span>h<span style="color: #339933;">:</span>column<span style="color: #339933;">&gt;</span>
  <span style="color: #339933;">&lt;</span>h<span style="color: #339933;">:</span>column<span style="color: #339933;">&gt;</span>
  <span style="color: #339933;">&lt;</span>f<span style="color: #339933;">:</span>facet name<span style="color: #339933;">=</span><span style="color: #0000ff;">&quot;header&quot;</span><span style="color: #339933;">&gt;</span>
  <span style="color: #339933;">&lt;</span>h<span style="color: #339933;">:</span>outputText<span style="color: #339933;">&gt;</span>Tem<span style="color: #339933;">&amp;</span>aacute<span style="color: #339933;">;</span>tica<span style="color: #339933;">&lt;/</span>h<span style="color: #339933;">:</span>outputText<span style="color: #339933;">&gt;</span>
  <span style="color: #339933;">&lt;/</span>f<span style="color: #339933;">:</span>facet<span style="color: #339933;">&gt;</span>
  <span style="color: #339933;">&lt;</span>h<span style="color: #339933;">:</span>outputText value<span style="color: #339933;">=</span><span style="color: #0000ff;">&quot;#{libro.tematica}&quot;</span><span style="color: #339933;">/&gt;</span>
&nbsp;
  <span style="color: #339933;">&lt;/</span>h<span style="color: #339933;">:</span>column<span style="color: #339933;">&gt;</span>
   <span style="color: #339933;">&lt;</span>f<span style="color: #339933;">:</span>facet name<span style="color: #339933;">=</span><span style="color: #0000ff;">&quot;footer&quot;</span> <span style="color: #339933;">&gt;</span>
   <span style="color: #339933;">&lt;</span>h<span style="color: #339933;">:</span>outputText<span style="color: #339933;">&gt;</span> listado tabla<span style="color: #339933;">&lt;/</span>h<span style="color: #339933;">:</span>outputText<span style="color: #339933;">&gt;</span>
  <span style="color: #339933;">&lt;/</span>f<span style="color: #339933;">:</span>facet<span style="color: #339933;">&gt;</span>
<span style="color: #339933;">&lt;/</span>h<span style="color: #339933;">:</span>dataTable<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>f<span style="color: #339933;">:</span>view<span style="color: #339933;">&gt;</span>
<span style="color: #339933;">&lt;/</span>html<span style="color: #339933;">&gt;</span></pre></td></tr></table></div>

<img src="http://feeds.feedburner.com/~r/railsymas/~4/BUgYGbIyaTc" height="1" width="1"/>]]></content:encoded>
			<wfw:commentRss>http://www.railsymas.com/2010/07/25/conexion-jdbc-en-jsf/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Validando campos para jsf</title>
		<link>http://www.railsymas.com/2010/07/16/validando-campos-para-jsf/</link>
		<comments>http://www.railsymas.com/2010/07/16/validando-campos-para-jsf/#comments</comments>
		<pubDate>Fri, 16 Jul 2010 22:17:18 +0000</pubDate>
		<dc:creator>admin</dc:creator>
				<category><![CDATA[jsf (java server faces)]]></category>

		<guid isPermaLink="false">http://www.railsymas.com/?p=1851</guid>
		<description><![CDATA[Ejemplo de validación de algunos tipos de campos 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 [...]]]></description>
			<content:encoded><![CDATA[<p> Ejemplo de validación de algunos tipos de campos </p>
<p> <span id="more-1851"></span></p>
<p><a href="http://www.railsymas.com/wp-content/uploads/2010/07/formvalidacion.png"><img src="http://www.railsymas.com/wp-content/uploads/2010/07/formvalidacion.png" alt="" title="formvalidacion" width="634" height="411" class="alignnone size-full wp-image-1864" /></a></p>
<p><a href="http://www.railsymas.com/wp-content/uploads/2010/07/situacion11.png"><img src="http://www.railsymas.com/wp-content/uploads/2010/07/situacion11.png" alt="" title="situacion11" width="580" height="400" class="alignnone size-full wp-image-1866" /></a></p>
<p><a href="http://www.railsymas.com/wp-content/uploads/2010/07/situacion3.png"><img src="http://www.railsymas.com/wp-content/uploads/2010/07/situacion3.png" alt="" title="situacion3" width="580" height="400" class="alignnone size-full wp-image-1863" /></a></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
</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 prefix<span style="color: #339933;">=</span><span style="color: #0000ff;">&quot;f&quot;</span>  uri<span style="color: #339933;">=</span><span style="color: #0000ff;">&quot;http://java.sun.com/jsf/core&quot;</span><span style="color: #339933;">%&gt;</span>
<span style="color: #339933;">&lt;%</span>@ taglib prefix<span style="color: #339933;">=</span><span style="color: #0000ff;">&quot;h&quot;</span>  uri<span style="color: #339933;">=</span><span style="color: #0000ff;">&quot;http://java.sun.com/jsf/html&quot;</span><span style="color: #339933;">%&gt;</span>
&nbsp;
&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>f<span style="color: #339933;">:</span>view<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> 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>
&nbsp;
<span style="color: #339933;">&lt;</span>title<span style="color: #339933;">&gt;</span>Formulario mensaje<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: #339933;">&lt;</span>div id<span style="color: #339933;">=</span><span style="color: #0000ff;">&quot;contenido&quot;</span><span style="color: #339933;">&gt;</span>
&nbsp;
   <span style="color: #339933;">&lt;</span>h2<span style="color: #339933;">&gt;</span> Formulario Mensajes<span style="color: #339933;">&lt;/</span>h2<span style="color: #339933;">&gt;</span>
&nbsp;
   <span style="color: #339933;">&lt;</span>h<span style="color: #339933;">:</span>form<span style="color: #339933;">&gt;</span>
&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>h<span style="color: #339933;">:</span>outputText value<span style="color: #339933;">=</span><span style="color: #0000ff;">&quot;#{mensaje.nombre}&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>h<span style="color: #339933;">:</span>inputText  id<span style="color: #339933;">=</span><span style="color: #0000ff;">&quot;nombre&quot;</span> value<span style="color: #339933;">=</span><span style="color: #0000ff;">&quot;#{mensajesBean.nombre}&quot;</span>   required<span style="color: #339933;">=</span><span style="color: #0000ff;">&quot;true&quot;</span> <span style="color: #339933;">/&gt;</span>
&nbsp;
&nbsp;
   <span style="color: #339933;">&lt;</span>h<span style="color: #339933;">:</span>message <span style="color: #000000; font-weight: bold;">for</span><span style="color: #339933;">=</span><span style="color: #0000ff;">&quot;nombre&quot;</span> errorClass<span style="color: #339933;">=</span><span style="color: #0000ff;">&quot;errores&quot;</span> <span style="color: #339933;">/&gt;</span>
&nbsp;
   <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: #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>h<span style="color: #339933;">:</span>outputText value<span style="color: #339933;">=</span><span style="color: #0000ff;">&quot;#{mensaje.apellidos}&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>h<span style="color: #339933;">:</span>inputText value<span style="color: #339933;">=</span><span style="color: #0000ff;">&quot;#{mensajesBean.apellidos}&quot;</span> required<span style="color: #339933;">=</span><span style="color: #0000ff;">&quot;true&quot;</span> id<span style="color: #339933;">=</span><span style="color: #0000ff;">&quot;apellidos&quot;</span><span style="color: #339933;">/&gt;</span>
&nbsp;
   <span style="color: #339933;">&lt;</span>h<span style="color: #339933;">:</span>message <span style="color: #000000; font-weight: bold;">for</span><span style="color: #339933;">=</span><span style="color: #0000ff;">&quot;apellidos&quot;</span> errorClass<span style="color: #339933;">=</span><span style="color: #0000ff;">&quot;errores&quot;</span><span style="color: #339933;">/&gt;</span>
&nbsp;
&nbsp;
   <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: #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>h<span style="color: #339933;">:</span>outputText value<span style="color: #339933;">=</span><span style="color: #0000ff;">&quot;#{mensaje.edad}&quot;</span><span style="color: #339933;">/&gt;</span>
&nbsp;
   <span style="color: #339933;">&lt;</span>br<span style="color: #339933;">/&gt;</span>
&nbsp;
&nbsp;
&nbsp;
   <span style="color: #339933;">&lt;</span>h<span style="color: #339933;">:</span>inputText converter<span style="color: #339933;">=</span><span style="color: #0000ff;">&quot;#{BigInteger}&quot;</span> id<span style="color: #339933;">=</span><span style="color: #0000ff;">&quot;edad&quot;</span> value<span style="color: #339933;">=</span><span style="color: #0000ff;">&quot;#{mensajesBean.edad}&quot;</span> required<span style="color: #339933;">=</span><span style="color: #0000ff;">&quot;true&quot;</span> <span style="color: #339933;">&gt;</span>
&nbsp;
   <span style="color: #339933;">&lt;</span>f<span style="color: #339933;">:</span>validateDoubleRange minimum<span style="color: #339933;">=</span><span style="color: #0000ff;">&quot;1&quot;</span> maximum<span style="color: #339933;">=</span><span style="color: #0000ff;">&quot;120&quot;</span> <span style="color: #339933;">/&gt;</span> 
&nbsp;
   <span style="color: #339933;">&lt;/</span>h<span style="color: #339933;">:</span>inputText<span style="color: #339933;">&gt;</span>
&nbsp;
   <span style="color: #339933;">&lt;</span>h<span style="color: #339933;">:</span>message <span style="color: #000000; font-weight: bold;">for</span><span style="color: #339933;">=</span><span style="color: #0000ff;">&quot;edad&quot;</span> errorClass<span style="color: #339933;">=</span><span style="color: #0000ff;">&quot;errores&quot;</span><span style="color: #339933;">/&gt;</span>
&nbsp;
   <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: #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>h<span style="color: #339933;">:</span>outputText value<span style="color: #339933;">=</span><span style="color: #0000ff;">&quot;introduce un número de teléfono&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>h<span style="color: #339933;">:</span>inputText value<span style="color: #339933;">=</span><span style="color: #0000ff;">&quot;#{mensajesBean.telefono}&quot;</span> required<span style="color: #339933;">=</span><span style="color: #0000ff;">&quot;true&quot;</span> id<span style="color: #339933;">=</span><span style="color: #0000ff;">&quot;telefono&quot;</span><span style="color: #339933;">&gt;</span>
&nbsp;
&nbsp;
   <span style="color: #339933;">&lt;</span>f<span style="color: #339933;">:</span>validateLength minimum<span style="color: #339933;">=</span><span style="color: #0000ff;">&quot;9&quot;</span><span style="color: #339933;">/&gt;</span>   
&nbsp;
   <span style="color: #339933;">&lt;/</span>h<span style="color: #339933;">:</span>inputText<span style="color: #339933;">&gt;</span>
&nbsp;
   <span style="color: #339933;">&lt;</span>h<span style="color: #339933;">:</span>message <span style="color: #000000; font-weight: bold;">for</span><span style="color: #339933;">=</span><span style="color: #0000ff;">&quot;telefono&quot;</span> errorClass<span style="color: #339933;">=</span><span style="color: #0000ff;">&quot;errores&quot;</span><span style="color: #339933;">/&gt;</span> 
&nbsp;
   <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: #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>h<span style="color: #339933;">:</span>outputText value<span style="color: #339933;">=</span><span style="color: #0000ff;">&quot;Introduce tu fecha de nacimiento&quot;</span><span style="color: #339933;">/&gt;</span>
&nbsp;
   <span style="color: #339933;">&lt;</span>h<span style="color: #339933;">:</span>inputText value<span style="color: #339933;">=</span><span style="color: #0000ff;">&quot;#{mensajesBean.fecha}&quot;</span> required<span style="color: #339933;">=</span><span style="color: #0000ff;">&quot;true&quot;</span> id<span style="color: #339933;">=</span><span style="color: #0000ff;">&quot;fecha&quot;</span><span style="color: #339933;">&gt;</span>
&nbsp;
     <span style="color: #339933;">&lt;</span>f<span style="color: #339933;">:</span>convertDateTime pattern<span style="color: #339933;">=</span><span style="color: #0000ff;">&quot;M/d/yy hh:mm&quot;</span>  <span style="color: #339933;">/&gt;</span>
&nbsp;
   <span style="color: #339933;">&lt;/</span>h<span style="color: #339933;">:</span>inputText<span style="color: #339933;">&gt;</span>
&nbsp;
   <span style="color: #339933;">&lt;</span>h<span style="color: #339933;">:</span>message <span style="color: #000000; font-weight: bold;">for</span><span style="color: #339933;">=</span><span style="color: #0000ff;">&quot;fecha&quot;</span> errorClass<span style="color: #339933;">=</span><span style="color: #0000ff;">&quot;errores&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>h<span style="color: #339933;">:</span>commandButton value<span style="color: #339933;">=</span><span style="color: #0000ff;">&quot;enviar&quot;</span> styleClass<span style="color: #339933;">=</span><span style="color: #0000ff;">&quot;boton&quot;</span> action<span style="color: #339933;">=</span><span style="color: #0000ff;">&quot;mensajeaction&quot;</span><span style="color: #339933;">/&gt;</span>
   <span style="color: #339933;">&lt;</span>h<span style="color: #339933;">:</span>commandButton  action<span style="color: #339933;">=</span><span style="color: #0000ff;">&quot;cancelaraction&quot;</span> value<span style="color: #339933;">=</span><span style="color: #0000ff;">&quot;cancelar&quot;</span> styleClass<span style="color: #339933;">=</span><span style="color: #0000ff;">&quot;boton&quot;</span>  immediate<span style="color: #339933;">=</span><span style="color: #0000ff;">&quot;true&quot;</span><span style="color: #339933;">/&gt;</span>   
&nbsp;
   <span style="color: #339933;">&lt;/</span>h<span style="color: #339933;">:</span>form<span style="color: #339933;">&gt;</span>
&nbsp;
   <span style="color: #339933;">&lt;/</span>div<span style="color: #339933;">&gt;</span>
&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>
&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>f<span style="color: #339933;">:</span>view<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>configuración  faces-confing.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
18
</pre></td><td class="code"><pre class="xml" style="font-family:monospace;"> <span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;navigation-rule<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>
    <span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;from-view-id<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>/pages/formulariomensajes.jsp<span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;/from-view-id<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>
    <span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;navigation-case<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>
     <span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;from-outcome<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>mensajeaction<span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;/from-outcome<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>
     <span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;to-view-id<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>/pages/resultadomensaje.jsp<span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;/to-view-id<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>
    <span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;/navigation-case<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>
&nbsp;
    <span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;/navigation-rule<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>
&nbsp;
&nbsp;
    <span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;navigation-rule<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>
     <span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;from-view-id<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>/pages/formulariomensajes.jsp<span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;/from-view-id<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>
     <span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;navigation-case<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>
     <span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;from-outcome<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>cancelaraction<span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;/from-outcome<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>
     <span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;to-view-id<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>/pages/cancelada.jsp<span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;/to-view-id<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>
     <span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;/navigation-case<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>
&nbsp;
    <span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;/navigation-rule<span style="color: #000000; font-weight: bold;">&gt;</span></span></span></pre></td></tr></table></div>

<p>Código de la página resulta</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
</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 prefix<span style="color: #339933;">=</span><span style="color: #0000ff;">&quot;f&quot;</span>  uri<span style="color: #339933;">=</span><span style="color: #0000ff;">&quot;http://java.sun.com/jsf/core&quot;</span><span style="color: #339933;">%&gt;</span>
<span style="color: #339933;">&lt;%</span>@ taglib prefix<span style="color: #339933;">=</span><span style="color: #0000ff;">&quot;h&quot;</span>  uri<span style="color: #339933;">=</span><span style="color: #0000ff;">&quot;http://java.sun.com/jsf/html&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>f<span style="color: #339933;">:</span>view<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>h<span style="color: #339933;">:</span>outputText value<span style="color: #339933;">=</span><span style="color: #0000ff;">&quot;#{mensaje.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> 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>head<span style="color: #339933;">&gt;</span>
<span style="color: #339933;">&lt;</span>body<span style="color: #339933;">&gt;</span>
&nbsp;
&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: #339933;">&lt;</span>div id<span style="color: #339933;">=</span><span style="color: #0000ff;">&quot;contenido&quot;</span><span style="color: #339933;">&gt;</span>
&nbsp;
&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>h<span style="color: #339933;">:</span>outputText value<span style="color: #339933;">=</span><span style="color: #0000ff;">&quot;Tu nombre:&quot;</span><span style="color: #339933;">/&gt;</span>
            <span style="color: #339933;">&lt;</span>h<span style="color: #339933;">:</span>outputText value<span style="color: #339933;">=</span><span style="color: #0000ff;">&quot;#{mensajesBean.nombre}&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>h<span style="color: #339933;">:</span>outputText value<span style="color: #339933;">=</span><span style="color: #0000ff;">&quot;Tus apellidos:&quot;</span><span style="color: #339933;">/&gt;</span>
            <span style="color: #339933;">&lt;</span>h<span style="color: #339933;">:</span>outputText value<span style="color: #339933;">=</span><span style="color: #0000ff;">&quot;#{mensajesBean.apellidos}&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>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>h<span style="color: #339933;">:</span>outputText value<span style="color: #339933;">=</span><span style="color: #0000ff;">&quot;Tu edad:&quot;</span><span style="color: #339933;">/&gt;</span>
            <span style="color: #339933;">&lt;</span>h<span style="color: #339933;">:</span>outputText value<span style="color: #339933;">=</span><span style="color: #0000ff;">&quot;#{mensajesBean.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>
&nbsp;
           <span style="color: #339933;">&lt;</span>h<span style="color: #339933;">:</span>outputText value<span style="color: #339933;">=</span><span style="color: #0000ff;">&quot;Tu teléfono:&quot;</span><span style="color: #339933;">/&gt;</span>
           <span style="color: #339933;">&lt;</span>h<span style="color: #339933;">:</span>outputText value<span style="color: #339933;">=</span><span style="color: #0000ff;">&quot;#{mensajesBean.telefono}&quot;</span><span style="color: #339933;">/&gt;</span>
&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<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>
&nbsp;
&nbsp;
&nbsp;
<span style="color: #339933;">&lt;/</span>body<span style="color: #339933;">&gt;</span>
<span style="color: #339933;">&lt;/</span>f<span style="color: #339933;">:</span>view<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>Los mensajes de errores correspondientes </p>
<p><a href="http://www.railsymas.com/wp-content/uploads/2010/07/propiedadeserrores.png"><img src="http://www.railsymas.com/wp-content/uploads/2010/07/propiedadeserrores.png" alt="" title="propiedadeserrores" width="324" height="82" class="alignnone size-full wp-image-1894" /></a></p>
<p>Configuración del archivo face-config.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
</pre></td><td class="code"><pre class="xml" style="font-family:monospace;">  <span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;application<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>
    <span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;resource-bundle<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>
    <span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;base-name<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>propiedades.message<span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;/base-name<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>
    <span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;var<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>mensaje<span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;/var<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>   
    <span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;/resource-bundle<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>
&nbsp;
&nbsp;
    <span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;locale-config<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>
    <span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;default-locale<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>es_ES<span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;/default-locale<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>
    <span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;supported-locale<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>en<span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;/supported-locale<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>    
    <span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;/locale-config<span style="color: #000000; font-weight: bold;">&gt;</span></span></span> 
&nbsp;
&nbsp;
    <span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;message-bundle<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>propiedades.erroresBundle<span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;/message-bundle<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>
&nbsp;
    <span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;/application<span style="color: #000000; font-weight: bold;">&gt;</span></span></span></pre></td></tr></table></div>

<p>jsf a diferencia de struts o springframework donde los errores los validamos  bien mediante clases específicas o mediante el framework struts-validator.xml en jsf existen una serie de mensajes estandar con los cuales jugar para obtener el resultado esperado</p>
<p>Código de erroresBundle.properties</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;
javax.faces.component.UIInput.REQUIRED = Campo Requerido
javax.faces.validator.DoubleRangeValidator.NOT_IN_RANGE =  No esta en el rango entre 1 y 120
javax.faces.converter.BigIntegerConverter.BIGINTEGER= {0} Tiene que ser un número
javax.faces.validator.LengthValidator.MINIMUM = El número de teléfono debe ser de nueve mínimo
javax.faces.converter.DateTimeConverter.DATE = {0} no es una fecha correcta</pre></td></tr></table></div>

<p>Dirección con gran cantidad de mensajes <a href="http://www.javadabbadoo.org/apendice/jsf/mensajesEstandar/index.html">javadabbadoo.org</a></p>
<img src="http://feeds.feedburner.com/~r/railsymas/~4/_tQTUEUHmj8" height="1" width="1"/>]]></content:encoded>
			<wfw:commentRss>http://www.railsymas.com/2010/07/16/validando-campos-para-jsf/feed/</wfw:commentRss>
		<slash:comments>2</slash:comments>
		</item>
		<item>
		<title>Ejemplo simple facelets jsf</title>
		<link>http://www.railsymas.com/2010/07/15/ejemplo-simple-facelets-jsf/</link>
		<comments>http://www.railsymas.com/2010/07/15/ejemplo-simple-facelets-jsf/#comments</comments>
		<pubDate>Thu, 15 Jul 2010 23:58:28 +0000</pubDate>
		<dc:creator>admin</dc:creator>
				<category><![CDATA[jsf (java server faces)]]></category>

		<guid isPermaLink="false">http://www.railsymas.com/?p=1831</guid>
		<description><![CDATA[Para la versión jsf 1.2 de este framework Sitio oficial para descarga de los jars https://facelets.dev.java.net/ Sitio oficial con documentación para desarrolladores https://facelets.dev.java.net/nonav/docs/dev/docbook.html modificación del archivo faces-config.xml para la visualización 1 2 3 &#60;application&#62; &#60;view-handler&#62;com.sun.facelets.FaceletViewHandler&#60;/view-handler&#62; &#60;/application&#62; modificación del fichero web.xml 1 2 3 4 5 6 7 8 9 10 11 12 13 14 &#60;context-param&#62; [...]]]></description>
			<content:encoded><![CDATA[<p>  Para la versión jsf 1.2 de este framework </p>
<p>  <span id="more-1831"></span></p>
<p>   Sitio oficial para descarga  de los jars <a href="https://facelets.dev.java.net/">https://facelets.dev.java.net/</a></p>
<p>   Sitio oficial con documentación para desarrolladores  <a href="https://facelets.dev.java.net/nonav/docs/dev/docbook.html">https://facelets.dev.java.net/nonav/docs/dev/docbook.html</a></p>
<p>   modificación del archivo faces-config.xml  para la visualización</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;application<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>
     <span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;view-handler<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>com.sun.facelets.FaceletViewHandler<span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;/view-handler<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>
    <span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;/application<span style="color: #000000; font-weight: bold;">&gt;</span></span></span></pre></td></tr></table></div>

<p>  modificación del fichero web.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
</pre></td><td class="code"><pre class="xml" style="font-family:monospace;">   <span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;context-param<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>
    <span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;param-name<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>facelets.DEVELOPMENT<span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;/param-name<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>
    <span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;param-value<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>true<span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;/param-value<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>
  <span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;/context-param<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>
&nbsp;
&nbsp;
  <span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;context-param<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>
   <span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;param-name<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>javax.faces.DEFAULT_SUFFIX<span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;/param-name<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>
   <span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;param-value<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>.xhtml<span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;/param-value<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>
  <span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;/context-param<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>
&nbsp;
  <span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;welcome-file-list<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>
    <span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;welcome-file<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>index.xhtml<span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;/welcome-file<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>    
  <span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;/welcome-file-list<span style="color: #000000; font-weight: bold;">&gt;</span></span></span></pre></td></tr></table></div>

<p>  modificamos el sufijo por defecto de las páginas de jsf a .xhtml</p>
<p>  los facelets nos permiten crear plantillas en jsf de una forma rápida y comoda al cambiar el manejador de las vistas todas nuestras jsp tienen que ser renombradas a xhtml pero no es obligatorio</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
</pre></td><td class="code"><pre class="xml" style="font-family:monospace;">  <span style="color: #00bbdd;">&lt;!DOCTYPE html PUBLIC &quot;-//W3C//DTD XHTML 1.0 Transitional//EN&quot; &quot;http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd&quot;&gt;</span>
<span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;html</span> <span style="color: #000066;">xmlns</span>=<span style="color: #ff0000;">&quot;http://www.w3.org/1999/xhtml&quot;</span> </span>
<span style="color: #009900;"> <span style="color: #000066;">xmlns:f</span>=<span style="color: #ff0000;">&quot;http://java.sun.com/jsf/core&quot;</span> <span style="color: #000066;">xmlns:ui</span>=<span style="color: #ff0000;">&quot;http://java.sun.com/jsf/facelets&quot;</span></span>
<span style="color: #009900;"> <span style="color: #000066;">xmlns:h</span>=<span style="color: #ff0000;">&quot;http://java.sun.com/jsf/html&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;head<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>
<span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;link</span> <span style="color: #000066;">rel</span>=<span style="color: #ff0000;">&quot;stylesheet&quot;</span> <span style="color: #000066;">href</span>=<span style="color: #ff0000;">&quot;../../css/estilo.css&quot;</span> <span style="color: #000066;">type</span>=<span style="color: #ff0000;">&quot;text/css&quot;</span><span style="color: #000000; font-weight: bold;">/&gt;</span></span>
<span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;ui:insert</span> <span style="color: #000066;">name</span>=<span style="color: #ff0000;">&quot;titulo&quot;</span><span style="color: #000000; font-weight: bold;">/&gt;</span></span>
<span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;/head<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>
<span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;body<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>
  <span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;div</span> <span style="color: #000066;">id</span>=<span style="color: #ff0000;">&quot;contenedor&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;div</span> <span style="color: #000066;">id</span>=<span style="color: #ff0000;">&quot;cabecera&quot;</span><span style="color: #000000; font-weight: bold;">&gt;</span></span>
  <span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;h2<span style="color: #000000; font-weight: bold;">&gt;</span></span><span style="color: #000000; font-weight: bold;">&lt;ui:insert</span> <span style="color: #000066;">name</span>=<span style="color: #ff0000;">&quot;cabecera&quot;</span><span style="color: #000000; font-weight: bold;">/&gt;</span><span style="color: #000000; font-weight: bold;">&lt;/h2<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>
  <span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;/div<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>
&nbsp;
  <span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;div</span> <span style="color: #000066;">id</span>=<span style="color: #ff0000;">&quot;contenido&quot;</span><span style="color: #000000; font-weight: bold;">&gt;</span></span>  
  <span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;ui:insert</span> <span style="color: #000066;">name</span>=<span style="color: #ff0000;">&quot;contenido&quot;</span><span style="color: #000000; font-weight: bold;">/&gt;</span></span>
  <span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;/div<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>
&nbsp;
  <span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;div</span> <span style="color: #000066;">id</span>=<span style="color: #ff0000;">&quot;pie&quot;</span><span style="color: #000000; font-weight: bold;">&gt;</span></span>  
  <span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;ui:insert</span> <span style="color: #000066;">name</span>=<span style="color: #ff0000;">&quot;pie&quot;</span><span style="color: #000000; font-weight: bold;">/&gt;</span></span>
  <span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;/div<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>
  <span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;/div<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>
<span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;/body<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>
<span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;/html<span style="color: #000000; font-weight: bold;">&gt;</span></span></span></pre></td></tr></table></div>

<p> Código de un cliente para la plantilla  clienteplantilla.xhtml</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
</pre></td><td class="code"><pre class="xml" style="font-family:monospace;"> <span style="color: #00bbdd;">&lt;!DOCTYPE html PUBLIC &quot;-//W3C//DTD XHTML 1.0 Transitional//EN&quot;</span>
<span style="color: #00bbdd;">&quot;http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd&quot;&gt;</span>
<span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;html</span> <span style="color: #000066;">xmlns</span>=<span style="color: #ff0000;">&quot;http://www.w3.org/1999/xhtml&quot;</span></span>
<span style="color: #009900;">      <span style="color: #000066;">xmlns:ui</span>=<span style="color: #ff0000;">&quot;http://java.sun.com/jsf/facelets&quot;</span></span>
<span style="color: #009900;">      <span style="color: #000066;">xmlns:h</span>=<span style="color: #ff0000;">&quot;http://java.sun.com/jsf/html&quot;</span><span style="color: #000000; font-weight: bold;">&gt;</span></span>
&nbsp;
&nbsp;
&nbsp;
 <span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;ui:composition</span> <span style="color: #000066;">template</span>=<span style="color: #ff0000;">&quot;plantillasimple.xhtml&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;ui:define</span> <span style="color: #000066;">name</span>=<span style="color: #ff0000;">&quot;cabecera&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;h:outputText</span> <span style="color: #000066;">value</span>=<span style="color: #ff0000;">&quot;Ejemplo simple con facelets&quot;</span><span style="color: #000000; font-weight: bold;">/&gt;</span></span>
	<span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;/ui:define<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>
&nbsp;
&nbsp;
	<span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;ui:define</span> <span style="color: #000066;">name</span>=<span style="color: #ff0000;">&quot;contenido&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;h:outputText</span> <span style="color: #000066;">value</span>=<span style="color: #ff0000;">&quot;cuerpo de la aplicación&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;/ui:define<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>
&nbsp;
	<span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;ui:define</span> <span style="color: #000066;">name</span>=<span style="color: #ff0000;">&quot;pie&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;p<span style="color: #000000; font-weight: bold;">&gt;</span></span><span style="color: #000000; font-weight: bold;">&lt;h:outputText</span> <span style="color: #000066;">value</span>=<span style="color: #ff0000;">&quot;www.railsymas.com&quot;</span><span style="color: #000000; font-weight: bold;">/&gt;</span><span style="color: #000000; font-weight: bold;">&lt;/p<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>
	<span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;/ui:define<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>
&nbsp;
 <span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;/ui:composition<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>
&nbsp;
<span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;/html<span style="color: #000000; font-weight: bold;">&gt;</span></span></span></pre></td></tr></table></div>

<p>Resultado</p>
<p><a href="http://www.railsymas.com/wp-content/uploads/2010/07/faceletsimple.png"><img src="http://www.railsymas.com/wp-content/uploads/2010/07/faceletsimple.png" alt="" title="faceletsimple" width="580" height="138" class="alignnone size-full wp-image-1843" /></a></p>
<img src="http://feeds.feedburner.com/~r/railsymas/~4/tiDjwi2jNz8" height="1" width="1"/>]]></content:encoded>
			<wfw:commentRss>http://www.railsymas.com/2010/07/15/ejemplo-simple-facelets-jsf/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Aproximación a liferay</title>
		<link>http://www.railsymas.com/2010/07/11/aproximacion-a-liferay/</link>
		<comments>http://www.railsymas.com/2010/07/11/aproximacion-a-liferay/#comments</comments>
		<pubDate>Sun, 11 Jul 2010 18:55:03 +0000</pubDate>
		<dc:creator>admin</dc:creator>
				<category><![CDATA[Liferay]]></category>

		<guid isPermaLink="false">http://www.railsymas.com/?p=1812</guid>
		<description><![CDATA[Dentro del desarrollo web y de las nuevas tecnologías se producen constantemente evoluciones del software que van encaminadas a la automatización de procesos, permitiendo quitar parte del trabajo cotidiano realizado por los desarrolladores para centrarse en aspectos específicos de la aplicación o estéticos. Para el trabajo con portales 2.0 el contar con una herramienta potente [...]]]></description>
			<content:encoded><![CDATA[<p> Dentro del desarrollo web y de las nuevas tecnologías se producen constantemente evoluciones<br />
<span id="more-1812"></span><br />
del software que van encaminadas a la automatización de procesos, permitiendo quitar parte del trabajo cotidiano realizado por los desarrolladores para centrarse en aspectos específicos de la aplicación o estéticos.  Para el trabajo con portales 2.0 el contar con una herramienta potente alivia mucho tanto el tiempo de desarrollo como los costes de producción.</p>
<p>Liferay es un cms basado en la tecnología java, esta basado en struts y la unidad de creación son los portlets que pueden ser para la versión 5.3 portlest 2.0 permitiendo eventos y comunicación entre portlets</p>
<p>Liferay permite mostrar entradas de diferentes idiomas, tiene una gran cantidad de portlets a los que se puede acceder desde el administrador de contenidos.</p>
<p>Tiene una base de datos y un usuario por defectos test para poder acceder como administradores.</p>
<p><a href="http://www.railsymas.com/wp-content/uploads/2010/07/liferay1ej.png"><img src="http://www.railsymas.com/wp-content/uploads/2010/07/liferay1ej.png" alt="" title="liferay1ej" width="580" height="380" class="alignnone size-full wp-image-1818" /></a></p>
<p>Se puede configurar el entorno para diferentes idiomas, además de cambiar los mensajes de bienvenida por defecto</p>
<p>el cms liferay cuenta con diferentes tipos de usuarios, en este caso tenemos un usuario administrador del liferay un usuario power user juan </p>
<p><a href="http://www.railsymas.com/wp-content/uploads/2010/07/liferay2ej.png"><img src="http://www.railsymas.com/wp-content/uploads/2010/07/liferay2ej.png" alt="" title="liferay2ej" width="580" height="400" class="alignnone size-full wp-image-1822" /></a></p>
<p><a href="http://www.railsymas.com/wp-content/uploads/2010/07/liferay3ej.png"><img src="http://www.railsymas.com/wp-content/uploads/2010/07/liferay3ej.png" alt="" title="liferay3ej" width="580" height="450" class="alignnone size-full wp-image-1825" /></a></p>
<p> Los usuarios del sistema pueden crear blogs y formar parte de comunidades según sus intereses</p>
<img src="http://feeds.feedburner.com/~r/railsymas/~4/Fa7xFIe1hRs" height="1" width="1"/>]]></content:encoded>
			<wfw:commentRss>http://www.railsymas.com/2010/07/11/aproximacion-a-liferay/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>DataTable  estilos de tabla</title>
		<link>http://www.railsymas.com/2010/07/10/datatable-estilos-de-tabla/</link>
		<comments>http://www.railsymas.com/2010/07/10/datatable-estilos-de-tabla/#comments</comments>
		<pubDate>Sat, 10 Jul 2010 21:38:12 +0000</pubDate>
		<dc:creator>admin</dc:creator>
				<category><![CDATA[jsf (java server faces)]]></category>

		<guid isPermaLink="false">http://www.railsymas.com/?p=1798</guid>
		<description><![CDATA[Ejemplo para el tratamiento de datos con dataTable de jsf Declaramos el bean, con el nombre deportesBean y el path de la clase beans.Deportes y el ámbito de petición request 1 2 3 4 5 &#60;managed-bean&#62; &#60;managed-bean-name&#62;deportesBean&#60;/managed-bean-name&#62; &#60;managed-bean-class&#62;beans.Deportes&#60;/managed-bean-class&#62; &#60;managed-bean-scope&#62;request&#60;/managed-bean-scope&#62; &#60;/managed-bean&#62; Declaramos la navegación del formulario desde formulariosdeportes enviando una petición de accion deportesaction para devolver [...]]]></description>
			<content:encoded><![CDATA[<p>  Ejemplo para el tratamiento de datos con dataTable de jsf</p>
<p>  <span id="more-1798"></span></p>
<p>Declaramos el bean, con el nombre deportesBean y el path de la clase beans.Deportes y el ámbito de petición request</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;">    <span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;managed-bean<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>
    <span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;managed-bean-name<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>deportesBean<span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;/managed-bean-name<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>
    <span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;managed-bean-class<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>beans.Deportes<span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;/managed-bean-class<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>
    <span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;managed-bean-scope<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>request<span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;/managed-bean-scope<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>    
    <span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;/managed-bean<span style="color: #000000; font-weight: bold;">&gt;</span></span></span></pre></td></tr></table></div>

<p>Declaramos la navegación del formulario desde formulariosdeportes enviando una petición de accion deportesaction para devolver el resultado en resultadodeportes</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;"> <span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;navigation-rule<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>
     <span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;from-view-id<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>/pages/formulariodeportes.jsp<span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;/from-view-id<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>
     <span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;navigation-case<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>
     <span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;from-outcome<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>deportesaction<span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;/from-outcome<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>
     <span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;to-view-id<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>/pages/resultadodeportes.jsp<span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;/to-view-id<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>  
     <span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;/navigation-case<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>
    <span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;/navigation-rule<span style="color: #000000; font-weight: bold;">&gt;</span></span></span></pre></td></tr></table></div>

<p>Declaramos el bean deportes</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
</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;">beans</span><span style="color: #339933;">;</span>
&nbsp;
<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> Deportes <span style="color: #009900;">&#123;</span>
&nbsp;
	<span style="color: #000000; font-weight: bold;">private</span> <span style="color: #003399;">ArrayList</span> <span style="color: #339933;">&lt;</span>String<span style="color: #339933;">&gt;</span> listaDeportes<span style="color: #339933;">;</span>
&nbsp;
	<span style="color: #000000; font-weight: bold;">public</span> ArrayList<span style="color: #339933;">&lt;</span>String<span style="color: #339933;">&gt;</span> getListaDeportes<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> listaDeportes<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> setListaDeportes<span style="color: #009900;">&#40;</span>ArrayList<span style="color: #339933;">&lt;</span>String<span style="color: #339933;">&gt;</span> listaDeportes<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;">listaDeportes</span> <span style="color: #339933;">=</span> listaDeportes<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>Estilo.css</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;
  .cabeceratabla {
   color:#ff2223;
   text-align:center;
  }
&nbsp;
  .pietabla {
   color:#208123;
   text-align:center;
   }</pre></td></tr></table></div>

<p>formulariodeportes.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
</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 prefix<span style="color: #339933;">=</span><span style="color: #0000ff;">&quot;f&quot;</span>  uri<span style="color: #339933;">=</span><span style="color: #0000ff;">&quot;http://java.sun.com/jsf/core&quot;</span><span style="color: #339933;">%&gt;</span>
<span style="color: #339933;">&lt;%</span>@ taglib prefix<span style="color: #339933;">=</span><span style="color: #0000ff;">&quot;h&quot;</span>  uri<span style="color: #339933;">=</span><span style="color: #0000ff;">&quot;http://java.sun.com/jsf/html&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>f<span style="color: #339933;">:</span>view<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> 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>title<span style="color: #339933;">&gt;</span>vistas<span style="color: #339933;">&lt;/</span>title<span style="color: #339933;">&gt;</span>
&nbsp;
<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;</span> Selecciona tus deportes favoritos <span style="color: #339933;">&lt;/</span>h2<span style="color: #339933;">&gt;</span>
&nbsp;
    <span style="color: #339933;">&lt;</span>h<span style="color: #339933;">:</span>form<span style="color: #339933;">&gt;</span>
&nbsp;
     <span style="color: #339933;">&lt;</span>h<span style="color: #339933;">:</span>outputText value<span style="color: #339933;">=</span><span style="color: #0000ff;">&quot;Selecciona tus deportes favoritos&quot;</span><span style="color: #339933;">/&gt;</span>
     <span style="color: #339933;">&lt;</span>br<span style="color: #339933;">/&gt;</span>
&nbsp;
     <span style="color: #339933;">&lt;</span>h<span style="color: #339933;">:</span>selectManyListbox value<span style="color: #339933;">=</span><span style="color: #0000ff;">&quot;#{deportesBean.listaDeportes}&quot;</span><span style="color: #339933;">&gt;</span>
     <span style="color: #339933;">&lt;</span>f<span style="color: #339933;">:</span>selectItem itemValue<span style="color: #339933;">=</span><span style="color: #0000ff;">&quot;baloncesto&quot;</span> itemLabel<span style="color: #339933;">=</span><span style="color: #0000ff;">&quot;baloncesto&quot;</span><span style="color: #339933;">/&gt;</span>
     <span style="color: #339933;">&lt;</span>f<span style="color: #339933;">:</span>selectItem itemValue<span style="color: #339933;">=</span><span style="color: #0000ff;">&quot;balonmano&quot;</span> itemLabel<span style="color: #339933;">=</span><span style="color: #0000ff;">&quot;balonmano&quot;</span><span style="color: #339933;">/&gt;</span>
     <span style="color: #339933;">&lt;</span>f<span style="color: #339933;">:</span>selectItem itemValue<span style="color: #339933;">=</span><span style="color: #0000ff;">&quot;fútbol&quot;</span> itemLabel<span style="color: #339933;">=</span><span style="color: #0000ff;">&quot;fútbol&quot;</span><span style="color: #339933;">/&gt;</span>
&nbsp;
     <span style="color: #339933;">&lt;/</span>h<span style="color: #339933;">:</span>selectManyListbox<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>h<span style="color: #339933;">:</span>commandButton value<span style="color: #339933;">=</span><span style="color: #0000ff;">&quot;enviar&quot;</span> action<span style="color: #339933;">=</span><span style="color: #0000ff;">&quot;deportesaction&quot;</span> styleClass<span style="color: #339933;">=</span><span style="color: #0000ff;">&quot;boton&quot;</span><span style="color: #339933;">/&gt;</span>
&nbsp;
    <span style="color: #339933;">&lt;/</span>h<span style="color: #339933;">:</span>form<span style="color: #339933;">&gt;</span>
&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>
<span style="color: #339933;">&lt;/</span>body<span style="color: #339933;">&gt;</span>
<span style="color: #339933;">&lt;/</span>f<span style="color: #339933;">:</span>view<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><a href="http://www.railsymas.com/wp-content/uploads/2010/07/deportesfor1.png"><img src="http://www.railsymas.com/wp-content/uploads/2010/07/deportesfor1.png" alt="" title="deportesfor" width="580" height="227" class="alignnone size-full wp-image-1803" /></a></p>
<p>Código de resultadodeportes.jsp hacemos referencia en el datatable de los estilos en el header y footer de la tabla</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
</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 prefix<span style="color: #339933;">=</span><span style="color: #0000ff;">&quot;f&quot;</span>  uri<span style="color: #339933;">=</span><span style="color: #0000ff;">&quot;http://java.sun.com/jsf/core&quot;</span><span style="color: #339933;">%&gt;</span>
<span style="color: #339933;">&lt;%</span>@ taglib prefix<span style="color: #339933;">=</span><span style="color: #0000ff;">&quot;h&quot;</span>  uri<span style="color: #339933;">=</span><span style="color: #0000ff;">&quot;http://java.sun.com/jsf/html&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>f<span style="color: #339933;">:</span>view<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;</span>Resultado deportes<span style="color: #339933;">&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>
&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: #339933;">&lt;</span>h2<span style="color: #339933;">&gt;</span> Resultado de Deportes <span style="color: #339933;">&lt;/</span>h2<span style="color: #339933;">&gt;</span>
&nbsp;
  <span style="color: #339933;">&lt;</span>h<span style="color: #339933;">:</span>dataTable styleClass<span style="color: #339933;">=</span><span style="color: #0000ff;">&quot;tabla&quot;</span>  value<span style="color: #339933;">=</span><span style="color: #0000ff;">&quot;#{deportesBean.listaDeportes}&quot;</span> var<span style="color: #339933;">=</span><span style="color: #0000ff;">&quot;deporte&quot;</span> 
   headerClass<span style="color: #339933;">=</span><span style="color: #0000ff;">&quot;cabeceratabla&quot;</span> footerClass<span style="color: #339933;">=</span><span style="color: #0000ff;">&quot;pietabla&quot;</span><span style="color: #339933;">&gt;</span>
  <span style="color: #339933;">&lt;</span>h<span style="color: #339933;">:</span>column<span style="color: #339933;">&gt;</span>
  <span style="color: #339933;">&lt;</span>f<span style="color: #339933;">:</span>facet name<span style="color: #339933;">=</span><span style="color: #0000ff;">&quot;header&quot;</span><span style="color: #339933;">&gt;</span>
   <span style="color: #339933;">&lt;</span>h<span style="color: #339933;">:</span>outputText<span style="color: #339933;">&gt;</span>Listado de Deportes Seleccionados<span style="color: #339933;">&lt;/</span>h<span style="color: #339933;">:</span>outputText<span style="color: #339933;">&gt;</span>
  <span style="color: #339933;">&lt;/</span>f<span style="color: #339933;">:</span>facet<span style="color: #339933;">&gt;</span>
&nbsp;
&nbsp;
  <span style="color: #339933;">&lt;</span>h<span style="color: #339933;">:</span>outputText value<span style="color: #339933;">=</span><span style="color: #0000ff;">&quot;#{deporte}&quot;</span><span style="color: #339933;">/&gt;</span>
&nbsp;
&nbsp;
  <span style="color: #339933;">&lt;</span>f<span style="color: #339933;">:</span>facet name<span style="color: #339933;">=</span><span style="color: #0000ff;">&quot;footer&quot;</span> <span style="color: #339933;">&gt;</span>
   <span style="color: #339933;">&lt;</span>h<span style="color: #339933;">:</span>outputText<span style="color: #339933;">&gt;</span> pie de tabla<span style="color: #339933;">&lt;/</span>h<span style="color: #339933;">:</span>outputText<span style="color: #339933;">&gt;</span>
  <span style="color: #339933;">&lt;/</span>f<span style="color: #339933;">:</span>facet<span style="color: #339933;">&gt;</span>
  <span style="color: #339933;">&lt;/</span>h<span style="color: #339933;">:</span>column<span style="color: #339933;">&gt;</span>  
  <span style="color: #339933;">&lt;/</span>h<span style="color: #339933;">:</span>dataTable<span style="color: #339933;">&gt;</span>
&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>
&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>f<span style="color: #339933;">:</span>view<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>  <a href="http://www.railsymas.com/wp-content/uploads/2010/07/resultatable.png"><img src="http://www.railsymas.com/wp-content/uploads/2010/07/resultatable.png" alt="" title="resultatable" width="580" height="207" class="alignnone size-full wp-image-1800" /></a></p>
<img src="http://feeds.feedburner.com/~r/railsymas/~4/HgCdAmFaM8U" height="1" width="1"/>]]></content:encoded>
			<wfw:commentRss>http://www.railsymas.com/2010/07/10/datatable-estilos-de-tabla/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Simple web mvc spring</title>
		<link>http://www.railsymas.com/2010/07/07/simple-web-mcv-spring/</link>
		<comments>http://www.railsymas.com/2010/07/07/simple-web-mcv-spring/#comments</comments>
		<pubDate>Wed, 07 Jul 2010 18:23:23 +0000</pubDate>
		<dc:creator>admin</dc:creator>
				<category><![CDATA[spring]]></category>

		<guid isPermaLink="false">http://www.railsymas.com/?p=1780</guid>
		<description><![CDATA[Ejemplo en el que vamos a ver algunos detalles sobre el manejo de peticiones además de el tratamiento de los datos bean para recuperarlos desde los controladores y mostrar los valores en la vista de las jsp Código de la página index.jsp 1 2 3 4 5 6 7 8 9 10 11 12 13 [...]]]></description>
			<content:encoded><![CDATA[<p> Ejemplo en el que vamos a ver algunos detalles sobre  el manejo de peticiones además de el tratamiento de los datos bean para recuperarlos desde los controladores y mostrar los valores en la vista de las jsp </p>
<p><span id="more-1780"></span></p>
<p>Código de la página index.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
</pre></td><td class="code"><pre class="java" style="font-family:monospace;">&nbsp;
<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;
&nbsp;
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>
&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>
&nbsp;
<span style="color: #0000ff;">&quot;http://www.w3.org/TR/html4/loose.dtd&quot;</span><span style="color: #339933;">&gt;</span>
&nbsp;
<span style="color: #339933;">&lt;</span>html<span style="color: #339933;">&gt;</span>
&nbsp;
<span style="color: #339933;">&lt;</span>head<span style="color: #339933;">&gt;</span>
&nbsp;
<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>
&nbsp;
<span style="color: #339933;">&lt;</span>title<span style="color: #339933;">&gt;</span>P<span style="color: #339933;">&amp;</span>amp<span style="color: #339933;">;</span>aacute<span style="color: #339933;">;</span>gina de inicio<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>
&nbsp;
<span style="color: #339933;">&lt;</span>body<span style="color: #339933;">&gt;</span>
<span style="color: #339933;">&lt;</span>jsp<span style="color: #339933;">:</span>forward page<span style="color: #339933;">=</span><span style="color: #0000ff;">&quot;holamundo.html&quot;</span><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>Código de la página bienvenida.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
</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>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;</span>bienvenida<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: #009900;">&#123;</span>mensajebienvenida<span style="color: #009900;">&#125;</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>
&nbsp;
      <span style="color: #339933;">&lt;/</span>html<span style="color: #339933;">&gt;</span></pre></td></tr></table></div>

<p>Configuración necesaria para la visualización de las páginas jsp, se añade un prefijo y un sufijo la llamada para nombrebean.html y lo transforma en la correspondiente página jsp, se devuelve el valor holmundo de la propiedad mensaje</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
</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.InternalResourceViewResolver&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;prefix&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;value<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>/WEB-INF/pages/<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;/property<span style="color: #000000; font-weight: bold;">&gt;</span></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: #000000; font-weight: bold;">&gt;</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>.jsp<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;/property<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 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;">name</span>=<span style="color: #ff0000;">&quot;/bienvenida.html&quot;</span> <span style="color: #000066;">class</span>=<span style="color: #ff0000;">&quot;controlador.Controlador&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;Holamundo&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</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
</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>
&nbsp;
<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.mvc.AbstractController</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;">public</span> <span style="color: #000000; font-weight: bold;">class</span> Controlador <span style="color: #000000; font-weight: bold;">extends</span> AbstractController
&nbsp;
<span style="color: #009900;">&#123;</span>
&nbsp;
<span style="color: #000000; font-weight: bold;">private</span> <span style="color: #003399;">String</span> mensaje<span style="color: #339933;">;</span>
<span style="color: #000000; font-weight: bold;">protected</span> ModelAndView handleRequestInternal <span style="color: #009900;">&#40;</span>HttpServletRequest request, HttpServletResponse response<span style="color: #009900;">&#41;</span>
&nbsp;
<span style="color: #000000; font-weight: bold;">throws</span> <span style="color: #003399;">Exception</span>
&nbsp;
<span style="color: #009900;">&#123;</span>
&nbsp;
<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;bienvenida&quot;</span>,<span style="color: #0000ff;">&quot;mensajebienvenida&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>
&nbsp;
<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> 
<span style="color: #009900;">&#125;</span></pre></td></tr></table></div>

<p>Creamos el fichero web.xml donde declaramos el servlet Dispatcher, indicamos además que todas las peticiones *.html sean tratadas por este servlet</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
</pre></td><td class="code"><pre class="java" style="font-family:monospace;"><span style="color: #339933;">&lt;</span>servlet<span style="color: #339933;">&gt;</span>
&nbsp;
<span style="color: #339933;">&lt;</span>servlet<span style="color: #339933;">-</span>name<span style="color: #339933;">&gt;</span>dispatcher<span style="color: #339933;">&lt;/</span>servlet<span style="color: #339933;">-</span>name<span style="color: #339933;">&gt;</span>
&nbsp;
<span style="color: #339933;">&lt;</span>servlet<span style="color: #339933;">-</span>class<span style="color: #339933;">&gt;</span>org.<span style="color: #006633;">springframework</span>.<span style="color: #006633;">web</span>.<span style="color: #006633;">servlet</span>.<span style="color: #006633;">DispatcherServlet</span><span style="color: #339933;">&lt;/</span>servlet<span style="color: #339933;">-</span>class<span style="color: #339933;">&gt;</span>
<span style="color: #339933;">&lt;</span>load<span style="color: #339933;">-</span>on<span style="color: #339933;">-</span>startup<span style="color: #339933;">&gt;</span><span style="color: #cc66cc;">1</span><span style="color: #339933;">&lt;/</span>load<span style="color: #339933;">-</span>on<span style="color: #339933;">-</span>startup<span style="color: #339933;">&gt;</span>
<span style="color: #339933;">&lt;/</span>servlet<span style="color: #339933;">&gt;</span>
&nbsp;
&nbsp;
<span style="color: #339933;">&lt;</span>servlet<span style="color: #339933;">-</span>mapping<span style="color: #339933;">&gt;</span>
<span style="color: #339933;">&lt;</span>servlet<span style="color: #339933;">-</span>name<span style="color: #339933;">&gt;</span>dispatcher<span style="color: #339933;">&lt;/</span>servlet<span style="color: #339933;">-</span>name<span style="color: #339933;">&gt;</span>
<span style="color: #339933;">&lt;</span>url<span style="color: #339933;">-</span>pattern<span style="color: #339933;">&gt;*</span>.<span style="color: #006633;">html</span><span style="color: #339933;">&lt;/</span>url<span style="color: #339933;">-</span>pattern<span style="color: #339933;">&gt;</span>
<span style="color: #339933;">&lt;/</span>servlet<span style="color: #339933;">-</span>mapping<span style="color: #339933;">&gt;</span></pre></td></tr></table></div>

<p><a href="http://www.railsymas.com/wp-content/uploads/2010/07/mensajespring.png"><img src="http://www.railsymas.com/wp-content/uploads/2010/07/mensajespring.png" alt="" title="mensajespring" width="580" height="80" class="alignnone size-full wp-image-1791" /></a></p>
<img src="http://feeds.feedburner.com/~r/railsymas/~4/qf2A-oIrQ8Y" height="1" width="1"/>]]></content:encoded>
			<wfw:commentRss>http://www.railsymas.com/2010/07/07/simple-web-mcv-spring/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Paso de referencias al bean</title>
		<link>http://www.railsymas.com/2010/07/07/paso-de-referencias-al-bean/</link>
		<comments>http://www.railsymas.com/2010/07/07/paso-de-referencias-al-bean/#comments</comments>
		<pubDate>Wed, 07 Jul 2010 13:59:57 +0000</pubDate>
		<dc:creator>admin</dc:creator>
				<category><![CDATA[spring]]></category>

		<guid isPermaLink="false">http://www.railsymas.com/?p=1775</guid>
		<description><![CDATA[A la hora de declarar beans con spring podemos establecer una jerarquía de beans para lo cual necesitamos pasar en los atributos de las declaraciones las referencias a otros bean Interface actividades 1 2 3 4 5 6 7 package tercerejemplo; &#160; public interface Actividades &#123; &#160; public abstract void actividad&#40;&#41;; &#160; &#125; Clase Caminar [...]]]></description>
			<content:encoded><![CDATA[<p> A la hora de declarar beans con spring podemos establecer una jerarquía de beans para lo cual necesitamos<br />
<span id="more-1775"></span><br />
pasar en los atributos de las declaraciones las referencias a otros bean</p>
<p>Interface actividades</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="java" style="font-family:monospace;"><span style="color: #000000; font-weight: bold;">package</span> <span style="color: #006699;">tercerejemplo</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> Actividades <span style="color: #009900;">&#123;</span>
&nbsp;
	<span style="color: #000000; font-weight: bold;">public</span> <span style="color: #000000; font-weight: bold;">abstract</span> <span style="color: #000066; font-weight: bold;">void</span> actividad<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 Caminar</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
</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;">tercerejemplo</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> Caminar <span style="color: #000000; font-weight: bold;">implements</span> Actividades 
<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> Caminar<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;
	<span style="color: #000000; font-weight: bold;">public</span> <span style="color: #000066; font-weight: bold;">void</span> actividad <span style="color: #009900;">&#40;</span><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;">println</span><span style="color: #009900;">&#40;</span>mensaje<span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
	<span style="color: #009900;">&#125;</span>
&nbsp;
&nbsp;
<span style="color: #009900;">&#125;</span></pre></td></tr></table></div>

<p>Clase Hablar</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
</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;">tercerejemplo</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> Hablar <span style="color: #000000; font-weight: bold;">implements</span> Actividades
<span style="color: #009900;">&#123;</span>
   <span style="color: #000000; font-weight: bold;">private</span> <span style="color: #003399;">String</span> palabras<span style="color: #339933;">;</span>
&nbsp;
&nbsp;
   <span style="color: #000000; font-weight: bold;">public</span> Hablar<span style="color: #009900;">&#40;</span><span style="color: #003399;">String</span> palabras<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;">palabras</span> <span style="color: #339933;">=</span> palabras<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> actividad<span style="color: #009900;">&#40;</span><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;">println</span><span style="color: #009900;">&#40;</span><span style="color: #000000; font-weight: bold;">this</span>.<span style="color: #006633;">palabras</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
   <span style="color: #009900;">&#125;</span>
<span style="color: #009900;">&#125;</span></pre></td></tr></table></div>

<p>Clase Medico</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
</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;">tercerejemplo</span><span style="color: #339933;">;</span>
&nbsp;
<span style="color: #000000; font-weight: bold;">import</span> <span style="color: #006699;">java.util.Collection</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> Medico <span style="color: #000000; font-weight: bold;">extends</span> Persona
<span style="color: #009900;">&#123;</span>
&nbsp;
	<span style="color: #000000; font-weight: bold;">private</span> <span style="color: #003399;">Collection</span> <span style="color: #339933;">&lt;</span>Actividades<span style="color: #339933;">&gt;</span> actividades<span style="color: #339933;">;</span>
	<span style="color: #000000; font-weight: bold;">private</span> <span style="color: #003399;">String</span> especialidad<span style="color: #339933;">;</span>
&nbsp;
&nbsp;
	<span style="color: #000000; font-weight: bold;">public</span> Medico <span style="color: #009900;">&#40;</span><span style="color: #003399;">String</span> nombreMedico<span style="color: #009900;">&#41;</span>
	<span style="color: #009900;">&#123;</span>
		<span style="color: #000000; font-weight: bold;">super</span><span style="color: #009900;">&#40;</span>nombreMedico<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> setEspecialidad <span style="color: #009900;">&#40;</span> <span style="color: #003399;">String</span> especialidad<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;">especialidad</span> <span style="color: #339933;">=</span> especialidad<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> setActividades<span style="color: #009900;">&#40;</span>Collection<span style="color: #339933;">&lt;</span>Actividades<span style="color: #339933;">&gt;</span> actividades<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;">actividades</span> <span style="color: #339933;">=</span> actividades<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> datos <span style="color: #009900;">&#40;</span><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;">println</span><span style="color: #009900;">&#40;</span><span style="color: #000000; font-weight: bold;">this</span>.<span style="color: #006633;">nombre</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
		<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: #000000; font-weight: bold;">this</span>.<span style="color: #006633;">especialidad</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
		<span style="color: #000000; font-weight: bold;">this</span>.<span style="color: #006633;">mostrarActividades</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
	<span style="color: #009900;">&#125;</span>
&nbsp;
	<span style="color: #000000; font-weight: bold;">public</span> <span style="color: #000066; font-weight: bold;">void</span> mostrarActividades <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;">for</span> <span style="color: #009900;">&#40;</span> Actividades actividad <span style="color: #339933;">:</span> <span style="color: #000000; font-weight: bold;">this</span>.<span style="color: #006633;">actividades</span>  <span style="color: #009900;">&#41;</span>
		<span style="color: #009900;">&#123;</span>
			<span style="color: #000000; font-weight: bold;">super</span>.<span style="color: #006633;">setActividad</span><span style="color: #009900;">&#40;</span>actividad<span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
			<span style="color: #000000; font-weight: bold;">super</span>.<span style="color: #006633;">actividades</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
		<span style="color: #009900;">&#125;</span>
	<span style="color: #009900;">&#125;</span>
&nbsp;
&nbsp;
<span style="color: #009900;">&#125;</span></pre></td></tr></table></div>

<p>Clase persona</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
</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;">tercerejemplo</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> Persona <span style="color: #009900;">&#123;</span>
&nbsp;
	Actividades actividad<span style="color: #339933;">;</span>
	<span style="color: #003399;">String</span> nombre<span style="color: #339933;">;</span>
&nbsp;
	<span style="color: #000000; font-weight: bold;">public</span> Persona <span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span>
	<span style="color: #009900;">&#123;</span>
&nbsp;
	<span style="color: #009900;">&#125;</span>
&nbsp;
	<span style="color: #000000; font-weight: bold;">public</span> Persona<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>
&nbsp;
	<span style="color: #000000; font-weight: bold;">public</span> <span style="color: #000066; font-weight: bold;">void</span> setActividad<span style="color: #009900;">&#40;</span>Actividades actividad<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;">actividad</span> <span style="color: #339933;">=</span> actividad<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> actividades <span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span>
	<span style="color: #009900;">&#123;</span>   
&nbsp;
		actividad.<span style="color: #006633;">actividad</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
	<span style="color: #009900;">&#125;</span>
&nbsp;
<span style="color: #009900;">&#125;</span></pre></td></tr></table></div>

<p>Clase principal PersonaApp</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
</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;">tercerejemplo</span><span style="color: #339933;">;</span>
&nbsp;
<span style="color: #000000; font-weight: bold;">import</span> <span style="color: #006699;">org.springframework.beans.factory.BeanFactory</span><span style="color: #339933;">;</span>
<span style="color: #000000; font-weight: bold;">import</span> <span style="color: #006699;">org.springframework.beans.factory.xml.XmlBeanFactory</span><span style="color: #339933;">;</span>
&nbsp;
<span style="color: #000000; font-weight: bold;">import</span> <span style="color: #006699;">org.springframework.core.io.Resource</span><span style="color: #339933;">;</span>
<span style="color: #000000; font-weight: bold;">import</span> <span style="color: #006699;">org.springframework.core.io.ClassPathResource</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> PersonaApp <span style="color: #009900;">&#123;</span>
&nbsp;
	<span style="color: #008000; font-style: italic; font-weight: bold;">/**
	 * @param args
	 */</span>
	<span style="color: #000000; font-weight: bold;">public</span> <span style="color: #000000; font-weight: bold;">static</span> <span style="color: #000066; font-weight: bold;">void</span> main<span style="color: #009900;">&#40;</span><span style="color: #003399;">String</span><span style="color: #009900;">&#91;</span><span style="color: #009900;">&#93;</span> args<span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
		<span style="color: #666666; font-style: italic;">// TODO Auto-generated method stub</span>
&nbsp;
&nbsp;
		Resource recurso <span style="color: #339933;">=</span> <span style="color: #000000; font-weight: bold;">new</span> ClassPathResource<span style="color: #009900;">&#40;</span><span style="color: #0000ff;">&quot;Medico.xml&quot;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
&nbsp;
		BeanFactory factoria <span style="color: #339933;">=</span> <span style="color: #000000; font-weight: bold;">new</span> XmlBeanFactory<span style="color: #009900;">&#40;</span>recurso<span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
&nbsp;
		Medico persona <span style="color: #339933;">=</span> <span style="color: #009900;">&#40;</span>Medico<span style="color: #009900;">&#41;</span> factoria.<span style="color: #006633;">getBean</span><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">&quot;medico&quot;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
&nbsp;
&nbsp;
		persona.<span style="color: #006633;">datos</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
&nbsp;
&nbsp;
	<span style="color: #009900;">&#125;</span>
&nbsp;
<span style="color: #009900;">&#125;</span></pre></td></tr></table></div>

<p><a href="http://www.railsymas.com/wp-content/uploads/2010/07/medicore.png"><img src="http://www.railsymas.com/wp-content/uploads/2010/07/medicore.png" alt="" title="medicore" width="264" height="91" class="alignnone size-full wp-image-1793" /></a></p>
<img src="http://feeds.feedburner.com/~r/railsymas/~4/dIvyfPKm_XQ" height="1" width="1"/>]]></content:encoded>
			<wfw:commentRss>http://www.railsymas.com/2010/07/07/paso-de-referencias-al-bean/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Parámetros por nombre spring</title>
		<link>http://www.railsymas.com/2010/07/05/parametros-por-nombre-spring/</link>
		<comments>http://www.railsymas.com/2010/07/05/parametros-por-nombre-spring/#comments</comments>
		<pubDate>Mon, 05 Jul 2010 16:45:02 +0000</pubDate>
		<dc:creator>admin</dc:creator>
				<category><![CDATA[spring]]></category>

		<guid isPermaLink="false">http://www.railsymas.com/?p=1761</guid>
		<description><![CDATA[Ejemplo para la inyección de dependencias en el que se configuran varios beans Ficheros que intervienen en el ejemplo Código de herramienta.java 1 2 3 4 5 6 7 package cuartoejemplo; &#160; public interface Herramienta &#123; &#160; abstract void utilidad&#40;&#41;; &#160; &#125; Código de Martillo.java 1 2 3 4 5 6 7 8 9 10 [...]]]></description>
			<content:encoded><![CDATA[<p>Ejemplo para la inyección de dependencias en el que se configuran varios beans</p>
<p><span id="more-1761"></span></p>
<p>Ficheros que intervienen en el ejemplo</p>
<p><a href="http://www.railsymas.com/wp-content/uploads/2010/07/parametrosjsfn.png"><img src="http://www.railsymas.com/wp-content/uploads/2010/07/parametrosjsfn.png" alt="" title="parametrosjsfn" width="246" height="174" class="alignnone size-full wp-image-1762" /></a></p>
<p>Código de herramienta.java</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="java" style="font-family:monospace;"><span style="color: #000000; font-weight: bold;">package</span> <span style="color: #006699;">cuartoejemplo</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> Herramienta <span style="color: #009900;">&#123;</span>
&nbsp;
	<span style="color: #000000; font-weight: bold;">abstract</span> <span style="color: #000066; font-weight: bold;">void</span> utilidad<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>Código de Martillo.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
16
17
18
19
20
21
22
23
24
</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;">cuartoejemplo</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> Martillo <span style="color: #000000; font-weight: bold;">implements</span>  Herramienta
<span style="color: #009900;">&#123;</span>
&nbsp;
	<span style="color: #000000; font-weight: bold;">private</span> <span style="color: #003399;">String</span> longitud<span style="color: #339933;">;</span>
&nbsp;
	<span style="color: #000000; font-weight: bold;">public</span> Martillo <span style="color: #009900;">&#40;</span><span style="color: #003399;">String</span> longitud<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;">longitud</span> <span style="color: #339933;">=</span> longitud<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> utilidad <span style="color: #009900;">&#40;</span><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;">println</span><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">&quot;Apuntalar cosas&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> getLongitud <span style="color: #009900;">&#40;</span><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;">println</span><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">&quot;La logintud es &quot;</span><span style="color: #339933;">+</span><span style="color: #000000; font-weight: bold;">this</span>.<span style="color: #006633;">longitud</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
	<span style="color: #009900;">&#125;</span>
&nbsp;
&nbsp;
<span style="color: #009900;">&#125;</span></pre></td></tr></table></div>

<p>Código de sierra.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
16
17
18
19
20
21
22
23
</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;">cuartoejemplo</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> Sierra <span style="color: #000000; font-weight: bold;">implements</span> Herramienta<span style="color: #009900;">&#123;</span>
&nbsp;
	<span style="color: #000000; font-weight: bold;">private</span> <span style="color: #003399;">String</span> color<span style="color: #339933;">;</span>
&nbsp;
	<span style="color: #000000; font-weight: bold;">public</span> Sierra<span style="color: #009900;">&#40;</span><span style="color: #003399;">String</span> color<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;">color</span> <span style="color: #339933;">=</span> color<span style="color: #339933;">;</span>
&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> utilidad <span style="color: #009900;">&#40;</span><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;">println</span><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">&quot;Sirve para serrar&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> getColor<span style="color: #009900;">&#40;</span><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;">println</span><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">&quot;Es de color&quot;</span><span style="color: #339933;">+</span><span style="color: #000000; font-weight: bold;">this</span>.<span style="color: #006633;">color</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
	<span style="color: #009900;">&#125;</span>
&nbsp;
<span style="color: #009900;">&#125;</span></pre></td></tr></table></div>

<p>Código de obrero.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
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;">cuartoejemplo</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> Obrero 
<span style="color: #009900;">&#123;</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> Herramienta herramienta<span style="color: #339933;">;</span>
&nbsp;
    <span style="color: #000000; font-weight: bold;">public</span> Obrero <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>
&nbsp;
    <span style="color: #000000; font-weight: bold;">public</span> <span style="color: #000066; font-weight: bold;">void</span> getNombre <span style="color: #009900;">&#40;</span><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;">println</span><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">&quot;nombre: &quot;</span><span style="color: #339933;">+</span><span style="color: #000000; font-weight: bold;">this</span>.<span style="color: #006633;">nombre</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;">public</span> <span style="color: #000066; font-weight: bold;">void</span> setHerramienta <span style="color: #009900;">&#40;</span> Herramienta herramienta<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;">herramienta</span> <span style="color: #339933;">=</span> herramienta<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> getHeramienta <span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span>
    <span style="color: #009900;">&#123;</span>
    	herramienta.<span style="color: #006633;">utilidad</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>
&nbsp;
    <span style="color: #000000; font-weight: bold;">public</span> <span style="color: #000066; font-weight: bold;">void</span> inicio <span style="color: #009900;">&#40;</span><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;">println</span><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">&quot;inicio&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> eliminar<span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span>
    <span style="color: #009900;">&#123;</span>
    	nombre<span style="color: #339933;">=</span><span style="color: #0000ff;">&quot;&quot;</span><span style="color: #339933;">;</span>
        herramienta <span style="color: #339933;">=</span> <span style="color: #000066; font-weight: bold;">null</span><span style="color: #339933;">;</span>
&nbsp;
    <span style="color: #009900;">&#125;</span>
&nbsp;
<span style="color: #009900;">&#125;</span></pre></td></tr></table></div>

<p>Código de obreroapp.java la aplicación principal, donde se obtiene el bean declerado en el fichero obrero.xml, llamamos a al bean trabajador1</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
</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;">cuartoejemplo</span><span style="color: #339933;">;</span>
&nbsp;
<span style="color: #000000; font-weight: bold;">import</span> <span style="color: #006699;">org.springframework.beans.factory.BeanFactory</span><span style="color: #339933;">;</span>
<span style="color: #000000; font-weight: bold;">import</span> <span style="color: #006699;">org.springframework.beans.factory.xml.XmlBeanFactory</span><span style="color: #339933;">;</span>
&nbsp;
<span style="color: #000000; font-weight: bold;">import</span> <span style="color: #006699;">org.springframework.core.io.Resource</span><span style="color: #339933;">;</span>
<span style="color: #000000; font-weight: bold;">import</span> <span style="color: #006699;">org.springframework.core.io.ClassPathResource</span><span style="color: #339933;">;</span>
&nbsp;
&nbsp;
&nbsp;
<span style="color: #000000; font-weight: bold;">public</span> <span style="color: #000000; font-weight: bold;">class</span> ObreroApp <span style="color: #009900;">&#123;</span>
&nbsp;
	<span style="color: #008000; font-style: italic; font-weight: bold;">/**
	 * @param args
	 */</span>
	<span style="color: #000000; font-weight: bold;">public</span> <span style="color: #000000; font-weight: bold;">static</span> <span style="color: #000066; font-weight: bold;">void</span> main<span style="color: #009900;">&#40;</span><span style="color: #003399;">String</span><span style="color: #009900;">&#91;</span><span style="color: #009900;">&#93;</span> args<span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
		<span style="color: #666666; font-style: italic;">// TODO Auto-generated method stub</span>
&nbsp;
		Resource recurso <span style="color: #339933;">=</span> <span style="color: #000000; font-weight: bold;">new</span> ClassPathResource<span style="color: #009900;">&#40;</span><span style="color: #0000ff;">&quot;cuartoejemplo<span style="color: #000099; font-weight: bold;">\\</span>Obrero.xml&quot;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
&nbsp;
		BeanFactory factory <span style="color: #339933;">=</span> <span style="color: #000000; font-weight: bold;">new</span> XmlBeanFactory <span style="color: #009900;">&#40;</span>recurso<span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
&nbsp;
		Obrero obrero   <span style="color: #339933;">=</span> <span style="color: #009900;">&#40;</span>Obrero<span style="color: #009900;">&#41;</span> factory.<span style="color: #006633;">getBean</span> <span style="color: #009900;">&#40;</span><span style="color: #0000ff;">&quot;trabajador1&quot;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
&nbsp;
		obrero.<span style="color: #006633;">getNombre</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
&nbsp;
		obrero.<span style="color: #006633;">getHeramienta</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;
<span style="color: #009900;">&#125;</span></pre></td></tr></table></div>

<p>Código de Obrero.xml, se pueden declarar los métodos de inicio y de destroy que se ejecutan al comienzo y al final de la vida del objeto. </p>
<p>Con el atributo id, establecemos el identificador para hacer uso de el en el programa principal. El atributo class establecemos la relación con el path a la clase, tiene como constructor el valor de obrero1</p>
<p>El bean herramienta declara un valor para el constructor de la clase con el valor de rojo</p>
<p>En el bean trabajodor1 tenemos el atributo autowire con el valor byname, estamos indicando una conexión automática del bean por nombre, de tal forma que se hace coincidir el valor de una propiedad con un bean del mismo nombre en este caso herramienta sin tener que pasar la referencia explicita del bean herramienta en trabajador1</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
</pre></td><td class="code"><pre class="java" style="font-family:monospace;"><span style="color: #339933;">&lt;?</span>xml version<span style="color: #339933;">=</span><span style="color: #0000ff;">&quot;1.0&quot;</span> encoding<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>beans xmlns<span style="color: #339933;">=</span><span style="color: #0000ff;">&quot;http://www.springframework.org/schema/beans&quot;</span>
	xmlns<span style="color: #339933;">:</span>xsi<span style="color: #339933;">=</span><span style="color: #0000ff;">&quot;http://www.w3.org/2001/XMLSchema-instance&quot;</span>
	xsi<span style="color: #339933;">:</span>schemaLocation<span style="color: #339933;">=</span><span style="color: #0000ff;">&quot;http://www.springframework.org/schema/beans 
	http://www.springframework.org/schema/beans/spring-beans.xsd&quot;</span><span style="color: #339933;">&gt;</span>
&nbsp;
    <span style="color: #339933;">&lt;</span>bean id<span style="color: #339933;">=</span><span style="color: #0000ff;">&quot;herramienta&quot;</span> <span style="color: #000000; font-weight: bold;">class</span><span style="color: #339933;">=</span><span style="color: #0000ff;">&quot;cuartoejemplo.Sierra&quot;</span><span style="color: #339933;">&gt;</span>
       <span style="color: #339933;">&lt;</span>constructor<span style="color: #339933;">-</span>arg value<span style="color: #339933;">=</span><span style="color: #0000ff;">&quot;rojo&quot;</span><span style="color: #339933;">/&gt;</span>            
    <span style="color: #339933;">&lt;/</span>bean<span style="color: #339933;">&gt;</span>
&nbsp;
    <span style="color: #339933;">&lt;</span>bean id<span style="color: #339933;">=</span><span style="color: #0000ff;">&quot;trabajador1&quot;</span> <span style="color: #000000; font-weight: bold;">class</span><span style="color: #339933;">=</span><span style="color: #0000ff;">&quot;cuartoejemplo.Obrero&quot;</span> autowire<span style="color: #339933;">=</span><span style="color: #0000ff;">&quot;byName&quot;</span>
      init<span style="color: #339933;">-</span>method<span style="color: #339933;">=</span><span style="color: #0000ff;">&quot;inicio&quot;</span>
      destroy<span style="color: #339933;">-</span>method<span style="color: #339933;">=</span><span style="color: #0000ff;">&quot;eliminar&quot;</span>           
     <span style="color: #339933;">&gt;</span>       
&nbsp;
    <span style="color: #339933;">&lt;</span>constructor<span style="color: #339933;">-</span>arg value<span style="color: #339933;">=</span><span style="color: #0000ff;">&quot;obrero1&quot;</span><span style="color: #339933;">/&gt;</span>       
&nbsp;
    <span style="color: #339933;">&lt;/</span>bean<span style="color: #339933;">&gt;</span>
&nbsp;
<span style="color: #339933;">&lt;/</span>beans<span style="color: #339933;">&gt;</span></pre></td></tr></table></div>

<p>Resultado </p>
<p><a href="http://www.railsymas.com/wp-content/uploads/2010/07/ejemplosierra.png"><img src="http://www.railsymas.com/wp-content/uploads/2010/07/ejemplosierra.png" alt="" title="ejemplosierra" width="218" height="78" class="alignnone size-full wp-image-1769" /></a></p>
<img src="http://feeds.feedburner.com/~r/railsymas/~4/QqAzSYvc3eQ" height="1" width="1"/>]]></content:encoded>
			<wfw:commentRss>http://www.railsymas.com/2010/07/05/parametros-por-nombre-spring/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>
