On Mon, 24 Jun 2002, David Goodenough wrote:

> > The <c:out> tag, which I assume you'll be using to output the final value
> > of 'group' here, supports a 'default' attribute that takes care of this
> > case.  Thus, you could write
> >
> >   <c:out value="${param.group}" default="some default value"/>
> 
> Are, well actually no, the next thing I want to do with these values is
> typically some validation or calculation based on the values, not simply 
> return them to the HTML stream for next time around.  What I want is the
> same as the default attribute on the c:out on c:set, so that if the value
> is null the default is used.

You can get that by nesting:

  <c:set var="group">
    <c:out value="${...}" default="${...}"/>
  </c:set>

It's a little more concise than the original and somewhat more
representative of the amount of work involved:  you're performing an
explicit set based on output.

If every tag had a 'default' attribute, things might get unwieldy.  The
alternative, as you suggest, is some EL-based mechanism; we've considered
that too but decided, for JSTL 1.0, that the default defaults (so to
speak) are enough.  By that, I mean the coercions to empty values ("") as
appropriate.  For user-defined defaults, we support <c:out> as the
universal tool.

-- 
Shawn Bayern
"JSTL in Action"   http://www.jstlbook.com
(coming in July 2002 from Manning Publications)


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

Reply via email to