You are viewing a plain text version of this content. The canonical link for it is here.
Posted to user@velocity.apache.org by Rafał Gierusz <su...@tlen.pl> on 2005/11/10 13:33:44 UTC

Veltag and tools

Hello,

I'm trying to use Veltag in my JSP page. My code for velocity in my
JSP page look like this (first two lines for vel test - works):

<vel:velocity>
  #if (true) true #end
  #if (!false) & false #end
  <br>
  $date.get("yyyy-M-d H:m:s")
</vel:velocity>

my output is:

true & false
$date.get("yyyy-M-d H:m:s")

so, $date.get("yyyy-M-d H:m:s") is not evaluated, this line works if I
use it with *.vm page. When using Veltag in JSP I get also error in
log file:

2005-11-10 13:25:43 org.apache.catalina.core.ApplicationContext log
INFO:  Velocity   [warn] org.apache.velocity.runtime.exception.ReferenceException: reference : template = JSP for me! [line 5,column 11] : $date.get("yyyy-M-d H:m:s") is not a valid reference.

my tool config look like this:

<tool>
  <key>date</key>
  <scope>application</scope>
  <class>org.apache.velocity.tools.generic.DateTool</class>
</tool>

I'am quite sure that I can't use any velocity tool im my JSP.

Anybody can help me?

Michal



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


Re: velocity-tools-1.1 to 1.2 upgrade and the date tool

Posted by David Sperling <zz...@yahoo.com>.

--- Nathan Bubna <nb...@gmail.com> wrote:

> On 1/10/06, David Sperling <zz...@yahoo.com>
> wrote:
> > Hi-
> >
> > In version 1.1 in velocity-tools I used to pull
> the
> > date format String from a resource bundle.  This
> was
> > nice because it let me put the date in month, day,
> > year order for US English and year, month, day
> order
> > for Japanese.
> 
> good way to go.
> 
> > Here is the code that I used:
> >
> > $date.format(
> > $text.get("admin.form.date.arrival.format"),
> > $order.arrivalTime, $request.getLocale() )
> >
> > but now with version 1.2 of velocity-tools, the
> > call to get the date format in this statement:
> > $text.get("admin.form.date.arrival.format")
> > isn't being executed from within the date tool
> format
> > method like it did in version 1.1.
> 
> hmm.  wish i had thought of that use case some time
> ago.  this isn't
> due to any change in DateTool.  it's because of a
> change in
> MessageTool.  $text.get('foo') no longer returns a
> string.  it returns
> a TextKey to allow shorthand use like
> $text.admin.form.date.arrival.format
> 
> sorry about that.  we should probably change tool
> methods that accept
> strings to accept Objects and just do
> String.valueOf() on them.  i'll
> make a note to do this before 1.3 is out.
> 
> > Does anyone know of a work around?
> 
> you should be able to do:
> 
> $date.format("$text.admin.form.date.arrival",
> $order.arrivalTime,
> $request.locale)
> 
> or at least
> 
>
$date.format($text.admin.form.date.arrival.toString(),
> $order.arrivalTime, $request.locale)
> 
> and just as a tangential tip, if you will be
> retrieving a lot of date
> format strings from your message resources on that
> page, you can
> simplify things a bit by doing things like:
> 
> #set( $format = $text.admin.form.date )
> 
> and then
> 
> $date.format("$format.arrival", $order.arrivalTime,
> $request.locale)
> $date.format("$format.departure",
> $order.departureTime, $request.locale)
> 
> :)
> 

Accessing the resource via:
"$text.admin.form.date.arrival"

worked like a charm!  And thanks for the tip!


Cheers,

David



__________________________________________________
Do You Yahoo!?
Tired of spam?  Yahoo! Mail has the best spam protection around 
http://mail.yahoo.com 

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


Re: velocity-tools-1.1 to 1.2 upgrade and the date tool

Posted by Nathan Bubna <nb...@gmail.com>.
On 1/10/06, David Sperling <zz...@yahoo.com> wrote:
> Hi-
>
> In version 1.1 in velocity-tools I used to pull the
> date format String from a resource bundle.  This was
> nice because it let me put the date in month, day,
> year order for US English and year, month, day order
> for Japanese.

good way to go.

