On Mar 16, 2004, at 1:04 PM, SainTiss wrote:


-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1

Ok, the reason of setValue failing seems to be that an exception is thrown...
That's what I get in the velocity.log file:


[error] ASTReference setValue() : exception :
java.lang.StringIndexOutOfBoundsException : String index out of range:
3 template = templates/TransFlow.vsl [24,8]


I guess that does look like a problem with velocity now...

Could this still be my fault somehow?

Could be - any chance you can give us the whole stack trace? And an example of your usage of the directive? I wouldn't be surprised if there was a bug, but need more info to figure it out.


geir


Thanks,


Hans

On Tuesday 16 March 2004 18:42, SainTiss wrote:
I've been trying to debug the LocalDirective class a bit, and at least I've
tracked down where things go wrong... At the end, the class attempts to
restore the saved values in the context, with this code:


 while(it.hasNext())
            {
                ASTReference ref = (ASTReference) it.next();
                System.out.println("current value: " +
ref.getVariableValue(context, "foo"));
                System.out.println("saved value: " + data.get(ref));

                ref.setValue(context, data.get(ref));
                System.out.println("final value: " +
ref.getVariableValue(context, "foo"));
            }

The odd thing is that, in my example, "current value" is 2 and "saved
value" is 1, which means that the value has been saved correctly. However,
"final value" is 2, so it appears as if something goes wrong in the
ref.setValue statement. Is there an explanation for this?


Thanks,

Hans

On Tuesday 16 March 2004 18:24, SainTiss wrote:
Hrmm, unexpectedly, replacing velocity-dep-1.2.jar with
velocity-dep-1.3.1.jar does seem to solve the parse errors, but now the
#local directive just seems to be ignored...


i.e. the following example:
#set($foo=1)
#local($foo)
#set($foo=2)
#end
$foo

outputs 2 instead of 1

It does appear as if the LocalDirective.class is found now, because if I
remove the file from the classpath, I get parse errors again, but
obviously it's still not as it should be.


I suppose the LocalDirective class should work, so then I must be doing
something wrong... Maybe it's no good to just replace
velocity-dep-1.2.jar with velocity-dep-1.3.1.jar for example?


Thanks,

Hans

On Tuesday 16 March 2004 18:09, SainTiss wrote:
Hi,

I'm trying to get this local directive to work, which, according to the
FAQ, shouldn't be difficult, but still...


Basically, what I did is create a velocity.properties file with 1 line:
userdirective = LocalDirective


I'm using velocity from an application which initializes the engine as
follows:
velocityPropertiesFile = new File("velocity.properties");
fis = new FileInputStream(velocityPropertiesFile);
velocityProperties.load(fis);
ExtendedProperties ep =
ExtendedProperties.convertProperties(velocityProperties);
ve.setExtendedProperties(ep);
ve.init();


I checked, and after the init() call, getProperty("userdirective")
indeed returns a string "LocalDirective", so the property is set.

Yet, trying to use a template with the #local directive doesn't work,
as I'm getting parse errors.


So I guess the problem must be that the LocalDirective.class isn't
found then? I don't see any errors in the velocity.log which indicate
that though... I just put LocalDirective.class on the classpath, but
that doesn't seem to work then? Where exactly should I put it?


Also, I'm using velocity 1.2, but that can't be the problem, right?

Thanks,

Hans

- -- Ark Linux - Linux for the Masses (http://arklinux.org)

Capitalism:
You don't have any cows. The bank will not lend you money to buy cows,
because you don't have any cows to put up as collateral.

Representative Democracy:
You have two cows. Your neighbors pick someone to tell you who gets the milk.


In a world without walls and fences, who needs windows and gates?

Hans Schippers
2LIC INF
UA 2003-2004
-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.2.3 (GNU/Linux)

iD8DBQFAV0G3XlnUYIbmLOQRApEqAJ45gWYLh5OdJ9+1kwDKzN5uCVAijgCfZvKZ
itkxy/Ce2tSZ3Me1TQIW71k=
=QPaa
-----END PGP SIGNATURE-----


--------------------------------------------------------------------- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]


--
Geir Magnusson Jr                                   203-247-1713(m)
[EMAIL PROTECTED]


--------------------------------------------------------------------- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]



Reply via email to