You are viewing a plain text version of this content. The canonical link for it is here.
Posted to taglibs-user@tomcat.apache.org by "David M. Karr" <dm...@earthlink.net> on 2002/08/31 23:35:23 UTC
Is it meaningful that there are no "default" values?
In building the Struts-EL tag library, I haven't ported Struts tags that
provide functionality that are directly supported in the JSTL. However, in
some of those tags I haven't ported, I have noticed one small feature that
isn't strictly provided in their JSTL analogs.
The issue is "default values". For instance, in the Struts "bean:cookie" tag,
it will assign the value of a cookie to a variable, but if the cookie isn't
defined, you can specify a default value that will be assigned to the variable.
There are a couple tags in the "bean" library that have this feature.
In the JSTL, there's no "quick" way to get this. I believe, for each variable
that you want to have a default value, you'd do something like this, after
every "c:set" (perhaps) that reads a value you hope is defined:
<c:if test="${empty variable}">
<c:set var="variable" value="default value"/>
</c:if>
(I guess this avoids the question of the difference between a null string and
an empty string.)
If I were to suggest an enhancement, it would be a "default" attribute on
"c:set" that can take an EL expression. Is there any perception that this
might have enough value for a formal enhancement report?
--
===================================================================
David M. Karr ; Java/J2EE/XML/Unix/C++
dmkarr@earthlink.net
--
To unsubscribe, e-mail: <ma...@jakarta.apache.org>
For additional commands, e-mail: <ma...@jakarta.apache.org>
Re: Is it meaningful that there are no "default" values?
Posted by "David M. Karr" <dm...@earthlink.net>.
>>>>> "Shawn" == Shawn Bayern <ba...@essentially.net> writes:
Shawn> The <c:out> tag has just the sort of 'default' attribute you suggest; you
Shawn> can use it in conjunction with <c:set> and many other JSTL tags.
Sigh. I probably looked at that page a hundred times.
--
===================================================================
David M. Karr ; Java/J2EE/XML/Unix/C++
dmkarr@earthlink.net
--
To unsubscribe, e-mail: <ma...@jakarta.apache.org>
For additional commands, e-mail: <ma...@jakarta.apache.org>
Re: Is it meaningful that there are no "default" values?
Posted by Shawn Bayern <ba...@essentially.net>.
The <c:out> tag has just the sort of 'default' attribute you suggest; you
can use it in conjunction with <c:set> and many other JSTL tags.
--
Shawn Bayern
"JSTL in Action" http://www.jstlbook.com
On 31 Aug 2002, David M. Karr wrote:
> In building the Struts-EL tag library, I haven't ported Struts tags that
> provide functionality that are directly supported in the JSTL. However, in
> some of those tags I haven't ported, I have noticed one small feature that
> isn't strictly provided in their JSTL analogs.
>
> The issue is "default values". For instance, in the Struts "bean:cookie" tag,
> it will assign the value of a cookie to a variable, but if the cookie isn't
> defined, you can specify a default value that will be assigned to the variable.
> There are a couple tags in the "bean" library that have this feature.
>
> In the JSTL, there's no "quick" way to get this. I believe, for each variable
> that you want to have a default value, you'd do something like this, after
> every "c:set" (perhaps) that reads a value you hope is defined:
>
> <c:if test="${empty variable}">
> <c:set var="variable" value="default value"/>
> </c:if>
>
> (I guess this avoids the question of the difference between a null string and
> an empty string.)
>
> If I were to suggest an enhancement, it would be a "default" attribute on
> "c:set" that can take an EL expression. Is there any perception that this
> might have enough value for a formal enhancement report?
--
To unsubscribe, e-mail: <ma...@jakarta.apache.org>
For additional commands, e-mail: <ma...@jakarta.apache.org>