You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@velocity.apache.org by "Will Glass-Husain (JIRA)" <de...@velocity.apache.org> on 2009/10/16 19:18:31 UTC

[jira] Created: (VELOCITY-739) Do not throw exception for quiet references in strict reference checking mode

Do not throw exception for quiet references in strict reference checking mode
-----------------------------------------------------------------------------

                 Key: VELOCITY-739
                 URL: https://issues.apache.org/jira/browse/VELOCITY-739
             Project: Velocity
          Issue Type: Improvement
          Components: Engine
    Affects Versions: 1.6.2
            Reporter: Will Glass-Husain


I used strict reference checking for the first time and discovered that it throws exceptions even for quiet references.

<input class="signupInput" type="text" id="StxtFirstNames"
name="firstName" value="$!user.firstName"/>

org.apache.velocity.exception.MethodInvocationException: Variable
$user has not been set at layout/slide_login.vm[line 13, column 117]

This doesn't make sense to me.  If a template author designates a reference as quiet, it's explicitly not an error.  We're preventing the use of this convenient feature.

It's not a hard change to fix this.  Does it break backwards compatibility if we change this?

Incidentally, there's an identical problem for InvalidReferenceEventHandler.  I'll file a separate issue.

-- 
This message is automatically generated by JIRA.
-
You can reply to this email to add a comment to the issue online.


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


[jira] Commented: (VELOCITY-739) Do not throw exception for quiet references in strict reference checking mode

