You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@velocity.apache.org by "Tomáš Procházka (JIRA)" <de...@velocity.apache.org> on 2007/06/06 08:47:25 UTC

[jira] Created: (VELOCITY-553) Posibility to configure ReportInvalidReferences to don't report report variables,properties and method which exist, but only have null value

Posibility to configure ReportInvalidReferences to don't report report variables,properties and method which exist, but only have null value
--------------------------------------------------------------------------------------------------------------------------------------------

                 Key: VELOCITY-553
                 URL: https://issues.apache.org/jira/browse/VELOCITY-553
             Project: Velocity
          Issue Type: Improvement
          Components: Engine
    Affects Versions: 1.5
         Environment: any
            Reporter: Tomáš Procházka


ReportInvalidReferences has very big imperfection, it report by default all variables, properties and method which has null value.
This may cause many problems for developer.

I for example need only validate template without any data, only check which contain right variables, properties or method (which exist), it's value is not important for me.

I tried use my own ReferenceInsertionEventHandler for replace null value with "" (empty String) but Velocity call InvalidReference handler before ReferenceInsertionEventHandler.

I suggest configuration options for this (repor or doesn't report null value)

-- 
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-553) Posibility to configure ReportInvalidReferences to don't report report variables,properties and method which exist, but only have null value

