[prev in list] [next in list] [prev in thread] [next in thread] 

List:       struts-user
Subject:    RE: Help me defend Struts taglibs!!!
From:       Amos Shapira <amos.shapira () webcollage ! com>
Date:       2001-05-31 15:01:36
[Download RAW message or body]

As the local neighborhood taglibs pusher in my company, I came
under some scrutiny about the lack of an Else in tags and realised
the difficulty about nesting XML tags legally, just as described by
Craig in his message below.

What I pretty quickly came up with is a "switch" syntax:

<struts:switch condition="<%= expression %>" >
  <case value="<%= true %>">
    ...
  </case>
  <case value="<%= false %>">
  </case>
</struts:switch>

It's not stright-forward if/else, but it is (IMHO):

1. Legal XML
2. Relatively clear as an if/else clause
3. Provides a solution for a more general case of switch/case

What do you think?

Cheers,

--Amos Shapira
WebCollage

-----Original Message-----
From: Craig R. McClanahan [mailto:craigmcc@apache.org]
Sent: Thursday, May 31, 2001 6:18 AM
To: 'struts-user@jakarta.apache.org'
Subject: RE: Help me defend Struts taglibs!!!




On Thu, 26 Apr 2001, Scott Cressler wrote:

> One thing this argument might come down to is why custom tags, especially
> for "if...else" stuff (which, BTW, IMHO is not handled real well by the
> struts tags...would be nicer to have more flexibility in the conditions
you
> can check and to have the ability to do else, rather than
> <logic:equal>...</logic:equal><logic:notEqual>...</logic:notEqual>...but
> that's another discussion :-).  In other words, if it is so easy to just
> slap some Java in their to do some conditional stuff, why use a clumsy
tag.
> 

It turns out to be surprisingly difficult to come up with syntax for an
"else" construct that is legal XML syntax and isn't really ugly.

There's currently work going on in the JSP Standard Tag Library effort
(JSR-052) to create tags that will eventually be known to all containters
in the same way that tags like <jsp:useBean> are -- which will also deal
with a lot of the performance related concerns.  It looks like there will
be reasonable ways to do "switch" and "if-else" type processing with them.

In the mean time, we can reconsider adding an "else" capability in Struts
1.1, if someone can come up with a good syntax.

Craig

[prev in list] [next in list] [prev in thread] [next in thread] 

Configure | About | News | Add a list | Sponsored by KoreLogic