Posted by "Nathan Bubna (JIRA)" <de...@velocity.apache.org>.
    [ https://issues.apache.org/jira/browse/VELOCITY-739?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=12766933#action_12766933 ] 

Nathan Bubna commented on VELOCITY-739:
---------------------------------------

I believe the idea was that, in strict mode, the quiet reference notation is for *null* values, not for missing ones.   A distinction is made in strict reference mode between a reference whose key is present in the context but whose value is null and a reference which has no such key in the context.   The same for properties/method calls.  If there's no such thing, the quiet reference notation won't help you, but if it exists and returns as null, then then you use the quiet ref to keep it from rendering.

Honestly, i'm sympathetic to your view of it, but i think Byron made a stronger case for the current behavior.  In strict reference mode, there's no tolerance for completely "unexpected" references, though it can certainly handle null values quietly.

> Do not throw exception for quiet references in strict reference checking mode
> -----------------------------------------------------------------------------
>
>                 Key: VELOCITY-739
>                 URL: https://issues.apache.org/jira/browse/VELOCITY-739
>             Project: Velocity
>          Issue Type: Improvement
>          Components: Engine
>    Affects Versions: 1.6.2
>            Reporter: Will Glass-Husain
>
> I used strict reference checking for the first time and discovered that it throws exceptions even for quiet references.
> <input class="signupInput" type="text" id="StxtFirstNames"
> name="firstName" value="$!user.firstName"/>
> org.apache.velocity.exception.MethodInvocationException: Variable
> $user has not been set at layout/slide_login.vm[line 13, column 117]
> This doesn't make sense to me.  If a template author designates a reference as quiet, it's explicitly not an error.  We're preventing the use of this convenient feature.
> It's not a hard change to fix this.  Does it break backwards compatibility if we change this?
> Incidentally, there's an identical problem for InvalidReferenceEventHandler.  I'll file a separate issue.

-- 
This message is automatically generated by JIRA.
-
You can reply to this email to add a comment to the issue online.


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


[jira] Commented: (VELOCITY-739) Do not throw exception for quiet references in strict reference checking mode

Posted by "Byron Foster (JIRA)" <de...@velocity.apache.org>.
    [ https://issues.apache.org/jira/browse/VELOCITY-739?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=12772172#action_12772172 ] 

Byron Foster commented on VELOCITY-739:
---------------------------------------

My preference would be the current behavior.  But, it's not a strong preference,  and if most people like the above described behavior, I would not object.

My only argument is that it casts a wider net, and now all references with the bang notation don't benefit as much from strict checking and error reporting.

I'v considered making it so that expressions that evaluate to null, simply render as an empty string without  error, which makes the current use of the bang reference unnecessary.  If someone did want stricter handling of nulls they could do it through handlers.

I assume that the above behavior is only for the root variable, so given:

$!a.b

if 'a' is not in the context, then nothing is rendered. But if 'a' is defined but does not contain the method 'b', or 'a' is null, then Velocity will throw an error.


> Do not throw exception for quiet references in strict reference checking mode
> -----------------------------------------------------------------------------
>
>                 Key: VELOCITY-739
>                 URL: https://issues.apache.org/jira/browse/VELOCITY-739
>             Project: Velocity
>          Issue Type: Improvement
>          Components: Engine
>    Affects Versions: 1.6.2
>            Reporter: Will Glass-Husain
>
> I used strict reference checking for the first time and discovered that it throws exceptions even for quiet references.
> <input class="signupInput" type="text" id="StxtFirstNames"
> name="firstName" value="$!user.firstName"/>
> org.apache.velocity.exception.MethodInvocationException: Variable
> $user has not been set at layout/slide_login.vm[line 13, column 117]
> This doesn't make sense to me.  If a template author designates a reference as quiet, it's explicitly not an error.  We're preventing the use of this convenient feature.
> It's not a hard change to fix this.  Does it break backwards compatibility if we change this?
> Incidentally, there's an identical problem for InvalidReferenceEventHandler.  I'll file a separate issue.

-- 
This message is automatically generated by JIRA.
-
You can reply to this email to add a comment to the issue online.


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


[jira] Commented: (VELOCITY-739) Do not throw exception for quiet references in strict reference checking mode

Posted by "Will Glass-Husain (JIRA)" <de...@velocity.apache.org>.
    [ https://issues.apache.org/jira/browse/VELOCITY-739?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=12767092#action_12767092 ] 

Will Glass-Husain commented on VELOCITY-739:
--------------------------------------------

Thanks for the comments,

I think there's a pretty good argument for having "strict" ignore silent references.  After all, the template author is explicitly calling out a silent reference as "may or may not be present" and doesn't need these called out as errors.  

In my templates, at least, we make little distinction between null and invalid.  The example given ($user) is a good one.  If a user is logged in, $user is in the context.  If not, there is no $user.

Right now silent references are basically useless if you want to strictly check references.

Still, I'm late to this party so am reluctant to strongly advocate this.  I'll leave this bug open, see if Byron or others actually using this feature chime in.  

If we can make the change in SIMULATE-740, then I'm ok with leaving strict mode as is.  That provides a mechanism to do a pseudo-strict mode that flags errors for regular references and ignores silent references.  



> Do not throw exception for quiet references in strict reference checking mode
> -----------------------------------------------------------------------------
>
>                 Key: VELOCITY-739
>                 URL: https://issues.apache.org/jira/browse/VELOCITY-739
>             Project: Velocity
>          Issue Type: Improvement
>          Components: Engine
>    Affects Versions: 1.6.2
>            Reporter: Will Glass-Husain
>
> I used strict reference checking for the first time and discovered that it throws exceptions even for quiet references.
> <input class="signupInput" type="text" id="StxtFirstNames"
> name="firstName" value="$!user.firstName"/>
> org.apache.velocity.exception.MethodInvocationException: Variable
> $user has not been set at layout/slide_login.vm[line 13, column 117]
> This doesn't make sense to me.  If a template author designates a reference as quiet, it's explicitly not an error.  We're preventing the use of this convenient feature.
> It's not a hard change to fix this.  Does it break backwards compatibility if we change this?
> Incidentally, there's an identical problem for InvalidReferenceEventHandler.  I'll file a separate issue.

-- 
This message is automatically generated by JIRA.
-
You can reply to this email to add a comment to the issue online.


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


[jira] Commented: (VELOCITY-739) Do not throw exception for quiet references in strict reference checking mode

Posted by "Will Glass-Husain (JIRA)" <de...@velocity.apache.org>.
    [ https://issues.apache.org/jira/browse/VELOCITY-739?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=12772850#action_12772850 ] 

Will Glass-Husain commented on VELOCITY-739:
--------------------------------------------


In the interests of conservatism, I'm going to leave this alone.    If more people want it speak up.

> Do not throw exception for quiet references in strict reference checking mode
> -----------------------------------------------------------------------------
>
>                 Key: VELOCITY-739
>                 URL: https://issues.apache.org/jira/browse/VELOCITY-739
>             Project: Velocity
>          Issue Type: Improvement
>          Components: Engine
>    Affects Versions: 1.6.2
>            Reporter: Will Glass-Husain
>
> I used strict reference checking for the first time and discovered that it throws exceptions even for quiet references.
> <input class="signupInput" type="text" id="StxtFirstNames"
> name="firstName" value="$!user.firstName"/>
> org.apache.velocity.exception.MethodInvocationException: Variable
> $user has not been set at layout/slide_login.vm[line 13, column 117]
> This doesn't make sense to me.  If a template author designates a reference as quiet, it's explicitly not an error.  We're preventing the use of this convenient feature.
> It's not a hard change to fix this.  Does it break backwards compatibility if we change this?
> Incidentally, there's an identical problem for InvalidReferenceEventHandler.  I'll file a separate issue.

-- 
This message is automatically generated by JIRA.
-
You can reply to this email to add a comment to the issue online.


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


[jira] Commented: (VELOCITY-739) Do not throw exception for quiet references in strict reference checking mode

Posted by "Nathan Bubna (JIRA)" <de...@velocity.apache.org>.
    [ https://issues.apache.org/jira/browse/VELOCITY-739?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=12766937#action_12766937 ] 

Nathan Bubna commented on VELOCITY-739:
---------------------------------------

Either "quiet" looses some meaning or "strict" looses some meaning.   Since i don't use strict mode, i'll happily defer to those who do use it on this issue.

> Do not throw exception for quiet references in strict reference checking mode
> -----------------------------------------------------------------------------
>
>                 Key: VELOCITY-739
>                 URL: https://issues.apache.org/jira/browse/VELOCITY-739
>             Project: Velocity
>          Issue Type: Improvement
>          Components: Engine
>    Affects Versions: 1.6.2
>            Reporter: Will Glass-Husain
>
> I used strict reference checking for the first time and discovered that it throws exceptions even for quiet references.
> <input class="signupInput" type="text" id="StxtFirstNames"
> name="firstName" value="$!user.firstName"/>
> org.apache.velocity.exception.MethodInvocationException: Variable
> $user has not been set at layout/slide_login.vm[line 13, column 117]
> This doesn't make sense to me.  If a template author designates a reference as quiet, it's explicitly not an error.  We're preventing the use of this convenient feature.
> It's not a hard change to fix this.  Does it break backwards compatibility if we change this?
> Incidentally, there's an identical problem for InvalidReferenceEventHandler.  I'll file a separate issue.

-- 
This message is automatically generated by JIRA.
-
You can reply to this email to add a comment to the issue online.


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


[jira] Commented: (VELOCITY-739) Do not throw exception for quiet references in strict reference checking mode

Posted by "Claude Brisson (JIRA)" <de...@velocity.apache.org>.
    [ https://issues.apache.org/jira/browse/VELOCITY-739?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=12766935#action_12766935 ] 

Claude Brisson commented on VELOCITY-739:
-----------------------------------------

I'd be +1 not to differentiate null and inexistent references in this case. Otherwise quietness  looses some meaning here.

> Do not throw exception for quiet references in strict reference checking mode
> -----------------------------------------------------------------------------
>
>                 Key: VELOCITY-739
>                 URL: https://issues.apache.org/jira/browse/VELOCITY-739
>             Project: Velocity
>          Issue Type: Improvement
>          Components: Engine
>    Affects Versions: 1.6.2
>            Reporter: Will Glass-Husain
>
> I used strict reference checking for the first time and discovered that it throws exceptions even for quiet references.
> <input class="signupInput" type="text" id="StxtFirstNames"
> name="firstName" value="$!user.firstName"/>
> org.apache.velocity.exception.MethodInvocationException: Variable
> $user has not been set at layout/slide_login.vm[line 13, column 117]
> This doesn't make sense to me.  If a template author designates a reference as quiet, it's explicitly not an error.  We're preventing the use of this convenient feature.
> It's not a hard change to fix this.  Does it break backwards compatibility if we change this?
> Incidentally, there's an identical problem for InvalidReferenceEventHandler.  I'll file a separate issue.

-- 
This message is automatically generated by JIRA.
-
You can reply to this email to add a comment to the issue online.


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