> Here is the code that I used:
>
> $date.format(
> $text.get("admin.form.date.arrival.format"),
> $order.arrivalTime, $request.getLocale() )
>
> but now with version 1.2 of velocity-tools, the
> call to get the date format in this statement:
> $text.get("admin.form.date.arrival.format")
> isn't being executed from within the date tool format
> method like it did in version 1.1.

hmm.  wish i had thought of that use case some time ago.  this isn't
due to any change in DateTool.  it's because of a change in
MessageTool.  $text.get('foo') no longer returns a string.  it returns
a TextKey to allow shorthand use like
$text.admin.form.date.arrival.format

sorry about that.  we should probably change tool methods that accept
strings to accept Objects and just do String.valueOf() on them.  i'll
make a note to do this before 1.3 is out.

> Does anyone know of a work around?

you should be able to do:

$date.format("$text.admin.form.date.arrival", $order.arrivalTime,
$request.locale)

or at least

$date.format($text.admin.form.date.arrival.toString(),
$order.arrivalTime, $request.locale)

and just as a tangential tip, if you will be retrieving a lot of date
format strings from your message resources on that page, you can
simplify things a bit by doing things like:

#set( $format = $text.admin.form.date )

and then

$date.format("$format.arrival", $order.arrivalTime, $request.locale)
$date.format("$format.departure", $order.departureTime, $request.locale)

:)

>
> __________________________________________________
> Do You Yahoo!?
> Tired of spam?  Yahoo! Mail has the best spam protection around
> http://mail.yahoo.com
>
> ---------------------------------------------------------------------
> 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


velocity-tools-1.1 to 1.2 upgrade and the date tool

Posted by David Sperling <zz...@yahoo.com>.
Hi-

In version 1.1 in velocity-tools I used to pull the
date format String from a resource bundle.  This was
nice because it let me put the date in month, day,
year order for US English and year, month, day order
for Japanese.  Here is the code that I used:

$date.format(
$text.get("admin.form.date.arrival.format"),
$order.arrivalTime, $request.getLocale() )

but now with version 1.2 of velocity-tools, the 
call to get the date format in this statement:
$text.get("admin.form.date.arrival.format")
isn't being executed from within the date tool format
method like it did in version 1.1.

Does anyone know of a work around?


__________________________________________________
Do You Yahoo!?
Tired of spam?  Yahoo! Mail has the best spam protection around 
http://mail.yahoo.com 

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


Re: Veltag and tools

Posted by Nathan Bubna <nb...@gmail.com>.
Veltag and VelocityTools have not yet been made to work together. 
this is something we plan to do after we get velocity tools 1.2
released.

however, i have talked over how to integrate the two of them before. 
read the messages in this thread for complete instructions:

http://marc.theaimsgroup.com/?t=108212363800008&r=1&w=2

On 11/10/05, Rafał Gierusz <su...@tlen.pl> wrote:
> Hello,
>
> I'm trying to use Veltag in my JSP page. My code for velocity in my
> JSP page look like this (first two lines for vel test - works):
>
> <vel:velocity>
>   #if (true) true #end
>   #if (!false) & false #end
>   <br>
>   $date.get("yyyy-M-d H:m:s")
> </vel:velocity>
>
> my output is:
>
> true & false
> $date.get("yyyy-M-d H:m:s")
>
> so, $date.get("yyyy-M-d H:m:s") is not evaluated, this line works if I
> use it with *.vm page. When using Veltag in JSP I get also error in
> log file:
>
> 2005-11-10 13:25:43 org.apache.catalina.core.ApplicationContext log
> INFO:  Velocity   [warn] org.apache.velocity.runtime.exception.ReferenceException: reference : template = JSP for me! [line 5,column 11] : $date.get("yyyy-M-d H:m:s") is not a valid reference.
>
> my tool config look like this:
>
> <tool>
>   <key>date</key>
>   <scope>application</scope>
>   <class>org.apache.velocity.tools.generic.DateTool</class>
> </tool>
>
> I'am quite sure that I can't use any velocity tool im my JSP.
>
> Anybody can help me?
>
> Michal
>
>
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: velocity-user-unsubscribe@jakarta.apache.org
> For additional commands, e-mail: velocity-user-help@jakarta.apache.org
>
>