You are viewing a plain text version of this content. The canonical link for it is here.
Posted to jetspeed-user@portals.apache.org by James Wang <to...@yahoo.com> on 2002/09/13 08:58:47 UTC
can i write some java code in Velocity?
sometimes i want to write some java code in
Velocity,not in the portlet code,for example,
i got a object 'java.util.Date',and now i want
to get formatted date string from this object,
in java code,i can
.......
java.text.SimpleDateFormat sdf = new
java.text.SimpleDateFormat("yyyy-MM-dd");
String s = sdf.format(date);
.......
in velocity, how can i do for $sdf.format($date)?
where can i get $sdf, do i have to init a new object
in portlet code and then put it into the context of
jetspeed?
that mean i must do such thing in Module part of
MVC if i adopt Turbine/Jetspeed/Velocity.
but i think the object ,SimpleDateFormat should be
initialized in Velocity,not in the java code of
Portlet.so i can make my code of Module simple.
maybe i dont master the MVC :(:)
any help would be appreciated!
__________________________________________________
Do you Yahoo!?
Yahoo! News - Today's headlines
http://news.yahoo.com
--
To unsubscribe, e-mail: <ma...@jakarta.apache.org>
For additional commands, e-mail: <ma...@jakarta.apache.org>
Re: can i write some java code in Velocity?
Posted by Paul Spencer <pa...@apache.org>.
James,
Velocity is a template engine. It does not support embedded Java. If
you want to embed Java, then use JSP. For more information on Velocity
see http://jakarta.apache.org/velocity
You can also extend the Velocity portlet to add Velocity context
variables which would be useable in you template.
Paul Spencer
James Wang wrote:
> sometimes i want to write some java code in
> Velocity,not in the portlet code,for example,
> i got a object 'java.util.Date',and now i want
> to get formatted date string from this object,
>
> in java code,i can
> .......
> java.text.SimpleDateFormat sdf = new
> java.text.SimpleDateFormat("yyyy-MM-dd");
> String s = sdf.format(date);
> .......
>
> in velocity, how can i do for $sdf.format($date)?
> where can i get $sdf, do i have to init a new object
> in portlet code and then put it into the context of
> jetspeed?
> that mean i must do such thing in Module part of
> MVC if i adopt Turbine/Jetspeed/Velocity.
>
> but i think the object ,SimpleDateFormat should be
> initialized in Velocity,not in the java code of
> Portlet.so i can make my code of Module simple.
>
> maybe i dont master the MVC :(:)
>
> any help would be appreciated!
>
>
>
>
>
>
>
>
>
>
>
> __________________________________________________
> Do you Yahoo!?
> Yahoo! News - Today's headlines
> http://news.yahoo.com
>
> --
> To unsubscribe, e-mail: <ma...@jakarta.apache.org>
> For additional commands, e-mail: <ma...@jakarta.apache.org>
>
>
--
To unsubscribe, e-mail: <ma...@jakarta.apache.org>
For additional commands, e-mail: <ma...@jakarta.apache.org>