You are viewing a plain text version of this content. The canonical link for it is here.
Posted to user@velocity.apache.org by Jordi Rubio Moreno <jr...@grupointercom.com> on 2007/05/14 10:36:37 UTC

I18n problem with Struts 2

Hi,
 
I'm trying to use Velocity with Struts 2. At this moment, I have two
view files: one with taglibs and one with Velocity tags. The first dumps
texts with <s:text name="foo"> (where foo var is stores in a
package.properties file), and works fine. The Velocity template looks
like:
 
     <tr align="right">
      #stext (name="Results.counter1")<br>
      $text.get('Results.counter1', [$result.getTotalRowsNumber()])<br>
      $text.exists("Results.counter1")
     </tr>
     <tr>
      <table id="results">
       #foreach($offer in $offers)
        <tr>
         <td>
                <a
href="$link.setAction('/Redirect.action').param('url',
$offer.url)">$offer.title</a>
         </td>
        </tr>
       #end
      </table>
     </tr>

The $link, #foreach, etc work fine, but the text tags works wrong. This
is the output for this code:
 
#stext (name="Results.counter1") 
$text.get('Results.counter1', [$result.getTotalRowsNumber()])
false
 
What am I  doing wrong? Taglibs and Velocity works with the same
package.properties. I have tried to put this resource file replicated in
a lot of directories, allways in the classpath, but the result is
allways the same...
 
Please, help! :P
 
Thanks a lot for your time!
 
Cheers!

Re: I18n problem with Struts 2

Posted by Nathan Bubna <nb...@gmail.com>.
Glad to hear you got it figured out!

On 5/14/07, Jordi Rubio Moreno <jr...@grupointercom.com> wrote:
> Hi Nathan,
>
> Well, the complete history is I was testing Velocity integration (as a
> good newbie) with and without the VelocityViewServlet (latest version).
> If I use VelocityViewServlet, e.g, the $link works fine, but $text
> fails.
>
> Few hours ago I had read that VelocityTools only supports Struts 1.x, as
> you say, and now I'm testing the integration without
> VelocityViewServlet. I'm using #stext and #surl tags to manage view
> layer with Velocity and Struts 2, and the code looks like:
>
>                         <tr align="right">
>                                 #stext("name=Results.counter")<br>
>                         </tr>
>                         <tr>
>                                 <table id="results">
>                                         #foreach($offer in $offers)
>                                                 <tr>
>                                                         <td>
>
> #surl("id=offUrl" "action=Redirect" "url=$offer.url")
>                                                         <a
> href="${offUrl}">$offer.title</a>
>                                                         </td>
>                                                 </tr>
>                                         #end
>                                 </table>
>                         </tr>
>
> I believe this solution works fine :)
>
> Thanks a lot for helping me!!
>
> Best regards!
>
> Jordi Rubio Moreno
>
>
>
> -----Mensaje original-----
> De: Nathan Bubna [mailto:nbubna@gmail.com]
> Enviado el: lunes, 14 de mayo de 2007 17:38
> Para: Velocity Users List
> Asunto: Re: I18n problem with Struts 2
>
> What is $text?  Are you trying to use VelocityTools with Struts2?  If so
> (and it very much looks like it), what version?  What does your
> toolbox.xml look like?  Are you using the VelocityViewServlet to process
> templates or is that something that Struts2 is handling?
>
> VelocityTools currently only explicitly supports Struts 1.x.   We're
> not involved in developing the Velocity directives for Struts2.  I
> believe those are being handled entirely by the Struts2 project.  I
> haven't used Struts2 yet, so i'm not very familiar with their Velocity
> integration.  If no one else on this lists chimes in with more info, you
> might try asking user@struts.apache.org about this.
>
> On 5/14/07, Jordi Rubio Moreno <jr...@grupointercom.com> wrote:
> > Hi,
> >
> > I'm trying to use Velocity with Struts 2. At this moment, I have two
> > view files: one with taglibs and one with Velocity tags. The first
> > dumps texts with <s:text name="foo"> (where foo var is stores in a
> > package.properties file), and works fine. The Velocity template looks
> > like:
> >
> >      <tr align="right">
> >       #stext (name="Results.counter1")<br>
> >       $text.get('Results.counter1',
> [$result.getTotalRowsNumber()])<br>
> >       $text.exists("Results.counter1")
> >      </tr>
> >      <tr>
> >       <table id="results">
> >        #foreach($offer in $offers)
> >         <tr>
> >          <td>
> >                 <a
> > href="$link.setAction('/Redirect.action').param('url',
> > $offer.url)">$offer.title</a>
> >          </td>
> >         </tr>
> >        #end
> >       </table>
> >      </tr>
> >
> > The $link, #foreach, etc work fine, but the text tags works wrong.
> > This is the output for this code:
> >
> > #stext (name="Results.counter1")
> > $text.get('Results.counter1', [$result.getTotalRowsNumber()]) false
> >
> > What am I  doing wrong? Taglibs and Velocity works with the same
> > package.properties. I have tried to put this resource file replicated
> > in a lot of directories, allways in the classpath, but the result is
> > allways the same...
> >
> > Please, help! :P
> >
> > Thanks a lot for your time!
> >
> > Cheers!
> >
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: user-unsubscribe@velocity.apache.org
> For additional commands, e-mail: user-help@velocity.apache.org
>
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: user-unsubscribe@velocity.apache.org
> For additional commands, e-mail: user-help@velocity.apache.org
>
>

---------------------------------------------------------------------
To unsubscribe, e-mail: user-unsubscribe@velocity.apache.org
For additional commands, e-mail: user-help@velocity.apache.org


RE: I18n problem with Struts 2

Posted by Jordi Rubio Moreno <jr...@grupointercom.com>.
Hi Nathan,

