I've got a patch that checks property calls on objects, and throws a
MethodInvocationException when the property doesn't exist. However,
this really isn't a complete solution. This mode should also check
that variables are defined. Otherwise, you get the following strange
behavior that $foo.bar will throw an exception if the bar property
does not exist, but if foo is not defined, then nothing happens with
$foo.bar, which I think is unexpected behavior. Also, I think
variables should be checked for the same reasons as methods, mainly
that an undefined variable is probably a typo.
This leads to the next change. Variables should be able to contain
null values, otherwise it's impossible to distinguish between a
variable that is null, and a variable that is not defined. This
should have no impact on how Velocity works now since the
VelocityContext returns null in the case that a variable is null, and
a variable is not in the hash. I can provide a patch for these
changes also.
In the context of not allowing defined variables it would be nice to
be able to set a variable only when it is undefined. I was thinking of
a syntax like #set($foo ~= "bar"). This gives the developer the
ability to define default parameters to templates, and in some
contexts this may be necessary. This also provides an easy mechanism
for people who are converting existing templates over to the stricter
reference mode since they could define these #set statements for any
variables which are referenced in a template, but are not always
defined. I'm not sure what is involved in making this change...
Is this something appropriate for a beta build? I feel that maybe just
the method checking is half working... And then when variables are
added that's just another option to be set. Thoughts?
On Sep 27, 2008, at 10:26 , Nathan Bubna wrote:
This issue is still slated for 1.6, but no patches have yet been
contributed, nor has any committer taken the issue up yet. Help would
be appreciated, of course. :)
On Sat, Sep 27, 2008 at 4:39 AM, Byron Foster <[EMAIL PROTECTED]> wrote:
Hello, I was wondering if the issue
https://issues.apache.org/jira/browse/VELOCITY-553 was something
that was
slated for velocity 1.6. Or, if there are any settings in 1.6
which would
force velocity to throw an exception if an object does not have a
given
property?
---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]