You are viewing a plain text version of this content. The canonical link for it is here.
Posted to user@velocity.apache.org by Chris Kimpton <ki...@yahoo.com> on 2001/09/17 11:37:34 UTC

Nested calls and null references

Hi,

I maybe doing too much in my template  ;-)  , but I have code like
this

<select name="mi_issuer">
$htmlutils.getDropDown($object.getByAlias("Issuer"), $all_orgs)
</select>

where htmlutils is a utility class for generating the <option> html,
given a value and a collection.  all_orgs is a collection of orgs. 
object is the current object we are working with.

This works fine on an update screen as all the above is well defined.

But on a new object screen, the $object reference is valid - but the
value returned by the getByAlias method is null.

This is causing velocity to give an invalid reference error - I was
hoping that it would call my getDropDown routine, passing a null for
the first parameter.

Is this to be expected - I guess there might be reasons for not
passing the null on.

We are using the velocity-1.2-dev build that is included with
jetspeed - which is probably a patched version of velocity as of 16th
August.

Regards,
Chris

=====
Need somewhere to Live in London - http://freeflats.com

__________________________________________________
Terrorist Attacks on U.S. - How can you help?
Donate cash, emergency relief information
http://dailynews.yahoo.com/fc/US/Emergency_Information/

Re: Nested calls and null references

Posted by Lane Sharman <la...@san.rr.com>.
Chris,

There have been some good articles on avoiding the use of null as a
value in some application settings. For example, NullSession, EmptyNode
are cases where your design preempts the delivery of a null pointer by
deliverying an object which has some behavior to cope with no object
state.

See if you could have an object, NullOrg, returned by getByAlias(),
which would behave properly in your example, as a design approach.

Then, your drop down would have nothing selected or it would have a
value like "Select...".

-lane

Chris Kimpton wrote:

> Hi,
>
> I maybe doing too much in my template  ;-)  , but I have code like
> this
>
> <select name="mi_issuer">
> $htmlutils.getDropDown($object.getByAlias("Issuer"), $all_orgs)
> </select>
>
> where htmlutils is a utility class for generating the <option> html,
> given a value and a collection.  all_orgs is a collection of orgs.
> object is the current object we are working with.
>
> This works fine on an update screen as all the above is well defined.
>
> But on a new object screen, the $object reference is valid - but the
> value returned by the getByAlias method is null.
>
> This is causing velocity to give an invalid reference error - I was
> hoping that it would call my getDropDown routine, passing a null for
> the first parameter.
>
> Is this to be expected - I guess there might be reasons for not
> passing the null on.
>
> We are using the velocity-1.2-dev build that is included with
> jetspeed - which is probably a patched version of velocity as of 16th
> August.
>
> Regards,
> Chris
>
> =====
> Need somewhere to Live in London - http://freeflats.com
>
> __________________________________________________
> Terrorist Attacks on U.S. - How can you help?
> Donate cash, emergency relief information
> http://dailynews.yahoo.com/fc/US/Emergency_Information/

--
Lane Sharman
http://corporate.acctiva.com/lane