You are viewing a plain text version of this content. The canonical link for it is here.
Posted to user@struts.apache.org by Johan Compagner <jc...@j-com.nl> on 2001/03/13 19:53:03 UTC
DefineTag.value question (proposal)
Hi,
If i specify the value in the DefineTag then the name/property is ignored!!
But when i also specify the name/property then i want the value to be filled in when
name/property seems to be null!
so not:
// Retrieve the required property value
Object value = this.value;
if (value == null)
value = RequestUtils.lookup(pageContext, name, property, scope);
but:
// Retrieve the required property value
Object value = null;
if(name != null)
value = RequestUtils.lookup(pageContext, name, property, scope);
if (value == null)
value = this.value;
johan
Re: DefineTag.value question (proposal)
Posted by Johan Compagner <jc...@j-com.nl>.
> > so not:
> >
> > // Retrieve the required property value
> > Object value = this.value;
>
> This will return null if you did not specify a "value" attribute, so the
> effect is the same as your desired result -- setting the new bean based on
> the name/property combination.
This is not my desired result because i want it to be a default value.
It should not ignore the name and property attributes if they are specified.
> > // Retrieve the required property value
> > Object value = null;
> > if(name != null)
> > value = RequestUtils.lookup(pageContext, name, property, scope);
> > if (value == null)
> > value = this.value;
> >
>
> This would reverse the priority of lookups, and make the string you
> specified for the "value" essentially a default if the specified property
> returns null. That is different from the current behavior, and different
> from what is documented, but makes a certain kind of sense.
But the behaviour is not changed for all the application build today
because None in using a name, value combo because at this time
that combo doesn't make any sense because it doesn't do a thing.
> What do people think about changing this?
You got my vote!
johan
Re: DefineTag.value question (proposal)
Posted by "Craig R. McClanahan" <cr...@apache.org>.
On Tue, 13 Mar 2001, Johan Compagner wrote:
> Hi,
>
> If i specify the value in the DefineTag then the name/property is ignored!!
> But when i also specify the name/property then i want the value to be filled in when
> name/property seems to be null!
>
If you specify the "value" attribute:
<bean:define id="xyz" value="this is a value"/>
you are saying that you want to create a bean under key "xyz" with the
specified literal String value "this is a value". That is why any
"name" or "property" attributes are ignored.
> so not:
>
> // Retrieve the required property value
> Object value = this.value;
This will return null if you did not specify a "value" attribute, so the
effect is the same as your desired result -- setting the new bean based on
the name/property combination.
> if (value == null)
> value = RequestUtils.lookup(pageContext, name, property, scope);
>
> but:
>
> // Retrieve the required property value
> Object value = null;
> if(name != null)
> value = RequestUtils.lookup(pageContext, name, property, scope);
> if (value == null)
> value = this.value;
>
This would reverse the priority of lookups, and make the string you
specified for the "value" essentially a default if the specified property
returns null. That is different from the current behavior, and different
from what is documented, but makes a certain kind of sense.
What do people think about changing this?
> johan
>
>
>
Craig