Well, the complete history is I was testing Velocity integration (as a
good newbie) with and without the VelocityViewServlet (latest version).
If I use VelocityViewServlet, e.g, the $link works fine, but $text
fails.

Few hours ago I had read that VelocityTools only supports Struts 1.x, as
you say, and now I'm testing the integration without
VelocityViewServlet. I'm using #stext and #surl tags to manage view
layer with Velocity and Struts 2, and the code looks like:

			<tr align="right">
				#stext("name=Results.counter")<br>
			</tr>
			<tr>
				<table id="results">
					#foreach($offer in $offers)
						<tr>
							<td>
	
#surl("id=offUrl" "action=Redirect" "url=$offer.url")
						        <a
href="${offUrl}">$offer.title</a>
							</td>
						</tr>
					#end
				</table>
			</tr>

I believe this solution works fine :)

Thanks a lot for helping me!!

Best regards!

Jordi Rubio Moreno
 


-----Mensaje original-----
De: Nathan Bubna [mailto:nbubna@gmail.com] 
Enviado el: lunes, 14 de mayo de 2007 17:38
Para: Velocity Users List
Asunto: Re: I18n problem with Struts 2

What is $text?  Are you trying to use VelocityTools with Struts2?  If so
(and it very much looks like it), what version?  What does your
toolbox.xml look like?  Are you using the VelocityViewServlet to process
templates or is that something that Struts2 is handling?

VelocityTools currently only explicitly supports Struts 1.x.   We're
not involved in developing the Velocity directives for Struts2.  I
believe those are being handled entirely by the Struts2 project.  I
haven't used Struts2 yet, so i'm not very familiar with their Velocity
integration.  If no one else on this lists chimes in with more info, you
might try asking user@struts.apache.org about this.

On 5/14/07, Jordi Rubio Moreno <jr...@grupointercom.com> wrote:
> Hi,
>
> I'm trying to use Velocity with Struts 2. At this moment, I have two 
> view files: one with taglibs and one with Velocity tags. The first 
> dumps texts with <s:text name="foo"> (where foo var is stores in a 
> package.properties file), and works fine. The Velocity template looks
> like:
>
>      <tr align="right">
>       #stext (name="Results.counter1")<br>
>       $text.get('Results.counter1',
[$result.getTotalRowsNumber()])<br>
>       $text.exists("Results.counter1")
>      </tr>
>      <tr>
>       <table id="results">
>        #foreach($offer in $offers)
>         <tr>
>          <td>
>                 <a
> href="$link.setAction('/Redirect.action').param('url',
> $offer.url)">$offer.title</a>
>          </td>
>         </tr>
>        #end
>       </table>
>      </tr>
>
> The $link, #foreach, etc work fine, but the text tags works wrong. 
> This is the output for this code:
>
> #stext (name="Results.counter1")
> $text.get('Results.counter1', [$result.getTotalRowsNumber()]) false
>
> What am I  doing wrong? Taglibs and Velocity works with the same 
> package.properties. I have tried to put this resource file replicated 
> in a lot of directories, allways in the classpath, but the result is 
> allways the same...
>
> Please, help! :P
>
> Thanks a lot for your time!
>
> Cheers!
>

---------------------------------------------------------------------
To unsubscribe, e-mail: user-unsubscribe@velocity.apache.org
For additional commands, e-mail: user-help@velocity.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: user-unsubscribe@velocity.apache.org
For additional commands, e-mail: user-help@velocity.apache.org


Re: I18n problem with Struts 2

Posted by Nathan Bubna <nb...@gmail.com>.
What is $text?  Are you trying to use VelocityTools with Struts2?  If
so (and it very much looks like it), what version?  What does your
toolbox.xml look like?  Are you using the VelocityViewServlet to
process templates or is that something that Struts2 is handling?

VelocityTools currently only explicitly supports Struts 1.x.   We're
not involved in developing the Velocity directives for Struts2.  I
believe those are being handled entirely by the Struts2 project.  I
haven't used Struts2 yet, so i'm not very familiar with their Velocity
integration.  If no one else on this lists chimes in with more info,
you might try asking user@struts.apache.org about this.

On 5/14/07, Jordi Rubio Moreno <jr...@grupointercom.com> wrote:
> Hi,
>
> I'm trying to use Velocity with Struts 2. At this moment, I have two
> view files: one with taglibs and one with Velocity tags. The first dumps
> texts with <s:text name="foo"> (where foo var is stores in a
> package.properties file), and works fine. The Velocity template looks
> like:
>
>      <tr align="right">
>       #stext (name="Results.counter1")<br>
>       $text.get('Results.counter1', [$result.getTotalRowsNumber()])<br>
>       $text.exists("Results.counter1")
>      </tr>
>      <tr>
>       <table id="results">
>        #foreach($offer in $offers)
>         <tr>
>          <td>
>                 <a
> href="$link.setAction('/Redirect.action').param('url',
> $offer.url)">$offer.title</a>
>          </td>
>         </tr>
>        #end
>       </table>
>      </tr>
>
> The $link, #foreach, etc work fine, but the text tags works wrong. This
> is the output for this code:
>
> #stext (name="Results.counter1")
> $text.get('Results.counter1', [$result.getTotalRowsNumber()])
> false
>
> What am I  doing wrong? Taglibs and Velocity works with the same
> package.properties. I have tried to put this resource file replicated in
> a lot of directories, allways in the classpath, but the result is
> allways the same...
>
> Please, help! :P
>
> Thanks a lot for your time!
>
> Cheers!
>

---------------------------------------------------------------------
To unsubscribe, e-mail: user-unsubscribe@velocity.apache.org
For additional commands, e-mail: user-help@velocity.apache.org