we know this #set($a = $a + 1) will change $a which in some cases may not be
preferable...but thanks anyway.
2009/7/20 Alexander
> Hi,
>
> Use
>
> #set($a = $a + 1) [?]
>
>
> Correct me if Im wrong but if u use variable like this it would write
> "hello" on a single line, where is the problem? [?
Hi,
Use $velocityCount in place where you need incremental value of some
variable
Eg: instead of,
#set($a = 0)
#foreach($mapping in $mappings)
Do something..
#set($a = $a+1)
Type something
Do it like:
#foreach($mapping in $mappings)
Do something..
Type something
$
thanks Rupali,
I got this problem when I started to think that, can I simply output an
expression like #{1+2+20*3+$a} without a varible?
2009/7/20 Rupali Gupta
> Hi,
>
>
>
> Use $velocityCount in place where you need incremental value of some
> variable
>
> Eg: instead of,
>
>
>
> #set($a
Hello,everyone,I work on the problem this whole afternoon...
finally,I decided to end this with a macro:
#macro(expr $expression)
#set($temp--='#set($temp---'+"=$expression)"+'$temp---')
#evaluate($temp--)
$temp---
#end
#set($a=2)
#expr("$a*100+200")
which result in a 400.
wait for an easier way f
Yeah, but $velocityCount starts counting from 1 not from 0, don't it? Tricky
moment so.
2009/7/20 Rupali Gupta
> Hi,
>
>
>
> Use $velocityCount in place where you need incremental value of some
> variable
>
> Eg: instead of,
>
>
>
> #set($a = 0)
>
> #foreach($mapping in $mappings)
>
> Do someth
On Mon, Jul 20, 2009 at 12:49 AM, lanxiazhi wrote:
> thanks Rupali,
> I got this problem when I started to think that, can I simply output an
> expression like #{1+2+20*3+$a} without a varible?
The macro is fine. Alternately, you could add an instance of the
MathTool (from VelocityTools) to
Maybe you should find some class that can parse and evaluate math string
(like "1+2+3*3 + 8/2") andthen use it in macro?
#macro(calc $expr)
$mathHelper.calculate($expr)
#end
I see you are trying to write ur own parser and I dont think It is a good
idea. There should be a lot of
such classes in in
Oh, didnt know that it can be configured, really thanks! [?] Anyway default
behaviour not obvious for javadev.
2009/7/20 Nathan Bubna
> On Mon, Jul 20, 2009 at 12:49 AM, lanxiazhi wrote:
> > thanks Rupali,
> > I got this problem when I started to think that, can I simply output an
> > expression
On Mon, Jul 20, 2009 at 7:02 AM, Alexander wrote:
>
> Oh, didnt know that it can be configured, really thanks! Anyway default
> behaviour not obvious for javadev.
The rational was that it wasn't just meant for javadevs and javadevs
would be able to figure it out. I'm willing to reconsider thi
I mean that always people say that you could use it in foreach statement and
gives completely incorrect example as we saw there. So I tried to stress
that initial value default is 1 not 0. Sure javadev can figure it out, but
with wrong example in front of eyes it would be mentally harder.
2009/7/20
Yes,Alexander,and I google it,and i found one choice:jep.and maybe javacc is
another choice for this.
by the way,besides evaluating math expression ,my macro can insert varibles
in it.
like expr("$a+100*$b").
still I think this is not a good way to do it,maybe next version of velocity
will support
lanxiazhi,
> by the way,besides evaluating math expression ,my macro can insert
> varibles in it.
like expr("$a+100*$b").
Before you passing "$a + 100*$b" to method parameters Velocity automatically
gonna replace all variables with values, remember?
> #macro(calc $expr)
$mathHelper.calculat
hello,try it this way,with single quote,
#expr('$a+$b*300')
which works as expected.
2009/7/20 Alexander
> lanxiazhi,
>
>
> > by the way,besides evaluating math expression ,my macro can insert
> > varibles in it.
>
> like expr("$a+100*$b").
>
>
> Before you passing "$a + 100*$b" to method param
I meant passing such string without single quote to method as parameter
eventually leads to same result: variables replaced with values and
expression calculated. But using some math helper class is more flexible
than writing your own macros.
2009/7/20 lanxiazhi
> hello,try it this way,with sing
ok,you're right,now i got what you mean.
just a moment ago,I realized that I need no such math helper or such
compicated macro as I wrote at all.If I have a velocity tool class called
Simple,which contains a method :
double f(double d)
{return d};
then I can use it in the template:$Simple.f($a+100*
Using Velocity 1.6.2 I wish to output the string "#".
In my template, I code it "\#\#\#\#\#"
It renders as \#\#\#\#\#.
What am I doing wrong? Or how can I make it do what I want?
Steve Cohen
-
To unsubscribe, e-mail: user-
I would use the ecsapetool
Thanks,
Jason Tesser
dotCMS Lead Development Manager
1-305-858-1422
On Mon, Jul 20, 2009 at 3:07 PM, Steve Cohen wrote:
> Using Velocity 1.6.2 I wish to output the string "#".
> In my template, I code it "\#\#\#\#\#"
> It renders as \#\#\#\#\#.
>
> What am I doin
Also, the Tools 2.0 documentation seems written from the point of view
that you're upgrading from Tools 1.4. Since I don't currently configure
or use the Tools, I seem to be missing some key concepts. I can't find
the Tools 1.4 documentation.
Steve Cohen wrote:
Thanks. This sounds like the
Thanks. This sounds like the right way to go, yet I currently have a
nice simple configuration based on 1.4. The $esc.hash seems to be a 2.0
thing. I don't use the tools now and it seems like a fairly heavy-duty
upgrade to fix such a small problem, involving configuration files, etc.
that I
Okay, I wrote too soon. I now see the escape tool and its hash method
in tools 1.4. My bad.
I still don't understand what, if anything, I need to do to configure my
application to use it. My present configuation is done entirely in Java:
private void init(ServletContext ctx) throws
Vel
Steve Cohen wrote:
...
(never mind any of what I wrote before, I have now boiled it down to one
hopefully intelligent question):
I am NOT using VelocityView but instantiating, configuring and
initializing a VelocityEngine in java code. I don't use Velocity View.
Since I don't use Veloci
Okay, I found THIS:
http://www.mailinglistarchive.com/velocity-u...@jakarta.apache.org/msg00552.html
and it works, but I'd still rather load the tool at the time the Engine
is initialized, rather than have to put it in the context everywhere I
want to use it. So what I'm really looking for is
I did it in the same way in my projects, and I defined class MathHelper just
using Velocity:)
public Object calculate(String expr)
{
String vtl = "#set($_ooo=" + expr + ")";
VelocityContext vc = ...
Velocity.evaluate...
return vc.get("_ooo");
}
---bluejoe
- Original Message
#set( $hashes = '' )
$hashes
single-quoted strings are not interpolated.
On Mon, Jul 20, 2009 at 12:07 PM, Steve Cohen wrote:
> Using Velocity 1.6.2 I wish to output the string "#".
> In my template, I code it "\#\#\#\#\#"
> It renders as \#\#\#\#\#.
>
> What am I doing wrong? Or how can
In VelocityTools 1.4, there is little support for auto-loading
GenericTools, i wouldn't bother. Just create a context, add tool
instances that you want and then use the already available
context-chaining support in VelocityContext to use that "tool" context
as a base context for other ones.
In Ve
On Mon, Jul 20, 2009 at 5:51 PM, Nathan Bubna wrote:
> In VelocityTools 1.4, there is little support for auto-loading
> GenericTools, i wouldn't bother. Just create a context, add tool
> instances that you want and then use the already available
> context-chaining support in VelocityContext to use
I had the same question before, finally I still chose VelocityView. Since
VelocityView is for webapp, I had to use MockServletContext and
MockServletConfig:
public MyVelocityEngine(ServletContext servletContext, String
velocityPropertiesFile) throws ServletException
{
MockServletConfig msc
Thanks, Nathan, that's probably the easiest way for this edge case.
Nathan Bubna wrote:
#set( $hashes = '' )
$hashes
single-quoted strings are not interpolated.
On Mon, Jul 20, 2009 at 12:07 PM, Steve Cohen wrote:
Using Velocity 1.6.2 I wish to output the string "#".
In my template
Thanks, Nathan. Although your single-quoting thing is the right answer
for this particular situation, this discussion did at least get me
thinking about the Tools, which I haven't used before. They could
provide some value for me in other situations so it's good to learn
about them. Therefor
Hello all,
I am working on a small MVC framework that runs on top of iJetty (a
Jetty port fot the Android platform). I am having trouble during
initialization of Velocity. Take a peek at the following code:
Log.info("Setting Template Directory: "+Configuration.VIEWS_LOC);
File viewsFol
I think you misunderstood a fundametal reason of the UnicodeInputStream class.
It is to use so that template loaders don't need to tell an encoding so all is
fully transparent.
getTemplate(name, encoding) method is an old legacy method where we as a user
must know the encoding beforehand. This
31 matches
Mail list logo