Posted by "Renato Steiner (JIRA)" <de...@velocity.apache.org>.
    [ https://issues.apache.org/jira/browse/VELOCITY-553?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=12828102#action_12828102 ] 

Renato Steiner commented on VELOCITY-553:
-----------------------------------------

I have noticed that Velocity makes a difference between accessing a property vs. accessing the property via a property accessor method:
Note: $util.isNull is a simple utility  method in one of the classes I unfortunately cannot attach. But you can simply create a utility method in one of your own classes which returns true if the params value is null.

=> The code below results in the invocation of InvalidReferenceEventHandler::invalidGetMethod(Context, String, Object, String, Info). 

         #set ($objRef = $util.getTestObject())
         #if ($util.isNull($objRef.nullValueAttribute))
            #debugMsg("@@util.isNull(objRef.nullValueAttribute) => isNull==true")
         #else
            #debugMsg("@@objRef.nullValueAttribute=$objRef.nullValueAttribute")
         #end

---------

=> The code below works correctly:

         #set ($objRef = $util.getTestObject())
         #if ($util.isNull($objRef.getNullValueAttribute()))
            #debugMsg("@@util.isNull(objRef.getNullValueAttribute()) => isNull==true")
         #else
            #debugMsg("@@objRef.nullValueAttribute=$objRef.nullValueAttribute")
         #end

---------

I have created and attached a new unit test which can be used to verify the desired behavior.
If the patch is applied, the InvalidEventHandlerTestCase.java test case should run without errors.
If you uncomment the documented code segments, errors will appear until the bug is fixed.

Notes: 
Single testcase execution (requires the patch: velocity-661-v1.0.patch -> http://issues.apache.org/jira/browse/VELOCITY-661)
$ ant -Dtestcase=org.apache.velocity.test.InvalidEventHandlerTestCase test

Related: 
http://issues.apache.org/jira/browse/VELOCITY-618
https://issues.apache.org/jira/browse/VELOCITY-423
http://wiki.apache.org/velocity/VelocityNullSupport

> Posibility to configure ReportInvalidReferences to don't report report variables,properties and method which exist, but only have null value
> --------------------------------------------------------------------------------------------------------------------------------------------
>
>                 Key: VELOCITY-553
>                 URL: https://issues.apache.org/jira/browse/VELOCITY-553
>             Project: Velocity
>          Issue Type: Improvement
>          Components: Engine
>    Affects Versions: 1.5
>         Environment: any
>            Reporter: Tomáš Procházka
>             Fix For: 1.7
>
>         Attachments: InvalidEventHandlerTestCase.java.patch
>
>
> ReportInvalidReferences has very big imperfection, it report by default all variables, properties and method which has null value.
> This may cause many problems for developer.
> I for example need only validate template without any data, only check which contain right variables, properties or method (which exist), it's value is not important for me.
> I tried use my own ReferenceInsertionEventHandler for replace null value with "" (empty String) but Velocity call InvalidReference handler before ReferenceInsertionEventHandler.
> I suggest configuration options for this (repor or doesn't report null value)

-- 
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] Issue Comment Edited: (VELOCITY-553) Posibility to configure ReportInvalidReferences to don't report report variables,properties and method which exist, but only have null value

Posted by "Renato Steiner (JIRA)" <de...@velocity.apache.org>.
    [ https://issues.apache.org/jira/browse/VELOCITY-553?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=12828103#action_12828103 ] 

Renato Steiner edited comment on VELOCITY-553 at 2/2/10 4:30 PM:
-----------------------------------------------------------------

Attached a modified Unit Test in order to reproduce the behavior of velocity when a method returns null.

      was (Author: honato11):
    Added code to test the behavior of velocity when a method returns null.
  
> Posibility to configure ReportInvalidReferences to don't report report variables,properties and method which exist, but only have null value
> --------------------------------------------------------------------------------------------------------------------------------------------
>
>                 Key: VELOCITY-553
>                 URL: https://issues.apache.org/jira/browse/VELOCITY-553
>             Project: Velocity
>          Issue Type: Improvement
>          Components: Engine
>    Affects Versions: 1.5
>         Environment: any
>            Reporter: Tomáš Procházka
>             Fix For: 1.7
>
>         Attachments: InvalidEventHandlerTestCase.java.patch
>
>
> ReportInvalidReferences has very big imperfection, it report by default all variables, properties and method which has null value.
> This may cause many problems for developer.
> I for example need only validate template without any data, only check which contain right variables, properties or method (which exist), it's value is not important for me.
> I tried use my own ReferenceInsertionEventHandler for replace null value with "" (empty String) but Velocity call InvalidReference handler before ReferenceInsertionEventHandler.
> I suggest configuration options for this (repor or doesn't report null value)

-- 
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] Issue Comment Edited: (VELOCITY-553) Posibility to configure ReportInvalidReferences to don't report report variables,properties and method which exist, but only have null value

Posted by "Renato Steiner (JIRA)" <de...@velocity.apache.org>.
    [ https://issues.apache.org/jira/browse/VELOCITY-553?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=12828103#action_12828103 ] 

Renato Steiner edited comment on VELOCITY-553 at 2/2/10 4:30 PM:
-----------------------------------------------------------------

Attached a modified Unit Test (InvalidEventHandlerTestCase.java.patch) in order to reproduce the behavior of velocity when a method returns null.

      was (Author: honato11):
    Attached a modified Unit Test in order to reproduce the behavior of velocity when a method returns null.
  
> Posibility to configure ReportInvalidReferences to don't report report variables,properties and method which exist, but only have null value
> --------------------------------------------------------------------------------------------------------------------------------------------
>
>                 Key: VELOCITY-553
>                 URL: https://issues.apache.org/jira/browse/VELOCITY-553
>             Project: Velocity
>          Issue Type: Improvement
>          Components: Engine
>    Affects Versions: 1.5
>         Environment: any
>            Reporter: Tomáš Procházka
>             Fix For: 1.7
>
>         Attachments: InvalidEventHandlerTestCase.java.patch
>
>
> ReportInvalidReferences has very big imperfection, it report by default all variables, properties and method which has null value.
> This may cause many problems for developer.
> I for example need only validate template without any data, only check which contain right variables, properties or method (which exist), it's value is not important for me.
> I tried use my own ReferenceInsertionEventHandler for replace null value with "" (empty String) but Velocity call InvalidReference handler before ReferenceInsertionEventHandler.
> I suggest configuration options for this (repor or doesn't report null value)

-- 
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-553) Posibility to configure ReportInvalidReferences to don't report report variables,properties and method which exist, but only have null value

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

Byron Foster commented on VELOCITY-553:
---------------------------------------

One more comment, the reason why ReportInvalidReference works the way it does is that before strict mode was added there was no distinction in Velocity between a null value and a non-exiting key.  An attempt to place a key into the context with a null value would be ignored.  strict mode changed that so now there is a distinction.


> Posibility to configure ReportInvalidReferences to don't report report variables,properties and method which exist, but only have null value
> --------------------------------------------------------------------------------------------------------------------------------------------
>
>                 Key: VELOCITY-553
>                 URL: https://issues.apache.org/jira/browse/VELOCITY-553
>             Project: Velocity
>          Issue Type: Improvement
>          Components: Engine
>    Affects Versions: 1.5
>         Environment: any
>            Reporter: Tomáš Procházka
>             Fix For: 1.6
>
>
> ReportInvalidReferences has very big imperfection, it report by default all variables, properties and method which has null value.
> This may cause many problems for developer.
> I for example need only validate template without any data, only check which contain right variables, properties or method (which exist), it's value is not important for me.
> I tried use my own ReferenceInsertionEventHandler for replace null value with "" (empty String) but Velocity call InvalidReference handler before ReferenceInsertionEventHandler.
> I suggest configuration options for this (repor or doesn't report null value)

-- 
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-553) Posibility to configure ReportInvalidReferences to don't report report variables,properties and method which exist, but only have null value

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

Nathan Bubna commented on VELOCITY-553:
---------------------------------------

Yes, that makes perfect sense to me.

> Posibility to configure ReportInvalidReferences to don't report report variables,properties and method which exist, but only have null value
> --------------------------------------------------------------------------------------------------------------------------------------------
>
>                 Key: VELOCITY-553
>                 URL: https://issues.apache.org/jira/browse/VELOCITY-553
>             Project: Velocity
>          Issue Type: Improvement
>          Components: Engine
>    Affects Versions: 1.5
>         Environment: any
>            Reporter: Tomáš Procházka
>             Fix For: 1.6
>
>
> ReportInvalidReferences has very big imperfection, it report by default all variables, properties and method which has null value.
> This may cause many problems for developer.
> I for example need only validate template without any data, only check which contain right variables, properties or method (which exist), it's value is not important for me.
> I tried use my own ReferenceInsertionEventHandler for replace null value with "" (empty String) but Velocity call InvalidReference handler before ReferenceInsertionEventHandler.
> I suggest configuration options for this (repor or doesn't report null value)

-- 
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-553) Posibility to configure ReportInvalidReferences to don't report report variables,properties and method which exist, but only have null value

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

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

Good comment. Rather than a configuration option, we should just change the behavior. 

It's an experimental feature, seems ok to me alter.

Targeting for 1.6.

> Posibility to configure ReportInvalidReferences to don't report report variables,properties and method which exist, but only have null value
> --------------------------------------------------------------------------------------------------------------------------------------------
>
>                 Key: VELOCITY-553
>                 URL: https://issues.apache.org/jira/browse/VELOCITY-553
>             Project: Velocity
>          Issue Type: Improvement
>          Components: Engine
>    Affects Versions: 1.5
>         Environment: any
>            Reporter: Tomáš Procházka
>             Fix For: 1.6
>
>
> ReportInvalidReferences has very big imperfection, it report by default all variables, properties and method which has null value.
> This may cause many problems for developer.
> I for example need only validate template without any data, only check which contain right variables, properties or method (which exist), it's value is not important for me.
> I tried use my own ReferenceInsertionEventHandler for replace null value with "" (empty String) but Velocity call InvalidReference handler before ReferenceInsertionEventHandler.
> I suggest configuration options for this (repor or doesn't report null value)

-- 
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-553) Posibility to configure ReportInvalidReferences to don't report report variables,properties and method which exist, but only have null value

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

Byron Foster commented on VELOCITY-553:
---------------------------------------

Really, strict mode VELOCITY-618 provides the functionality that I think the creator of this issue seeks. I think several of us have gone down the road of wanting strict type behavior and have looked into this to find that it doesn't distinguish between and invalid reference, and a reference that returns null :(.

However,  I think Will's comments above are exactly right for the desired behavior, and it parallels the same cases in which strict mode throws exceptions.   ReportInvalidReference could be implemented as Will has outlined by simply making the call at every point that strict mode throws an exception.

Further,  you could replace all instances where strict mode throws exceptions with a default implementation of ReportInvalidReference that throws an exception.  Even though you would have to augment the parameters passed so that you could provide the same level of informative error messages.  For 2.0 this would make this type of handling nicely plugable.  I would make strict the default, and drop the option.. then people could use an "anything goes" ReportInvalidReference if they wanted older behavior  :)






> Posibility to configure ReportInvalidReferences to don't report report variables,properties and method which exist, but only have null value
> --------------------------------------------------------------------------------------------------------------------------------------------
>
>                 Key: VELOCITY-553
>                 URL: https://issues.apache.org/jira/browse/VELOCITY-553
>             Project: Velocity
>          Issue Type: Improvement
>          Components: Engine
>    Affects Versions: 1.5
>         Environment: any
>            Reporter: Tomáš Procházka
>             Fix For: 1.6
>
>
> ReportInvalidReferences has very big imperfection, it report by default all variables, properties and method which has null value.
> This may cause many problems for developer.
> I for example need only validate template without any data, only check which contain right variables, properties or method (which exist), it's value is not important for me.
> I tried use my own ReferenceInsertionEventHandler for replace null value with "" (empty String) but Velocity call InvalidReference handler before ReferenceInsertionEventHandler.
> I suggest configuration options for this (repor or doesn't report null value)

-- 
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-553) Posibility to configure ReportInvalidReferences to don't report report variables,properties and method which exist, but only have null value

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

Trejkaz commented on VELOCITY-553:
----------------------------------

What I find surprising about this is that it results in errors when checking for existence of the object.

e.g., this works if you don't override the handler:

-- --

class A {
    public String getValue() { return null; }
}

-- --

context.put("record", new A());

-- --

#if( $record.value )
 $record. value
#end

-- --

But if you override the handler you will get an error from the #if line.  So even if you wanted to detect null values before you reference them, the normal way of doing it in the template doesn't work either because you get an error before you can.



> Posibility to configure ReportInvalidReferences to don't report report variables,properties and method which exist, but only have null value
> --------------------------------------------------------------------------------------------------------------------------------------------
>
>                 Key: VELOCITY-553
>                 URL: https://issues.apache.org/jira/browse/VELOCITY-553
>             Project: Velocity
>          Issue Type: Improvement
>          Components: Engine
>    Affects Versions: 1.5
>         Environment: any
>            Reporter: Tomáš Procházka
>             Fix For: 1.7
>
>
> ReportInvalidReferences has very big imperfection, it report by default all variables, properties and method which has null value.
> This may cause many problems for developer.
> I for example need only validate template without any data, only check which contain right variables, properties or method (which exist), it's value is not important for me.
> I tried use my own ReferenceInsertionEventHandler for replace null value with "" (empty String) but Velocity call InvalidReference handler before ReferenceInsertionEventHandler.
> I suggest configuration options for this (repor or doesn't report null value)

-- 
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] Updated: (VELOCITY-553) Posibility to configure ReportInvalidReferences to don't report report variables,properties and method which exist, but only have null value

Posted by "Nathan Bubna (JIRA)" <de...@velocity.apache.org>.
     [ https://issues.apache.org/jira/browse/VELOCITY-553?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel ]

Nathan Bubna updated VELOCITY-553:
----------------------------------

    Fix Version/s:     (was: 1.6)
                   1.7

> Posibility to configure ReportInvalidReferences to don't report report variables,properties and method which exist, but only have null value
> --------------------------------------------------------------------------------------------------------------------------------------------
>
>                 Key: VELOCITY-553
>                 URL: https://issues.apache.org/jira/browse/VELOCITY-553
>             Project: Velocity
>          Issue Type: Improvement
>          Components: Engine
>    Affects Versions: 1.5
>         Environment: any
>            Reporter: Tomáš Procházka
>             Fix For: 1.7
>
>
> ReportInvalidReferences has very big imperfection, it report by default all variables, properties and method which has null value.
> This may cause many problems for developer.
> I for example need only validate template without any data, only check which contain right variables, properties or method (which exist), it's value is not important for me.
> I tried use my own ReferenceInsertionEventHandler for replace null value with "" (empty String) but Velocity call InvalidReference handler before ReferenceInsertionEventHandler.
> I suggest configuration options for this (repor or doesn't report null value)

-- 
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-553) Posibility to configure ReportInvalidReferences to don't report report variables,properties and method which exist, but only have null value

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

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

Hi,

Looking at this issue.  There's a couple of cases here, any comment?

$something.abc     where there is no $something in the context
--> should call the event handler

$something.abc      where this is no property getAbc() or isAbc()
--> should call the event handler

$something.abc      where $something.getAbc() is null
--> should not call the event handler

But how about
$something.abc.def    where $something.getAbc() is null
--> I'd argue this should call the event handler

In other words, a null response doesn't trigger this, but calling another method on top of null does.

Seem reasonable?

> Posibility to configure ReportInvalidReferences to don't report report variables,properties and method which exist, but only have null value
> --------------------------------------------------------------------------------------------------------------------------------------------
>
>                 Key: VELOCITY-553
>                 URL: https://issues.apache.org/jira/browse/VELOCITY-553
>             Project: Velocity
>          Issue Type: Improvement
>          Components: Engine
>    Affects Versions: 1.5
>         Environment: any
>            Reporter: Tomáš Procházka
>             Fix For: 1.6
>
>
> ReportInvalidReferences has very big imperfection, it report by default all variables, properties and method which has null value.
> This may cause many problems for developer.
> I for example need only validate template without any data, only check which contain right variables, properties or method (which exist), it's value is not important for me.
> I tried use my own ReferenceInsertionEventHandler for replace null value with "" (empty String) but Velocity call InvalidReference handler before ReferenceInsertionEventHandler.
> I suggest configuration options for this (repor or doesn't report null value)

-- 
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] Issue Comment Edited: (VELOCITY-553) Posibility to configure ReportInvalidReferences to don't report report variables,properties and method which exist, but only have null value

Posted by "Renato Steiner (JIRA)" <de...@velocity.apache.org>.
    [ https://issues.apache.org/jira/browse/VELOCITY-553?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=12828102#action_12828102 ] 

Renato Steiner edited comment on VELOCITY-553 at 2/1/10 1:20 PM:
-----------------------------------------------------------------

I have noticed that Velocity makes a difference between accessing a property vs. accessing the property via a property accessor method:
Note: $util.isNull is a simple utility  method in one of the classes I unfortunately cannot attach. But you can simply create a utility method in one of your own classes which returns true if the params value is null.

=> The code below results in the invocation of InvalidReferenceEventHandler::invalidGetMethod(Context, String, Object, String, Info). 

         #set ($objRef = $util.getTestObject())
         #if ($util.isNull($objRef.nullValueAttribute))
            #debugMsg("@@util.isNull(objRef.nullValueAttribute) => isNull==true")
         #else
            #debugMsg("@@objRef.nullValueAttribute=$objRef.nullValueAttribute")
         #end

---------

=> The code below works correctly:

         #set ($objRef = $util.getTestObject())
         #if ($util.isNull($objRef.getNullValueAttribute()))
            #debugMsg("@@util.isNull(objRef.getNullValueAttribute()) => isNull==true")
         #else
            #debugMsg("@@objRef.nullValueAttribute=$objRef.nullValueAttribute")
         #end

---------

Note: TestObject is declared within InvalidEventHandlerTestCase.java.

I have created and attached a new unit test which can be used to verify the desired behavior.
If the patch is applied, the InvalidEventHandlerTestCase.java test case should run without errors.
If you uncomment the documented code segments, errors will appear until the bug is fixed.

Notes: 
Single testcase execution (requires the patch: velocity-661-v1.0.patch -> http://issues.apache.org/jira/browse/VELOCITY-661)
$ ant -Dtestcase=org.apache.velocity.test.InvalidEventHandlerTestCase test

Related: 
http://issues.apache.org/jira/browse/VELOCITY-618
https://issues.apache.org/jira/browse/VELOCITY-423
http://wiki.apache.org/velocity/VelocityNullSupport

      was (Author: honato11):
    I have noticed that Velocity makes a difference between accessing a property vs. accessing the property via a property accessor method:
Note: $util.isNull is a simple utility  method in one of the classes I unfortunately cannot attach. But you can simply create a utility method in one of your own classes which returns true if the params value is null.

=> The code below results in the invocation of InvalidReferenceEventHandler::invalidGetMethod(Context, String, Object, String, Info). 

         #set ($objRef = $util.getTestObject())
         #if ($util.isNull($objRef.nullValueAttribute))
            #debugMsg("@@util.isNull(objRef.nullValueAttribute) => isNull==true")
         #else
            #debugMsg("@@objRef.nullValueAttribute=$objRef.nullValueAttribute")
         #end

---------

=> The code below works correctly:

         #set ($objRef = $util.getTestObject())
         #if ($util.isNull($objRef.getNullValueAttribute()))
            #debugMsg("@@util.isNull(objRef.getNullValueAttribute()) => isNull==true")
         #else
            #debugMsg("@@objRef.nullValueAttribute=$objRef.nullValueAttribute")
         #end

---------

I have created and attached a new unit test which can be used to verify the desired behavior.
If the patch is applied, the InvalidEventHandlerTestCase.java test case should run without errors.
If you uncomment the documented code segments, errors will appear until the bug is fixed.

Notes: 
Single testcase execution (requires the patch: velocity-661-v1.0.patch -> http://issues.apache.org/jira/browse/VELOCITY-661)
$ ant -Dtestcase=org.apache.velocity.test.InvalidEventHandlerTestCase test

Related: 
http://issues.apache.org/jira/browse/VELOCITY-618
https://issues.apache.org/jira/browse/VELOCITY-423
http://wiki.apache.org/velocity/VelocityNullSupport
  
> Posibility to configure ReportInvalidReferences to don't report report variables,properties and method which exist, but only have null value
> --------------------------------------------------------------------------------------------------------------------------------------------
>
>                 Key: VELOCITY-553
>                 URL: https://issues.apache.org/jira/browse/VELOCITY-553
>             Project: Velocity
>          Issue Type: Improvement
>          Components: Engine
>    Affects Versions: 1.5
>         Environment: any
>            Reporter: Tomáš Procházka
>             Fix For: 1.7
>
>         Attachments: InvalidEventHandlerTestCase.java.patch
>
>
> ReportInvalidReferences has very big imperfection, it report by default all variables, properties and method which has null value.
> This may cause many problems for developer.
> I for example need only validate template without any data, only check which contain right variables, properties or method (which exist), it's value is not important for me.
> I tried use my own ReferenceInsertionEventHandler for replace null value with "" (empty String) but Velocity call InvalidReference handler before ReferenceInsertionEventHandler.
> I suggest configuration options for this (repor or doesn't report null value)

-- 
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] Updated: (VELOCITY-553) Posibility to configure ReportInvalidReferences to don't report report variables,properties and method which exist, but only have null value

Posted by "Renato Steiner (JIRA)" <de...@velocity.apache.org>.
     [ https://issues.apache.org/jira/browse/VELOCITY-553?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel ]

Renato Steiner updated VELOCITY-553:
------------------------------------

    Attachment: InvalidEventHandlerTestCase.java.patch

Added code to test the behavior of velocity when a method returns null.

> Posibility to configure ReportInvalidReferences to don't report report variables,properties and method which exist, but only have null value
> --------------------------------------------------------------------------------------------------------------------------------------------
>
>                 Key: VELOCITY-553
>                 URL: https://issues.apache.org/jira/browse/VELOCITY-553
>             Project: Velocity
>          Issue Type: Improvement
>          Components: Engine
>    Affects Versions: 1.5
>         Environment: any
>            Reporter: Tomáš Procházka
>             Fix For: 1.7
>
>         Attachments: InvalidEventHandlerTestCase.java.patch
>
>
> ReportInvalidReferences has very big imperfection, it report by default all variables, properties and method which has null value.
> This may cause many problems for developer.
> I for example need only validate template without any data, only check which contain right variables, properties or method (which exist), it's value is not important for me.
> I tried use my own ReferenceInsertionEventHandler for replace null value with "" (empty String) but Velocity call InvalidReference handler before ReferenceInsertionEventHandler.
> I suggest configuration options for this (repor or doesn't report null value)

-- 
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] Updated: (VELOCITY-553) Posibility to configure ReportInvalidReferences to don't report report variables,properties and method which exist, but only have null value

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

Will Glass-Husain updated VELOCITY-553:
---------------------------------------

    Fix Version/s: 1.6

> Posibility to configure ReportInvalidReferences to don't report report variables,properties and method which exist, but only have null value
> --------------------------------------------------------------------------------------------------------------------------------------------
>
>                 Key: VELOCITY-553
>                 URL: https://issues.apache.org/jira/browse/VELOCITY-553
>             Project: Velocity
>          Issue Type: Improvement
>          Components: Engine
>    Affects Versions: 1.5
>         Environment: any
>            Reporter: Tomáš Procházka
>             Fix For: 1.6
>
>
> ReportInvalidReferences has very big imperfection, it report by default all variables, properties and method which has null value.
> This may cause many problems for developer.
> I for example need only validate template without any data, only check which contain right variables, properties or method (which exist), it's value is not important for me.
> I tried use my own ReferenceInsertionEventHandler for replace null value with "" (empty String) but Velocity call InvalidReference handler before ReferenceInsertionEventHandler.
> I suggest configuration options for this (repor or doesn't report null value)

-- 
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-553) Posibility to configure ReportInvalidReferences to don't report report variables,properties and method which exist, but only have null value

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

Nathan Bubna commented on VELOCITY-553:
---------------------------------------

Where are we here?  It sounds like Byron had ideas for fixing/using this in 2.0, but no one has stepped up to resolve this for 1.7 (much less 1.6).  Since we have strict mode now, is this even worth fixing in 1.7?  I'd like to push out a 1.7 final soon.  Unless someone steps up soon, this won't happen in 1.7.

> Posibility to configure ReportInvalidReferences to don't report report variables,properties and method which exist, but only have null value
> --------------------------------------------------------------------------------------------------------------------------------------------
>
>                 Key: VELOCITY-553
>                 URL: https://issues.apache.org/jira/browse/VELOCITY-553
>             Project: Velocity
>          Issue Type: Improvement
>          Components: Engine
>    Affects Versions: 1.5
>         Environment: any
>            Reporter: Tomáš Procházka
>             Fix For: 1.7
>
>         Attachments: InvalidEventHandlerTestCase.java.patch
>
>
> ReportInvalidReferences has very big imperfection, it report by default all variables, properties and method which has null value.
> This may cause many problems for developer.
> I for example need only validate template without any data, only check which contain right variables, properties or method (which exist), it's value is not important for me.
> I tried use my own ReferenceInsertionEventHandler for replace null value with "" (empty String) but Velocity call InvalidReference handler before ReferenceInsertionEventHandler.
> I suggest configuration options for this (repor or doesn't report null value)

-- 
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