You are viewing a plain text version of this content. The canonical link for it is here.
Posted to user@velocity.apache.org by Neal Smith <Ne...@sas.com> on 2005/08/24 20:50:31 UTC

Struts and I18N

Hi All,

  I am new to Velocity and am working on part of our application written by someone else.  

  The app is using Velocity to generate emails.  Currently, we have templates that have hardcoded English text in them.  I am trying to I18N these templates so that they pick up text from our .properties files.

  I believe I don't have things setup correctly, but I can't seem to find a "full" example that explains everything end-to-end, so I can't figure out how to verify this.  From Googling, I see that lots of people seem to have similar problems, but none of their solutions seem to work for me.  I think it's involved with how we use the templates, but I'm too new to know for sure.

  I have dl'd the 1.1 Tools.  I have only copied the velocity-tools-1.1.jar to my lib directory, because it didn't seem like I needed the rest of it and I already have Struts.  (Am I wrong?)  I have setup the web.xml and toolbox.xml just like the Velocity website says.  I have updated part of the template with the following line:

<head>
  <title>$msg.get("app.title.txt") - Alert Details</title>

  #include($styleSheet)

</head>

  When I run this I get:

2:4:43 WARN  lang org.apache.velocity.runtime.exception.ReferenceException: refe
rence : template = /com/sas/aml/velocity/email/alert_details.vm [line 5,column 1
0] : $msg.get("app.title.txt") is not a valid reference.

  

  The real interesting part, to me anyway, is that we are not accessing these templates through regular Struts forwards, etc.  From what I understand VelocityViewServlet is necessary to use the MessageTool?  We are using VelocityEngine (via mergeTemplate) and I believe that I'll need to replace this with usage of VelocityViewServlet?  

  As you can tell, I'm getting very fuzzy on all of this last part.  Any help is appreciated.


Thanks,
Neal Smith




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


Re: Struts and I18N

Posted by Nathan Bubna <nb...@gmail.com>.
Hi Neal,

have you checked out the Struts example application in VelocityTools? 
It includes a number of "mini-webapps" that demonstrate using various
Struts features with VelocityTools.  I believe the mini-webapp "app1"
demonstrates use of the MessageTool for internationalization.

also, i'm curious where/how your are generating these emails?  are you
doing this within the servlet? is it as part of a servlet request? 
where/how are you creating/getting a Context to merge with the
template?

there's a lot that's unclear to me about the way you are approaching
this.  and to try and clear up your last curiousity there:  yeah, the
VelocityViewServlet is the main way in which the MessageTool is
initialized and added to the Context before processing the template. 
so, depending on where/how you are processing your email templates, it
may be easy to get a working MessageTool, or it may not.  it's hard to
say without knowing your setup better.

On 8/24/05, Neal Smith <Ne...@sas.com> wrote:
> Hi All,
> 
>   I am new to Velocity and am working on part of our application written by someone else.
> 
>   The app is using Velocity to generate emails.  Currently, we have templates that have hardcoded English text in them.  I am trying to I18N these templates so that they pick up text from our .properties files.
> 
>   I believe I don't have things setup correctly, but I can't seem to find a "full" example that explains everything end-to-end, so I can't figure out how to verify this.  From Googling, I see that lots of people seem to have similar problems, but none of their solutions seem to work for me.  I think it's involved with how we use the templates, but I'm too new to know for sure.
> 
>   I have dl'd the 1.1 Tools.  I have only copied the velocity-tools-1.1.jar to my lib directory, because it didn't seem like I needed the rest of it and I already have Struts.  (Am I wrong?)  I have setup the web.xml and toolbox.xml just like the Velocity website says.  I have updated part of the template with the following line:
> 
> <head>
>   <title>$msg.get("app.title.txt") - Alert Details</title>
> 
>   #include($styleSheet)
> 
> </head>
> 
>   When I run this I get:
> 
> 2:4:43 WARN  lang org.apache.velocity.runtime.exception.ReferenceException: refe
> rence : template = /com/sas/aml/velocity/email/alert_details.vm [line 5,column 1
> 0] : $msg.get("app.title.txt") is not a valid reference.
> 
> 
> 
>   The real interesting part, to me anyway, is that we are not accessing these templates through regular Struts forwards, etc.  From what I understand VelocityViewServlet is necessary to use the MessageTool?  We are using VelocityEngine (via mergeTemplate) and I believe that I'll need to replace this with usage of VelocityViewServlet?
> 
>   As you can tell, I'm getting very fuzzy on all of this last part.  Any help is appreciated.
> 
> 
> Thanks,
> Neal Smith
> 
> 
> 
> 
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: velocity-user-unsubscribe@jakarta.apache.org
> For additional commands, e-mail: velocity-user-help@jakarta.apache.org
> 
>

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