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

<channel>
	<title>Blog de sergio &#187; Struts2</title>
	<atom:link href="http://www.serunix.com/tag/struts2/feed" rel="self" type="application/rss+xml" />
	<link>http://www.serunix.com</link>
	<description>&#34;Un informático que sólo quiere ayudar... &#34;</description>
	<lastBuildDate>Sun, 04 Sep 2011 19:34:04 +0000</lastBuildDate>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.3.1</generator>
		<item>
		<title>leer una Key  de un archivo .properties desde un Action&#8230;</title>
		<link>http://www.serunix.com/2009/05/27/leer-una-key-de-un-archivo-properties-desde-un-action</link>
		<comments>http://www.serunix.com/2009/05/27/leer-una-key-de-un-archivo-properties-desde-un-action#comments</comments>
		<pubDate>Wed, 27 May 2009 07:55:43 +0000</pubDate>
		<dc:creator>sergio</dc:creator>
				<category><![CDATA[Java]]></category>
		<category><![CDATA[Struts2]]></category>

		<guid isPermaLink="false">http://www.serunix.com/?p=366</guid>
		<description><![CDATA[Pues es algo super básico pero nunca esta de más&#8230; aunque hay muchas formas de hacerlos&#8230; aquí les poco un opción&#8230; File Application.properties 1 2 login.username=Nombre login.password=Contraseña y desde el Action 1 2 MessageResources messageResources = getResources&#40;request&#41;; String username = messageResources.getMessage&#40;&#34;login.username&#34;&#41;; y listo&#8230;]]></description>
			<content:encoded><![CDATA[<p>Pues es algo super básico pero nunca esta de más&#8230; aunque hay muchas formas de hacerlos&#8230; aquí les poco un opción&#8230;<br />
File Application.properties</p>

<div class="wp_syntax"><table><tr><td class="line_numbers"><pre>1
2
</pre></td><td class="code"><pre class="html4strict" style="font-family:monospace;">login.username=Nombre
login.password=Contraseña</pre></td></tr></table></div>

<p>y desde el Action</p>

<div class="wp_syntax"><table><tr><td class="line_numbers"><pre>1
2
</pre></td><td class="code"><pre class="java" style="font-family:monospace;"> MessageResources messageResources <span style="color: #339933;">=</span> getResources<span style="color: #009900;">&#40;</span>request<span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
 <span style="color: #003399;">String</span> username <span style="color: #339933;">=</span> messageResources.<span style="color: #006633;">getMessage</span><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">&quot;login.username&quot;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span></pre></td></tr></table></div>

<p>y listo&#8230; </p>
<div class="thanks_button_div" style="float: left; margin-right: 10px;"><div style="float: left; display: inline;"><input type="button" onclick="thankYouButtonClick(366, 'You left &ldquo;Thanks&rdquo; already for this post')" value="Thank You: 0"
                class="thanks_button thanks_custom_button "
                style="background-image:url(http://b.static.ak.fbcdn.net/rsrc.php/yp/r/qDH1xoDhFBF.gif);width:15px; height:13px; font-family: Verdana, Arial, Sans-Serif; font-size: 14px; font-weight: normal;; color:#ffffff;"
                id="thanksButton_366_2" title="Click to left &ldquo;Thanks&rdquo; for this post"/></div><div id="ajax_loader_366_2" style="display:inline;visibility: hidden;"><img alt="ajax loader" src="http://www.serunix.com/wp-content/plugins/thanks-you-counter-button/images/ajax-loader.gif" /></div></div>]]></content:encoded>
			<wfw:commentRss>http://www.serunix.com/2009/05/27/leer-una-key-de-un-archivo-properties-desde-un-action/feed</wfw:commentRss>
		<slash:comments>1</slash:comments>
		</item>
		<item>
		<title>Utilizar archivos JSPF dentro de un proyecto en struts&#8230;</title>
		<link>http://www.serunix.com/2009/05/13/utilizar-archivos-jspf-dentro-de-un-proyecto-en-struts</link>
		<comments>http://www.serunix.com/2009/05/13/utilizar-archivos-jspf-dentro-de-un-proyecto-en-struts#comments</comments>
		<pubDate>Wed, 13 May 2009 07:04:19 +0000</pubDate>
		<dc:creator>sergio</dc:creator>
				<category><![CDATA[Java]]></category>
		<category><![CDATA[Programación]]></category>
		<category><![CDATA[Struts2]]></category>

		<guid isPermaLink="false">http://www.serunix.com/?p=322</guid>
		<description><![CDATA[No había trabajado don este tipo de archivos, pero realmente tiene la misma estructura que un archivo Jsp&#8230; pero no diferencia ya que los archivos JSPF utilizan los mismos Tags y además de que son muy utilizado para para organizar mejor las partes en que esta separado nuestro sistema , por ejemplo: header, body y [...]]]></description>
			<content:encoded><![CDATA[<p>No había trabajado don este tipo de archivos, pero realmente tiene la misma estructura que un archivo Jsp&#8230; pero no diferencia ya que los archivos JSPF utilizan los mismos Tags y además de que son muy utilizado para para organizar mejor las partes en que esta separado nuestro sistema , por ejemplo: header, body y footer.<br />
aquí un ejemplo:</p>

<div class="wp_syntax"><div class="code"><pre class="html4strict" style="font-family:monospace;"><span style="color: #009900;">&lt;%@ taglib uri<span style="color: #66cc66;">=</span><span style="color: #ff0000;">&quot;/WEB-INF/struts-bean.tld&quot;</span> prefix<span style="color: #66cc66;">=</span><span style="color: #ff0000;">&quot;bean&quot;</span>%&gt;</span>
<span style="color: #009900;">&lt;%@ taglib uri<span style="color: #66cc66;">=</span><span style="color: #ff0000;">&quot;/WEB-INF/struts-html.tld&quot;</span> prefix<span style="color: #66cc66;">=</span><span style="color: #ff0000;">&quot;html&quot;</span>%&gt;</span>
<span style="color: #009900;">&lt;%@ taglib uri<span style="color: #66cc66;">=</span><span style="color: #ff0000;">&quot;/WEB-INF/struts-logic.tld&quot;</span> prefix<span style="color: #66cc66;">=</span><span style="color: #ff0000;">&quot;logic&quot;</span>%&gt;</span>
<span style="color: #009900;">&lt;<span style="color: #000000; font-weight: bold;">div</span> <span style="color: #000066;">id</span><span style="color: #66cc66;">=</span><span style="color: #ff0000;">&quot;footer&quot;</span>&gt;</span>
<span style="color: #009900;">&lt;<span style="color: #66cc66;">/</span><span style="color: #000000; font-weight: bold;">div</span>&gt;</span></pre></div></div>

<div class="thanks_button_div" style="float: left; margin-right: 10px;"><div style="float: left; display: inline;"><input type="button" onclick="thankYouButtonClick(322, 'You left &ldquo;Thanks&rdquo; already for this post')" value="Thank You: 0"
                class="thanks_button thanks_custom_button "
                style="background-image:url(http://b.static.ak.fbcdn.net/rsrc.php/yp/r/qDH1xoDhFBF.gif);width:15px; height:13px; font-family: Verdana, Arial, Sans-Serif; font-size: 14px; font-weight: normal;; color:#ffffff;"
                id="thanksButton_322_2" title="Click to left &ldquo;Thanks&rdquo; for this post"/></div><div id="ajax_loader_322_2" style="display:inline;visibility: hidden;"><img alt="ajax loader" src="http://www.serunix.com/wp-content/plugins/thanks-you-counter-button/images/ajax-loader.gif" /></div></div>]]></content:encoded>
			<wfw:commentRss>http://www.serunix.com/2009/05/13/utilizar-archivos-jspf-dentro-de-un-proyecto-en-struts/feed</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Problemas con búsquedas dinámicas en struts2&#8230; utilizando &#8220;chain&#8221; y enviando los resultados al mismo Action donde se encuentra el formulario (filtro de búsqueda en la Jsp)&#8230;</title>
		<link>http://www.serunix.com/2009/04/27/problemas-con-busquedas-dinamicas-en-struts2-utilizando-chain-y-enviando-los-resultados-al-mismo-action-donde-se-encuentra-el-formulario-filtro-de-busqueda-en-la-jsp-2</link>
		<comments>http://www.serunix.com/2009/04/27/problemas-con-busquedas-dinamicas-en-struts2-utilizando-chain-y-enviando-los-resultados-al-mismo-action-donde-se-encuentra-el-formulario-filtro-de-busqueda-en-la-jsp-2#comments</comments>
		<pubDate>Mon, 27 Apr 2009 06:53:43 +0000</pubDate>
		<dc:creator>sergio</dc:creator>
				<category><![CDATA[Java]]></category>
		<category><![CDATA[Programación]]></category>
		<category><![CDATA[Struts2]]></category>

		<guid isPermaLink="false">http://www.serunix.com/?p=313</guid>
		<description><![CDATA[Así es, teníamos un Action para mostrar el formulario de búsqueda y al dar Submit.. se enviaba a otro Action en donde obtenía los datos y se formaba el list y este mostraba los datos en la misma Jsp&#8230; en conclución&#8230; No podíamos meter el resultado en el tiles (para agregar el header y footer) [...]]]></description>
			<content:encoded><![CDATA[<p>Así es,  teníamos un <em>Action </em>para mostrar el formulario de búsqueda y al dar <em>Submit</em>.. se enviaba a otro <em>Action</em> en donde obtenía los datos y se formaba el <em>list</em> y este  mostraba los datos en la misma Jsp&#8230;  en conclución&#8230; No podíamos meter el resultado en el <em>tiles </em>(para agregar el <em>header </em>y <em>footer</em>) ya que cuando lo hacíamos se perdían los datos&#8230; y la Jsp  se mostraba sin <em>header </em>y <em>footer</em>&#8230; antes estaba así:</p>

<div class="wp_syntax"><table><tr><td class="line_numbers"><pre>1
2
3
4
5
6
7
8
9
</pre></td><td class="code"><pre class="html4strict" style="font-family:monospace;"><span style="color: #009900;">&lt;action <span style="color: #000066;">name</span><span style="color: #66cc66;">=</span><span style="color: #ff0000;">&quot;searchBooks&quot;</span> <span style="color: #000066;">class</span><span style="color: #66cc66;">=</span><span style="color: #ff0000;">&quot;com.mycompany.SearchBooksAction&quot;</span> <span style="color: #000066;">method</span><span style="color: #66cc66;">=</span><span style="color: #ff0000;">&quot;search&quot;</span>&gt;</span>
         <span style="color: #009900;">&lt;result <span style="color: #000066;">type</span><span style="color: #66cc66;">=</span><span style="color: #ff0000;">&quot;chain&quot;</span>&gt;</span>listaBooks.action<span style="color: #009900;">&lt;<span style="color: #66cc66;">/</span>result&gt;</span>
         <span style="color: #009900;">&lt;result <span style="color: #000066;">name</span><span style="color: #66cc66;">=</span><span style="color: #ff0000;">&quot;chain&quot;</span>&gt;</span>/error.jsp<span style="color: #009900;">&lt;<span style="color: #66cc66;">/</span>result&gt;</span>
<span style="color: #009900;">&lt;<span style="color: #66cc66;">/</span>action&gt;</span>
&nbsp;
<span style="color: #009900;">&lt;action <span style="color: #000066;">name</span><span style="color: #66cc66;">=</span><span style="color: #ff0000;">&quot;listaBooks&quot;</span> <span style="color: #000066;">class</span><span style="color: #66cc66;">=</span><span style="color: #ff0000;">&quot;com.mycompany.SearchBooksAction&quot;</span>  <span style="color: #000066;">method</span><span style="color: #66cc66;">=</span><span style="color: #ff0000;">&quot;list&quot;</span>&gt;</span> 
&nbsp;
        <span style="color: #009900;">&lt;result &gt;</span>searchbook.jsp<span style="color: #009900;">&lt;<span style="color: #66cc66;">/</span>result&gt;</span>
<span style="color: #009900;">&lt;<span style="color: #66cc66;">/</span>action&gt;</span></pre></td></tr></table></div>

<p>Donde  searchbook.jsp lo utilizábamos para mostrar el formulario&#8230; en fin&#8230; un compañero lo resolvió de la siguiente forma: </p>
<p>En el web.xml hay que agregar:</p>

<div class="wp_syntax"><table><tr><td class="line_numbers"><pre>1
2
3
4
</pre></td><td class="code"><pre class="html4strict" style="font-family:monospace;"><span style="color: #009900;">&lt;filter&gt;</span>
      <span style="color: #009900;">&lt;filter-name&gt;</span>struts-cleanup<span style="color: #009900;">&lt;<span style="color: #66cc66;">/</span>filter-name&gt;</span>
      <span style="color: #009900;">&lt;filter-class&gt;</span>org.apache.struts2.dispatcher.ActionContextCleanUp<span style="color: #009900;">&lt;<span style="color: #66cc66;">/</span>filter-class&gt;</span>
<span style="color: #009900;">&lt;<span style="color: #66cc66;">/</span>filter&gt;</span></pre></td></tr></table></div>

<p>Y listo!!! con esto ya se puede direccionar la Jsp al <em>tiles </em>sin que si pierda el resultado y se pueda manterner en session.</p>

<div class="wp_syntax"><table><tr><td class="line_numbers"><pre>1
2
3
4
5
6
7
8
9
</pre></td><td class="code"><pre class="html4strict" style="font-family:monospace;"><span style="color: #009900;">&lt;action <span style="color: #000066;">name</span><span style="color: #66cc66;">=</span><span style="color: #ff0000;">&quot;searchBooks&quot;</span> <span style="color: #000066;">class</span><span style="color: #66cc66;">=</span><span style="color: #ff0000;">&quot;com.mycompany.SearchBooksAction&quot;</span> <span style="color: #000066;">method</span><span style="color: #66cc66;">=</span><span style="color: #ff0000;">&quot;search&quot;</span>&gt;</span>
         <span style="color: #009900;">&lt;result <span style="color: #000066;">type</span><span style="color: #66cc66;">=</span><span style="color: #ff0000;">&quot;chain&quot;</span>&gt;</span>listaBooks.action<span style="color: #009900;">&lt;<span style="color: #66cc66;">/</span>result&gt;</span>
         <span style="color: #009900;">&lt;result <span style="color: #000066;">name</span><span style="color: #66cc66;">=</span><span style="color: #ff0000;">&quot;chain&quot;</span>&gt;</span>/error.jsp<span style="color: #009900;">&lt;<span style="color: #66cc66;">/</span>result&gt;</span>
<span style="color: #009900;">&lt;<span style="color: #66cc66;">/</span>action&gt;</span>
&nbsp;
<span style="color: #009900;">&lt;action <span style="color: #000066;">name</span><span style="color: #66cc66;">=</span><span style="color: #ff0000;">&quot;listaBooks&quot;</span> <span style="color: #000066;">class</span><span style="color: #66cc66;">=</span><span style="color: #ff0000;">&quot;com.mycompany.SearchBooksAction&quot;</span>  <span style="color: #000066;">method</span><span style="color: #66cc66;">=</span><span style="color: #ff0000;">&quot;list&quot;</span>&gt;</span> 
&nbsp;
        <span style="color: #009900;">&lt;result <span style="color: #000066;">type</span><span style="color: #66cc66;">=</span><span style="color: #ff0000;">&quot;tiles&quot;</span>&gt;</span>searchbook.jsp<span style="color: #009900;">&lt;<span style="color: #66cc66;">/</span>result&gt;</span>
<span style="color: #009900;">&lt;<span style="color: #66cc66;">/</span>action&gt;</span></pre></td></tr></table></div>

<div class="thanks_button_div" style="float: left; margin-right: 10px;"><div style="float: left; display: inline;"><input type="button" onclick="thankYouButtonClick(313, 'You left &ldquo;Thanks&rdquo; already for this post')" value="Thank You: 0"
                class="thanks_button thanks_custom_button "
                style="background-image:url(http://b.static.ak.fbcdn.net/rsrc.php/yp/r/qDH1xoDhFBF.gif);width:15px; height:13px; font-family: Verdana, Arial, Sans-Serif; font-size: 14px; font-weight: normal;; color:#ffffff;"
                id="thanksButton_313_2" title="Click to left &ldquo;Thanks&rdquo; for this post"/></div><div id="ajax_loader_313_2" style="display:inline;visibility: hidden;"><img alt="ajax loader" src="http://www.serunix.com/wp-content/plugins/thanks-you-counter-button/images/ajax-loader.gif" /></div></div>]]></content:encoded>
			<wfw:commentRss>http://www.serunix.com/2009/04/27/problemas-con-busquedas-dinamicas-en-struts2-utilizando-chain-y-enviando-los-resultados-al-mismo-action-donde-se-encuentra-el-formulario-filtro-de-busqueda-en-la-jsp-2/feed</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>sobre escribir el mensaje de error que muestra por default struts2&#8230; Invalid field value for field &#8220;{0}&#8221; en struts2</title>
		<link>http://www.serunix.com/2009/03/25/sobre-escribir-el-mensaje-de-error-que-muestra-por-default-struts-2-invalid-field-value-for-field-0-en-struts2</link>
		<comments>http://www.serunix.com/2009/03/25/sobre-escribir-el-mensaje-de-error-que-muestra-por-default-struts-2-invalid-field-value-for-field-0-en-struts2#comments</comments>
		<pubDate>Wed, 25 Mar 2009 18:45:36 +0000</pubDate>
		<dc:creator>sergio</dc:creator>
				<category><![CDATA[Java]]></category>
		<category><![CDATA[Programación]]></category>
		<category><![CDATA[Struts2]]></category>

		<guid isPermaLink="false">http://www.serunix.com/?p=274</guid>
		<description><![CDATA[Para poder sobre escribir el mensaje de error que se muestra por default por xwork.default.invalid.fieldvalue (Invalid field value for field &#8220;nombre_campo&#8221;) por no hacer el manejo de la validación del campo o por otras desconocidas jajajaja causas, se puede realizar de dos formas: 1.- Utilizar el validador que viene por default en Struts2 nombre-validation.xml (si [...]]]></description>
			<content:encoded><![CDATA[<p>Para poder sobre escribir el mensaje de error que se muestra por <em>default</em> por <em>xwork.default.invalid.fieldvalue</em> (Invalid field value for field &#8220;nombre_campo&#8221;) por no hacer el manejo de la validación del campo o por otras <del datetime="2009-03-25T18:37:01+00:00">desconocidas jajajaja</del> causas, se puede realizar de dos formas:</p>
<p>1.- Utilizar el validador que viene por <em>default</em> en Struts2 nombre-<em>validation.xml</em> (si ya fallo este intento&#8230; pasar al paso 3)<br />
2.- Realizar la validación mediante  Java. (Sí también ha fallado este intento)<br />
3.- Declarar esta propiedad en los archivos <em>properties</em> que se estén utilizando (<em>invalid.fieldvalue.</em>NOMBRE_CAMPO)</p>
<p>Un ejemplo:<br />
En la jsp:</p>

<div class="wp_syntax"><table><tr><td class="line_numbers"><pre>1
2
3
4
5
6
7
8
</pre></td><td class="code"><pre class="html4strict" style="font-family:monospace;">  <span style="color: #009900;">&lt;s:date</span>
<span style="color: #009900;">     <span style="color: #000066;">name</span><span style="color: #66cc66;">=</span><span style="color: #ff0000;">&quot;date&quot;</span></span>
<span style="color: #009900;">     format<span style="color: #66cc66;">=</span><span style="color: #ff0000;">&quot;dd/mm/aaaa&quot;</span></span>
<span style="color: #009900;">     <span style="color: #000066;">id</span><span style="color: #66cc66;">=</span><span style="color: #ff0000;">&quot;date.formatted&quot;</span> <span style="color: #66cc66;">/</span>&gt;</span>
  <span style="color: #009900;">&lt;s:textfield <span style="color: #000066;">name</span><span style="color: #66cc66;">=</span><span style="color: #ff0000;">&quot;date&quot;</span> </span>
<span style="color: #009900;">     <span style="color: #000066;">label</span><span style="color: #66cc66;">=</span><span style="color: #ff0000;">&quot;Date&quot;</span></span>
<span style="color: #009900;">     required<span style="color: #66cc66;">=</span><span style="color: #ff0000;">&quot;true&quot;</span></span>
<span style="color: #009900;">     <span style="color: #000066;">value</span><span style="color: #66cc66;">=</span><span style="color: #ff0000;">&quot;%{date.formatted}&quot;</span> <span style="color: #66cc66;">/</span>&gt;</span></pre></td></tr></table></div>

<p>Si el campo no es correcto podría mostrar el siguiente mensaje de error:</p>

<div class="wp_syntax"><table><tr><td class="line_numbers"><pre>1
</pre></td><td class="code"><pre class="html4strict" style="font-family:monospace;">  Invalid field value for field &quot;date&quot;.</pre></td></tr></table></div>

<p>Así que podemos cambiar el mensaje declarando esa propiedad en los <em>archivos.properties</em>:</p>

<div class="wp_syntax"><table><tr><td class="line_numbers"><pre>1
</pre></td><td class="code"><pre class="html4strict" style="font-family:monospace;">invalid.fieldvalue.NOMBRE_CAMPO=Fecha invalida</pre></td></tr></table></div>

<p>con lo cual, para el ejemplo anterior quedaría así:</p>

<div class="wp_syntax"><table><tr><td class="line_numbers"><pre>1
</pre></td><td class="code"><pre class="html4strict" style="font-family:monospace;">invalid.fieldvalue.date=Fecha inválida</pre></td></tr></table></div>

<p>y listo&#8230; el texto es cambiado!!!!!</p>
<div class="thanks_button_div" style="float: left; margin-right: 10px;"><div style="float: left; display: inline;"><input type="button" onclick="thankYouButtonClick(274, 'You left &ldquo;Thanks&rdquo; already for this post')" value="Thank You: 0"
                class="thanks_button thanks_custom_button "
                style="background-image:url(http://b.static.ak.fbcdn.net/rsrc.php/yp/r/qDH1xoDhFBF.gif);width:15px; height:13px; font-family: Verdana, Arial, Sans-Serif; font-size: 14px; font-weight: normal;; color:#ffffff;"
                id="thanksButton_274_2" title="Click to left &ldquo;Thanks&rdquo; for this post"/></div><div id="ajax_loader_274_2" style="display:inline;visibility: hidden;"><img alt="ajax loader" src="http://www.serunix.com/wp-content/plugins/thanks-you-counter-button/images/ajax-loader.gif" /></div></div>]]></content:encoded>
			<wfw:commentRss>http://www.serunix.com/2009/03/25/sobre-escribir-el-mensaje-de-error-que-muestra-por-default-struts-2-invalid-field-value-for-field-0-en-struts2/feed</wfw:commentRss>
		<slash:comments>3</slash:comments>
		</item>
		<item>
		<title>Una  forma  de direccionar parámetros por medio de la URL en Struts 2&#8230; &lt;rediect-action&gt;&lt;param&gt;&#8230;</title>
		<link>http://www.serunix.com/2009/03/18/una-forma-de-direccionar-parametros-por-medio-de-la-url-en-struts-2%e2%80%a6-rediect-actionparam%e2%80%a6</link>
		<comments>http://www.serunix.com/2009/03/18/una-forma-de-direccionar-parametros-por-medio-de-la-url-en-struts-2%e2%80%a6-rediect-actionparam%e2%80%a6#comments</comments>
		<pubDate>Wed, 18 Mar 2009 14:33:25 +0000</pubDate>
		<dc:creator>sergio</dc:creator>
				<category><![CDATA[Google]]></category>
		<category><![CDATA[Programación]]></category>
		<category><![CDATA[Struts2]]></category>

		<guid isPermaLink="false">http://www.serunix.com/?p=249</guid>
		<description><![CDATA[Cuando tienes un formulario de búsqueda o una actualización y necesitas hacer los ver los cambios&#8230; y además que la JSP muestre los resultados ya actualizados&#8230; pues hay dos problemas&#8230; que para mostrar la consulta de resultados pues seguramente esta en un Action y otra que la modificación este en otro&#8230; pero aunque este en [...]]]></description>
			<content:encoded><![CDATA[<p>Cuando tienes un formulario de búsqueda  o una actualización y necesitas hacer los ver los cambios&#8230; y además que la JSP muestre los resultados ya actualizados&#8230; pues hay dos problemas&#8230; que para mostrar la consulta de resultados pues seguramente esta en un Action y otra que la modificación este en otro&#8230; pero aunque este en el mismo no podrías recibir los mismo parámetros del formulario&#8230; </p>
<p>Entonces se podría hacer esto:</p>
<p>Supongamos que este Action es el que muestra los alumnos de un filtro de una búsqueda: </p>
<p>JSP de búsqueda:</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="html4strict" style="font-family:monospace;"><span style="color: #009900;">&lt;s:form <span style="color: #000066;">action</span><span style="color: #66cc66;">=</span><span style="color: #ff0000;">&quot;buscaAlumnos&quot;</span> <span style="color: #000066;">method</span><span style="color: #66cc66;">=</span><span style="color: #ff0000;">&quot;post&quot;</span>&gt;</span>
            <span style="color: #009900;">&lt;s:textfield <span style="color: #000066;">name</span><span style="color: #66cc66;">=</span><span style="color: #ff0000;">&quot;name&quot;</span> </span>
<span style="color: #009900;">                cssClass<span style="color: #66cc66;">=</span><span style="color: #ff0000;">&quot;textInput&quot;</span> </span>
<span style="color: #009900;">                <span style="color: #000066;">maxlength</span><span style="color: #66cc66;">=</span><span style="color: #ff0000;">&quot;50&quot;</span> <span style="color: #000066;">size</span><span style="color: #66cc66;">=</span><span style="color: #ff0000;">&quot;20&quot;</span></span>
<span style="color: #009900;">                <span style="color: #000066;">label</span><span style="color: #66cc66;">=</span><span style="color: #ff0000;">&quot;Name&quot;</span></span>
<span style="color: #009900;">                required<span style="color: #66cc66;">=</span><span style="color: #ff0000;">&quot;false&quot;</span> <span style="color: #66cc66;">/</span>&gt;</span>
&nbsp;
            <span style="color: #009900;">&lt;s:textfield <span style="color: #000066;">name</span><span style="color: #66cc66;">=</span><span style="color: #ff0000;">&quot;lastname&quot;</span> </span>
<span style="color: #009900;">                cssClass<span style="color: #66cc66;">=</span><span style="color: #ff0000;">&quot;textInput&quot;</span> </span>
<span style="color: #009900;">                <span style="color: #000066;">maxlength</span><span style="color: #66cc66;">=</span><span style="color: #ff0000;">&quot;150&quot;</span> <span style="color: #000066;">size</span><span style="color: #66cc66;">=</span><span style="color: #ff0000;">&quot;30&quot;</span></span>
<span style="color: #009900;">                <span style="color: #000066;">label</span><span style="color: #66cc66;">=</span><span style="color: #ff0000;">&quot;Lastname&quot;</span></span>
<span style="color: #009900;">                required<span style="color: #66cc66;">=</span><span style="color: #ff0000;">&quot;false&quot;</span> <span style="color: #66cc66;">/</span>&gt;</span>
<span style="color: #009900;">&lt;<span style="color: #66cc66;">/</span>s:form&gt;</span></pre></td></tr></table></div>

<p>Action que procesa la búsqueda y que se le envían los parámetros anteriores:</p>

<div class="wp_syntax"><table><tr><td class="line_numbers"><pre>1
2
3
4
</pre></td><td class="code"><pre class="html4strict" style="font-family:monospace;"><span style="color: #009900;">&lt;action <span style="color: #000066;">name</span><span style="color: #66cc66;">=</span><span style="color: #ff0000;">&quot;buscaAlumnos&quot;</span> <span style="color: #000066;">class</span><span style="color: #66cc66;">=</span><span style="color: #ff0000;">&quot;com.buscar&quot;</span> <span style="color: #000066;">method</span><span style="color: #66cc66;">=</span><span style="color: #ff0000;">&quot;buscar&quot;</span>&gt;</span>
     <span style="color: #009900;">&lt;result <span style="color: #000066;">type</span><span style="color: #66cc66;">=</span><span style="color: #ff0000;">&quot;chain&quot;</span>&gt;</span>listaAlumnos<span style="color: #009900;">&lt;<span style="color: #66cc66;">/</span>result&gt;</span>
     <span style="color: #009900;">&lt;result <span style="color: #000066;">name</span><span style="color: #66cc66;">=</span><span style="color: #ff0000;">&quot;error&quot;</span>&gt;</span> errorBuscar<span style="color: #009900;">&lt;<span style="color: #66cc66;">/</span>result&gt;</span>
<span style="color: #009900;">&lt;<span style="color: #66cc66;">/</span>action&gt;</span></pre></td></tr></table></div>

<p>En el JSP que muestra los resultados, colocamos un link para poder borrar a un usuario:</p>

<div class="wp_syntax"><table><tr><td class="line_numbers"><pre>1
2
3
4
5
</pre></td><td class="code"><pre class="html4strict" style="font-family:monospace;"><span style="color: #009900;">&lt;s:url <span style="color: #000066;">id</span><span style="color: #66cc66;">=</span><span style="color: #ff0000;">&quot;Url&quot;</span> <span style="color: #000066;">action</span><span style="color: #66cc66;">=</span><span style="color: #ff0000;">&quot;Nombre_del_mapeo&quot;</span> escapeAmp<span style="color: #66cc66;">=</span><span style="color: #ff0000;">&quot;false&quot;</span>&gt;</span>
  	 <span style="color: #009900;">&lt;s:param <span style="color: #000066;">name</span><span style="color: #66cc66;">=</span><span style="color: #ff0000;">&quot;name&quot;</span> <span style="color: #000066;">value</span><span style="color: #66cc66;">=</span><span style="color: #ff0000;">&quot;name&quot;</span> <span style="color: #66cc66;">/</span>&gt;</span>
       <span style="color: #009900;">&lt;s:param <span style="color: #000066;">name</span><span style="color: #66cc66;">=</span><span style="color: #ff0000;">&quot;lastname&quot;</span> <span style="color: #000066;">value</span><span style="color: #66cc66;">=</span><span style="color: #ff0000;">&quot;lastname&quot;</span> <span style="color: #66cc66;">/</span>&gt;</span>
<span style="color: #009900;">&lt;<span style="color: #66cc66;">/</span>s:url&gt;</span>
<span style="color: #009900;">&lt;<span style="color: #000000; font-weight: bold;">a</span> <span style="color: #000066;">href</span><span style="color: #66cc66;">=</span><span style="color: #ff0000;">&quot;&lt;s:property value=&quot;</span>%<span style="color: #66cc66;">&#123;</span>Url<span style="color: #66cc66;">&#125;</span><span style="color: #ff0000;">&quot;/&gt;</span></span>&quot;&gt;<span style="color: #009900;">&lt;s:<span style="color: #000066;">text</span> <span style="color: #000066;">name</span><span style="color: #66cc66;">=</span><span style="color: #ff0000;">&quot;Borrar alumno&quot;</span><span style="color: #66cc66;">/</span>&gt;&lt;<span style="color: #66cc66;">/</span><span style="color: #000000; font-weight: bold;">a</span>&gt;</span></pre></td></tr></table></div>

<p> Y este otro Action  tiene que borrar al alumno y regresar con los datos de posibles filtros de la búsqueda realizada, ósea con el NAME Y LASTNAME del JSP donde esta el formulario:</p>

<div class="wp_syntax"><table><tr><td class="line_numbers"><pre>1
2
3
4
5
6
7
8
9
</pre></td><td class="code"><pre class="html4strict" style="font-family:monospace;">  <span style="color: #009900;">&lt;action <span style="color: #000066;">name</span><span style="color: #66cc66;">=</span><span style="color: #ff0000;">&quot; Nombre_del_mapeo&quot;</span> <span style="color: #000066;">class</span><span style="color: #66cc66;">=</span><span style="color: #ff0000;">&quot;com.delete&quot;</span>  <span style="color: #000066;">method</span><span style="color: #66cc66;">=</span><span style="color: #ff0000;">&quot;input&quot;</span>&gt;</span>
     <span style="color: #009900;">&lt;result <span style="color: #000066;">name</span><span style="color: #66cc66;">=</span><span style="color: #ff0000;">&quot;success&quot;</span> <span style="color: #000066;">type</span><span style="color: #66cc66;">=</span><span style="color: #ff0000;">&quot;redirect-action&quot;</span>&gt;</span>
	   <span style="color: #009900;">&lt;<span style="color: #000000; font-weight: bold;">param</span> <span style="color: #000066;">name</span><span style="color: #66cc66;">=</span><span style="color: #ff0000;">&quot;actionName&quot;</span>&gt;</span>./buscaAlumnos.action<span style="color: #009900;">&lt;<span style="color: #66cc66;">/</span><span style="color: #000000; font-weight: bold;">param</span>&gt;</span>
	   <span style="color: #009900;">&lt;<span style="color: #000000; font-weight: bold;">param</span> <span style="color: #000066;">name</span><span style="color: #66cc66;">=</span><span style="color: #ff0000;">&quot;parse&quot;</span>&gt;</span>true<span style="color: #009900;">&lt;<span style="color: #66cc66;">/</span><span style="color: #000000; font-weight: bold;">param</span>&gt;</span>
           <span style="color: #009900;">&lt;<span style="color: #000000; font-weight: bold;">param</span> <span style="color: #000066;">name</span><span style="color: #66cc66;">=</span><span style="color: #ff0000;">&quot;name&quot;</span>&gt;</span>${name}<span style="color: #009900;">&lt;<span style="color: #66cc66;">/</span><span style="color: #000000; font-weight: bold;">param</span>&gt;</span>
           <span style="color: #009900;">&lt;<span style="color: #000000; font-weight: bold;">param</span> <span style="color: #000066;">name</span><span style="color: #66cc66;">=</span><span style="color: #ff0000;">&quot;lastname&quot;</span>&gt;</span>${lastname}<span style="color: #009900;">&lt;<span style="color: #66cc66;">/</span><span style="color: #000000; font-weight: bold;">param</span>&gt;</span>
     <span style="color: #009900;">&lt;<span style="color: #66cc66;">/</span>result&gt;</span>
<span style="color: #009900;">&lt;result <span style="color: #000066;">name</span><span style="color: #66cc66;">=</span><span style="color: #ff0000;">&quot;error&quot;</span> <span style="color: #000066;">type</span><span style="color: #66cc66;">=</span><span style="color: #ff0000;">&quot;tiles&quot;</span>&gt;</span>errorDelete<span style="color: #009900;">&lt;<span style="color: #66cc66;">/</span>result&gt;</span>
<span style="color: #009900;">&lt;<span style="color: #66cc66;">/</span>action&gt;</span></pre></td></tr></table></div>

<p>Tenemos que tener su get y set de los atributos:</p>
<p>Action Delete.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
</pre></td><td class="code"><pre class="html4strict" style="font-family:monospace;">private String name;
private String lastname;
&nbsp;
public String getName()
    {
        return name;
    }
&nbsp;
    /**
     * @param name the name to set
     */
    public void setName(String name)
    {
        this.name = name;
    }
&nbsp;
    /**
     * @return the lastname
     */
    public String getLastname()
    {
        return lastname;
    }
&nbsp;
    /**
     * @param lastname the lastname to set
     */
    public void setLastname(String lastname)
    {
        this.lastname = lastname;
    }</pre></td></tr></table></div>

<p>Y después de realizar el proceso de borrado. Este reenviará al Action buscaAlumnos los parámetros por medio de la URL y así poder repetir la búsqueda y&#8230;</p>

<div class="wp_syntax"><table><tr><td class="line_numbers"><pre>1
</pre></td><td class="code"><pre class="html4strict" style="font-family:monospace;">http://...../buscaAlumnos.action?name=Valor<span style="color: #ddbb00;">&amp;lasname=Valor</span></pre></td></tr></table></div>

<p>entonces el JSP que muestra la búsqueda volverá actualizarse sin mostrar al Alumno borrado. Y listo!!!!</p>
<div class="thanks_button_div" style="float: left; margin-right: 10px;"><div style="float: left; display: inline;"><input type="button" onclick="thankYouButtonClick(249, 'You left &ldquo;Thanks&rdquo; already for this post')" value="Thank You: 0"
                class="thanks_button thanks_custom_button "
                style="background-image:url(http://b.static.ak.fbcdn.net/rsrc.php/yp/r/qDH1xoDhFBF.gif);width:15px; height:13px; font-family: Verdana, Arial, Sans-Serif; font-size: 14px; font-weight: normal;; color:#ffffff;"
                id="thanksButton_249_2" title="Click to left &ldquo;Thanks&rdquo; for this post"/></div><div id="ajax_loader_249_2" style="display:inline;visibility: hidden;"><img alt="ajax loader" src="http://www.serunix.com/wp-content/plugins/thanks-you-counter-button/images/ajax-loader.gif" /></div></div>]]></content:encoded>
			<wfw:commentRss>http://www.serunix.com/2009/03/18/una-forma-de-direccionar-parametros-por-medio-de-la-url-en-struts-2%e2%80%a6-rediect-actionparam%e2%80%a6/feed</wfw:commentRss>
		<slash:comments>3</slash:comments>
		</item>
		<item>
		<title>Validación del Tag &#8230; en Struts 2 (validation for  tag&#8230;Struts 2)</title>
		<link>http://www.serunix.com/2009/03/10/validacion-del-tag-en-struts-2-validation-for-tagstruts-2</link>
		<comments>http://www.serunix.com/2009/03/10/validacion-del-tag-en-struts-2-validation-for-tagstruts-2#comments</comments>
		<pubDate>Tue, 10 Mar 2009 19:11:38 +0000</pubDate>
		<dc:creator>sergio</dc:creator>
				<category><![CDATA[Java]]></category>
		<category><![CDATA[Programación]]></category>
		<category><![CDATA[Struts2]]></category>

		<guid isPermaLink="false">http://www.serunix.com/?p=234</guid>
		<description><![CDATA[Una forma de validación de un &#60;s:select&#62; en struts 2 , de las muchas que pueden existir, es la de usar el validador claro esta que viene integrado con el mismo frameworks&#8230; aquí les pongo un ejemplo: JSP 1 2 3 4 5 6 7 &#60;s:select label=&#34;Month:&#34; name=&#34;monthn&#34; headerKey=&#34;&#34; headerValue=&#34;-- Select a Month --&#34; list=&#34;#{'01':'January','02':'February','03':'March','04':'April', [...]]]></description>
			<content:encoded><![CDATA[<p>Una forma de validación de un <em>&lt;s:select&gt;</em> en struts 2 , de las muchas que pueden existir,  es la de usar el validador <del datetime="2009-03-10T18:49:27+00:00">claro esta</del> que viene integrado con el mismo frameworks&#8230;  aquí les pongo un ejemplo:</p>
<p>JSP</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="html4strict" style="font-family:monospace;"><span style="color: #009900;">&lt;s:select <span style="color: #000066;">label</span><span style="color: #66cc66;">=</span><span style="color: #ff0000;">&quot;Month:&quot;</span></span>
<span style="color: #009900;">     <span style="color: #000066;">name</span><span style="color: #66cc66;">=</span><span style="color: #ff0000;">&quot;monthn&quot;</span></span>
<span style="color: #009900;">     headerKey<span style="color: #66cc66;">=</span><span style="color: #ff0000;">&quot;&quot;</span></span>
<span style="color: #009900;">     headerValue<span style="color: #66cc66;">=</span><span style="color: #ff0000;">&quot;--  Select a Month --&quot;</span></span>
<span style="color: #009900;">     list<span style="color: #66cc66;">=</span><span style="color: #ff0000;">&quot;#{'01':'January','02':'February','03':'March','04':'April',</span>
<span style="color: #009900;">     '05':'May','06':'June','07':'July','08':'August','09':'September','10':</span>
<span style="color: #009900;">     'October','11':'November','12':'December'}&quot;</span> <span style="color: #66cc66;">/</span>&gt;</span></pre></td></tr></table></div>

<p>en html así</p>

<div class="wp_syntax"><table><tr><td class="line_numbers"><pre>1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
</pre></td><td class="code"><pre class="html4strict" style="font-family:monospace;"><span style="color: #009900;">&lt;<span style="color: #000000; font-weight: bold;">select</span> <span style="color: #000066;">name</span><span style="color: #66cc66;">=</span><span style="color: #ff0000;">&quot;monthn&quot;</span> &gt;</span>
    <span style="color: #009900;">&lt;<span style="color: #000000; font-weight: bold;">option</span> <span style="color: #000066;">value</span><span style="color: #66cc66;">=</span><span style="color: #ff0000;">&quot;&quot;</span> &gt;</span>--  Select a Month --<span style="color: #009900;">&lt;<span style="color: #66cc66;">/</span><span style="color: #000000; font-weight: bold;">option</span>&gt;</span>
    <span style="color: #009900;">&lt;<span style="color: #000000; font-weight: bold;">option</span> <span style="color: #000066;">value</span><span style="color: #66cc66;">=</span><span style="color: #ff0000;">&quot;01&quot;</span>&gt;</span>January<span style="color: #009900;">&lt;<span style="color: #66cc66;">/</span><span style="color: #000000; font-weight: bold;">option</span>&gt;</span>
    <span style="color: #009900;">&lt;<span style="color: #000000; font-weight: bold;">option</span> <span style="color: #000066;">value</span><span style="color: #66cc66;">=</span><span style="color: #ff0000;">&quot;02&quot;</span>&gt;</span>February<span style="color: #009900;">&lt;<span style="color: #66cc66;">/</span><span style="color: #000000; font-weight: bold;">option</span>&gt;</span>
    <span style="color: #009900;">&lt;<span style="color: #000000; font-weight: bold;">option</span> <span style="color: #000066;">value</span><span style="color: #66cc66;">=</span><span style="color: #ff0000;">&quot;03&quot;</span>&gt;</span>March<span style="color: #009900;">&lt;<span style="color: #66cc66;">/</span><span style="color: #000000; font-weight: bold;">option</span>&gt;</span>
    <span style="color: #009900;">&lt;<span style="color: #000000; font-weight: bold;">option</span> <span style="color: #000066;">value</span><span style="color: #66cc66;">=</span><span style="color: #ff0000;">&quot;04&quot;</span>&gt;</span>April<span style="color: #009900;">&lt;<span style="color: #66cc66;">/</span><span style="color: #000000; font-weight: bold;">option</span>&gt;</span>
    <span style="color: #009900;">&lt;<span style="color: #000000; font-weight: bold;">option</span> <span style="color: #000066;">value</span><span style="color: #66cc66;">=</span><span style="color: #ff0000;">&quot;05&quot;</span>&gt;</span>May<span style="color: #009900;">&lt;<span style="color: #66cc66;">/</span><span style="color: #000000; font-weight: bold;">option</span>&gt;</span>
    <span style="color: #009900;">&lt;<span style="color: #000000; font-weight: bold;">option</span> <span style="color: #000066;">value</span><span style="color: #66cc66;">=</span><span style="color: #ff0000;">&quot;06&quot;</span>&gt;</span>June<span style="color: #009900;">&lt;<span style="color: #66cc66;">/</span><span style="color: #000000; font-weight: bold;">option</span>&gt;</span>
    <span style="color: #009900;">&lt;<span style="color: #000000; font-weight: bold;">option</span> <span style="color: #000066;">value</span><span style="color: #66cc66;">=</span><span style="color: #ff0000;">&quot;07&quot;</span>&gt;</span>July<span style="color: #009900;">&lt;<span style="color: #66cc66;">/</span><span style="color: #000000; font-weight: bold;">option</span>&gt;</span>
    <span style="color: #009900;">&lt;<span style="color: #000000; font-weight: bold;">option</span> <span style="color: #000066;">value</span><span style="color: #66cc66;">=</span><span style="color: #ff0000;">&quot;08&quot;</span>&gt;</span>August<span style="color: #009900;">&lt;<span style="color: #66cc66;">/</span><span style="color: #000000; font-weight: bold;">option</span>&gt;</span>
    <span style="color: #009900;">&lt;<span style="color: #000000; font-weight: bold;">option</span> <span style="color: #000066;">value</span><span style="color: #66cc66;">=</span><span style="color: #ff0000;">&quot;09&quot;</span>&gt;</span>September<span style="color: #009900;">&lt;<span style="color: #66cc66;">/</span><span style="color: #000000; font-weight: bold;">option</span>&gt;</span>
    <span style="color: #009900;">&lt;<span style="color: #000000; font-weight: bold;">option</span> <span style="color: #000066;">value</span><span style="color: #66cc66;">=</span><span style="color: #ff0000;">&quot;10&quot;</span>&gt;</span>October<span style="color: #009900;">&lt;<span style="color: #66cc66;">/</span><span style="color: #000000; font-weight: bold;">option</span>&gt;</span>
    <span style="color: #009900;">&lt;<span style="color: #000000; font-weight: bold;">option</span> <span style="color: #000066;">value</span><span style="color: #66cc66;">=</span><span style="color: #ff0000;">&quot;11&quot;</span>&gt;</span>November<span style="color: #009900;">&lt;<span style="color: #66cc66;">/</span><span style="color: #000000; font-weight: bold;">option</span>&gt;</span>
    <span style="color: #009900;">&lt;<span style="color: #000000; font-weight: bold;">option</span> <span style="color: #000066;">value</span><span style="color: #66cc66;">=</span><span style="color: #ff0000;">&quot;12&quot;</span>&gt;</span>December<span style="color: #009900;">&lt;<span style="color: #66cc66;">/</span><span style="color: #000000; font-weight: bold;">option</span>&gt;</span>
<span style="color: #009900;">&lt;<span style="color: #66cc66;">/</span><span style="color: #000000; font-weight: bold;">select</span>&gt;</span></pre></td></tr></table></div>

<p>y en el validador (en el xml)</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="html4strict" style="font-family:monospace;"><span style="color: #009900;">&lt;field <span style="color: #000066;">name</span><span style="color: #66cc66;">=</span><span style="color: #ff0000;">&quot;monthn&quot;</span>&gt;</span>
        <span style="color: #009900;">&lt;field-validator <span style="color: #000066;">type</span><span style="color: #66cc66;">=</span><span style="color: #ff0000;">&quot;fieldexpression&quot;</span>&gt;</span>
            <span style="color: #009900;">&lt;<span style="color: #000000; font-weight: bold;">param</span> <span style="color: #000066;">name</span><span style="color: #66cc66;">=</span><span style="color: #ff0000;">&quot;expression&quot;</span>&gt;&lt;!<span style="color: #66cc66;">&#91;</span>CDATA<span style="color: #66cc66;">&#91;</span>!<span style="color: #66cc66;">&#40;</span><span style="color: #ff0000;">&quot;&quot;</span>.equals<span style="color: #66cc66;">&#40;</span>monthn<span style="color: #66cc66;">&#41;</span><span style="color: #66cc66;">&#41;</span><span style="color: #66cc66;">&#93;</span><span style="color: #66cc66;">&#93;</span>&gt;&lt;<span style="color: #66cc66;">/</span><span style="color: #000000; font-weight: bold;">param</span>&gt;</span>
             <span style="color: #009900;">&lt;message key<span style="color: #66cc66;">=</span><span style="color: #ff0000;">&quot;errors.required.monthn&quot;</span>&gt;&lt;<span style="color: #66cc66;">/</span>message&gt;</span>
        <span style="color: #009900;">&lt;<span style="color: #66cc66;">/</span>field-validator&gt;</span>
    <span style="color: #009900;">&lt;<span style="color: #66cc66;">/</span>field&gt;</span></pre></td></tr></table></div>

<p>Donde <em>equals</em> es el método a usar para compararlo con el nombre del <em>select</em>. Y listoÂ¡Â¡Â¡ Esta es una de las formas&#8230; pero se puede hacer de muchas maneras&#8230;</p>
<div class="thanks_button_div" style="float: left; margin-right: 10px;"><div style="float: left; display: inline;"><input type="button" onclick="thankYouButtonClick(234, 'You left &ldquo;Thanks&rdquo; already for this post')" value="Thank You: 1"
                class="thanks_button thanks_custom_button "
                style="background-image:url(http://b.static.ak.fbcdn.net/rsrc.php/yp/r/qDH1xoDhFBF.gif);width:15px; height:13px; font-family: Verdana, Arial, Sans-Serif; font-size: 14px; font-weight: normal;; color:#ffffff;"
                id="thanksButton_234_2" title="Click to left &ldquo;Thanks&rdquo; for this post"/></div><div id="ajax_loader_234_2" style="display:inline;visibility: hidden;"><img alt="ajax loader" src="http://www.serunix.com/wp-content/plugins/thanks-you-counter-button/images/ajax-loader.gif" /></div></div>]]></content:encoded>
			<wfw:commentRss>http://www.serunix.com/2009/03/10/validacion-del-tag-en-struts-2-validation-for-tagstruts-2/feed</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Problemas con la Internacionalización con Struts 2 y I18n&#8230; modificando la clase del Taglib I18nTag&#8230;</title>
		<link>http://www.serunix.com/2009/03/05/problemas-con-la-internacionalizacion-con-struts-2-y-i18n%e2%80%a6-modificando-la-clase-del-taglib-i18ntag%e2%80%a6</link>
		<comments>http://www.serunix.com/2009/03/05/problemas-con-la-internacionalizacion-con-struts-2-y-i18n%e2%80%a6-modificando-la-clase-del-taglib-i18ntag%e2%80%a6#comments</comments>
		<pubDate>Thu, 05 Mar 2009 10:56:36 +0000</pubDate>
		<dc:creator>sergio</dc:creator>
				<category><![CDATA[Java]]></category>
		<category><![CDATA[Programación]]></category>
		<category><![CDATA[Struts2]]></category>

		<guid isPermaLink="false">http://www.serunix.com/?p=222</guid>
		<description><![CDATA[Tuve muchos problemas con este Taglib, I18nTag: 1 2 3 &#60;s:i18n name=&#34;otherApplication&#34;&#62; &#60;s:text name=&#34;user.name&#34; /&#62; &#60;/s:i18n&#62; como ustedes saben, sirve para leer un archivo properties independientemente del definido en el archivo struts.xml que es loading como default en el proyecto: 1 &#60;constant name=&#34;struts.custom.i18n.resources&#34; value=&#34;Application&#34;/&#62; Este taglib busca el archivo otherApplication.properties y lo deja en el [...]]]></description>
			<content:encoded><![CDATA[<p>Tuve muchos problemas con este Taglib, I18nTag:</p>

<div class="wp_syntax"><table><tr><td class="line_numbers"><pre>1
2
3
</pre></td><td class="code"><pre class="html4strict" style="font-family:monospace;">           <span style="color: #009900;">&lt;s:i18n <span style="color: #000066;">name</span><span style="color: #66cc66;">=</span><span style="color: #ff0000;">&quot;otherApplication&quot;</span>&gt;</span>
	             <span style="color: #009900;">&lt;s:<span style="color: #000066;">text</span> <span style="color: #000066;">name</span><span style="color: #66cc66;">=</span><span style="color: #ff0000;">&quot;user.name&quot;</span> <span style="color: #66cc66;">/</span>&gt;</span> 
            <span style="color: #009900;">&lt;<span style="color: #66cc66;">/</span>s:i18n&gt;</span></pre></td></tr></table></div>

<p>como ustedes saben, sirve para leer un  archivo properties independientemente del definido en el archivo struts.xml que es loading como default en el proyecto:</p>

<div class="wp_syntax"><table><tr><td class="line_numbers"><pre>1
</pre></td><td class="code"><pre class="html4strict" style="font-family:monospace;">         <span style="color: #009900;">&lt;constant <span style="color: #000066;">name</span><span style="color: #66cc66;">=</span><span style="color: #ff0000;">&quot;struts.custom.i18n.resources&quot;</span> <span style="color: #000066;">value</span><span style="color: #66cc66;">=</span><span style="color: #ff0000;">&quot;Application&quot;</span><span style="color: #66cc66;">/</span>&gt;</span></pre></td></tr></table></div>

<p>Este taglib busca el archivo otherApplication.properties y lo deja en el stack del proyecto, con lo cual todas las propiedades que se soliciten dentro de este taglib son buscadas primero en este archivo, Yo quería ponerle una variable en la propiedad name=&#8221;{%}&#8221;, name=&#8221;#session&#8221;, etc.  para que el contenido sea dinámico&#8230; y que loading el archivo que yo quisiera sin que sea fijo el nombre&#8230; pero este taglib no deja que su propiedad name sea dinámico, sino que debe de ser estático ósea que obtiene el nombre tal y como lo hayamos escrito dentro de esta propiedad&#8230; en fin&#8230; si alguien esta interesado en cambiar el contenido y asociarle otro valor o modificarlo, lo que yo hice fue, modificar la clase I18nTag.class del .jar de struts2&#8230; y como hice esto:</p>
<p>1.- Abrimos el archivo struts<version>.jar con Winrar(en mi caso es el que tengo)<br />
2.- Abrimos la carpeta META-IF<br />
3.- Extraemos un archivo que se llama struts-tags.tld<br />
4.- Lo abrimos con un editor de texto<br />
5.- Buscamos el taglibs, en este caso Es I18n<br />
6.- Sustituimos al parte de ruta (<tag-class>):</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="html4strict" style="font-family:monospace;">	<span style="color: #009900;">&lt;tag&gt;</span>
    <span style="color: #009900;">&lt;name&gt;</span>i18n<span style="color: #009900;">&lt;<span style="color: #66cc66;">/</span>name&gt;</span>
    <span style="color: #009900;">&lt;tag-class&gt;</span>org.apache.struts2.views.jsp.I18nTag<span style="color: #009900;">&lt;<span style="color: #66cc66;">/</span>tag-class&gt;</span>
    <span style="color: #009900;">&lt;body-content&gt;</span>JSP<span style="color: #009900;">&lt;<span style="color: #66cc66;">/</span>body-content&gt;</span>
    <span style="color: #009900;">&lt;description&gt;&lt;!<span style="color: #66cc66;">&#91;</span>CDATA<span style="color: #66cc66;">&#91;</span>Get a resource bundle and place it on the <span style="color: #000066;">value</span> stack<span style="color: #66cc66;">&#93;</span><span style="color: #66cc66;">&#93;</span>&gt;&lt;<span style="color: #66cc66;">/</span>description&gt;</span>
    <span style="color: #009900;">&lt;attribute&gt;</span>
      <span style="color: #009900;">&lt;name&gt;</span>id<span style="color: #009900;">&lt;<span style="color: #66cc66;">/</span>name&gt;</span>
      <span style="color: #009900;">&lt;required&gt;</span>false<span style="color: #009900;">&lt;<span style="color: #66cc66;">/</span>required&gt;</span>
      <span style="color: #009900;">&lt;rtexprvalue&gt;</span>false<span style="color: #009900;">&lt;<span style="color: #66cc66;">/</span>rtexprvalue&gt;</span>
      <span style="color: #009900;">&lt;description&gt;&lt;!<span style="color: #66cc66;">&#91;</span>CDATA<span style="color: #66cc66;">&#91;</span><span style="color: #000066;">id</span> <span style="color: #000066;">for</span> referencing element. <span style="color: #000066;">For</span> UI and form tags it will be used as HTML <span style="color: #000066;">id</span> attribute<span style="color: #66cc66;">&#93;</span><span style="color: #66cc66;">&#93;</span>&gt;&lt;<span style="color: #66cc66;">/</span>description&gt;</span>
    <span style="color: #009900;">&lt;<span style="color: #66cc66;">/</span>attribute&gt;</span>
    <span style="color: #009900;">&lt;attribute&gt;</span>
      <span style="color: #009900;">&lt;name&gt;</span>name<span style="color: #009900;">&lt;<span style="color: #66cc66;">/</span>name&gt;</span>
      <span style="color: #009900;">&lt;required&gt;</span>true<span style="color: #009900;">&lt;<span style="color: #66cc66;">/</span>required&gt;</span>
      <span style="color: #009900;">&lt;rtexprvalue&gt;</span>false<span style="color: #009900;">&lt;<span style="color: #66cc66;">/</span>rtexprvalue&gt;</span>
      <span style="color: #009900;">&lt;description&gt;&lt;!<span style="color: #66cc66;">&#91;</span>CDATA<span style="color: #66cc66;">&#91;</span><span style="color: #000066;">Name</span> of ressource bundle to use <span style="color: #66cc66;">&#40;</span>eg foo<span style="color: #66cc66;">/</span>bar<span style="color: #66cc66;">/</span>customBundle<span style="color: #66cc66;">&#41;</span><span style="color: #66cc66;">&#93;</span><span style="color: #66cc66;">&#93;</span>&gt;&lt;<span style="color: #66cc66;">/</span>description&gt;</span>
    <span style="color: #009900;">&lt;<span style="color: #66cc66;">/</span>attribute&gt;</span>
  <span style="color: #009900;">&lt;<span style="color: #66cc66;">/</span>tag&gt;</span></pre></td></tr></table></div>

<p>Y en la línea escribimos un paquete dentro de nuestro proyecto&#8230;</p>

<div class="wp_syntax"><table><tr><td class="line_numbers"><pre>1
</pre></td><td class="code"><pre class="html4strict" style="font-family:monospace;">         <span style="color: #009900;">&lt;tag-class&gt;</span>net.new.views.jsp.I18nTag<span style="color: #009900;">&lt;<span style="color: #66cc66;">/</span>tag-class&gt;</span></pre></td></tr></table></div>

<p>7.- Lo guardamos y lo volvemos a empaquetar dentro del struts<version>.jar<br />
8.- Bajamos los archivos  fuentes de la versión que estemos usando, y los colocamos en la ruta de paquetes que hayamos definido en el paso 6 ósea en (<tag-class>)<br />
9.- Una vez hecho esto, cada vez que utilicemos dentro de una JSP esta etiqueta (i18n) de Struct 2 buscará la clase donde le hayamos puesto la ruta de paquetes&#8230;<br />
10.- Y con esto podremos modificar la clase y el valor de sus propiedades&#8230;</p>
<p>Listo!!!!</p>
<div class="thanks_button_div" style="float: left; margin-right: 10px;"><div style="float: left; display: inline;"><input type="button" onclick="thankYouButtonClick(222, 'You left &ldquo;Thanks&rdquo; already for this post')" value="Thank You: 0"
                class="thanks_button thanks_custom_button "
                style="background-image:url(http://b.static.ak.fbcdn.net/rsrc.php/yp/r/qDH1xoDhFBF.gif);width:15px; height:13px; font-family: Verdana, Arial, Sans-Serif; font-size: 14px; font-weight: normal;; color:#ffffff;"
                id="thanksButton_222_2" title="Click to left &ldquo;Thanks&rdquo; for this post"/></div><div id="ajax_loader_222_2" style="display:inline;visibility: hidden;"><img alt="ajax loader" src="http://www.serunix.com/wp-content/plugins/thanks-you-counter-button/images/ajax-loader.gif" /></div></div>]]></content:encoded>
			<wfw:commentRss>http://www.serunix.com/2009/03/05/problemas-con-la-internacionalizacion-con-struts-2-y-i18n%e2%80%a6-modificando-la-clase-del-taglib-i18ntag%e2%80%a6/feed</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
	</channel>
</rss>

