Shinobu Kawai <[EMAIL PROTECTED]> wrote:
> > Nathan, can we get this added to Velocity Tools once Shinobu finishes 
the
> > documentation?
> Uh-oh, do I hear request for documentation?  I only made it to test my
> replies to a couple of questions on the user list!  But if it's going
> to get a chance to get added to Velocity Tools, I'll be happy to
> document it right away.

I am not a committer, only an infrequent contributor to VelocityTools.
However, with the hundreds of null-based questions on the Velocity user 
list, it'd sure be nice to say the following to a new user.

"Yes, Velocity doesn't work like that, but the NullTool can provide most of 
the functionality you need." 

Another thing I'd like to see is a "$nulltool.set(key, value)" method to 
replace #set which can take a null value and handle it properly so one does 
not have to do everything with a #set_null_ok() macro that looks like the 
following (syntax untested)

#macro set_null_ok(key value)#if 
($nulltool.isNull)$nulltool.setNull(key)#else#set($key = $value)#end#end


    public void set(Context context, String key, String value) {
                if (null == value) context.remove(key);

        else context.put(key, value);

    }

    

I'd also add the ability to return null.

$nulltool.getNull() or $nulltool.NULL (is it legal to return a public field 
or only methods?)

    public void getNull() {
                return null;

    }


> I'll even make a ViewNullTool, if you like.  ;-)

I'm probably just misinterpreting a joke, but what would a ViewNullTool be?

Maybe it has something to do with not having to specify the context.   
That's the one downside I see with NullTool.  I don't generally have access 
to the context from the context, so I can't actually use any set method.   I 
haven't worked enough with the code to determine how you'd get the context 
without being passed it, but I suspect it could be part of the initalization 
code.

-Mike

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

Reply via email to