Re: if/elseif tag?

2000-12-29 Thread Jim Newsham


  The "struts-logic" library includes quite a few
  variations of an "if" tag that
  can perform different sorts of conditional checks
  for you.  At the moment,
  however, there is nothing that provides the "else"
  or "elseif" construct.  This
  is mostly because I've yet to see a syntax for this
  that is:
  * consistent with the XML syntax required by JSP
  custom tags
  * easily understood by page authors
  * not butt-ugly to look at or to type
 
  I'm open to suggestions for a solution to these
  issues.
 
   Mike Campbellemail: [EMAIL PROTECTED]
 
  Craig

I'm not too familiar with custom tag writing, so I don't know how
technically feasible this is, but... how about a "cond" tag (similar to
lisp's cond), whose body can contain multiple "test" tags.  The first
test which evaluates to true is allowed to render its body, and then
further processing is inhibited.  This would have the effect of "if,
else if, else if ...".

logic:cond
  logic:equal name="name" property="property" value="A"The value is
A/logic:equal
  logic:equal name="name" property="property" value="B"The value is
B/logic:equal
  logic:equal name="name" property="property" value="C"The value is
C/logic:equal
  logic:trueAn unexpected value?/logic:true
/logic:cond

... which should be equivalent to ...

if (name.getProperty().equals("A")) {
  out.write("The value is A");
}
else if (name.getProperty().equals("B")) {
  out.write("The value is B");
}
else if (name.getProperty().equals("C")) {
  out.write("The value is C");
}
else if (true) {
  out.write("An unexpected value?");
}


Jim N.




Re: if/elseif tag?

2000-12-28 Thread Craig R. McClanahan


Mike Campbell wrote:

Are there any tags in the struts library (or do you know
of any anywhere) which allow an
if
elseif
elseif
.
.
.
end if
type of construct?

The "struts-logic" library includes quite a few variations of an "if" tag
that can perform different sorts of conditional checks for you. At
the moment, however, there is nothing that provides the "else" or "elseif"
construct. This is mostly because I've yet to see a syntax for this
that is:
* consistent with the XML syntax required by JSP custom tags
* easily understood by page authors
* not butt-ugly to look at or to type
I'm open to suggestions for a solution to these issues.
Mike Campbell
email: [EMAIL PROTECTED]
Craig



Re: if/elseif tag?

2000-12-28 Thread Wong Kok Wai

Check out chapter 14 of the book "Core Servlets and
JSP" by Marty Hall. There is a web site with the
sources at http://archive.coreservlets.com/

--- "Craig R. McClanahan"
[EMAIL PROTECTED] wrote:
 Mike Campbell wrote:
 
 
 
  Are there any tags in the struts library (or do
 you know of any anywhere)
  which allow an
 
  if
  elseif
  elseif
  .
  .
  .
  end if
 
  type of construct?
 
 
 The "struts-logic" library includes quite a few
 variations of an "if" tag that
 can perform different sorts of conditional checks
 for you.  At the moment,
 however, there is nothing that provides the "else"
 or "elseif" construct.  This
 is mostly because I've yet to see a syntax for this
 that is:
 * consistent with the XML syntax required by JSP
 custom tags
 * easily understood by page authors
 * not butt-ugly to look at or to type
 
 I'm open to suggestions for a solution to these
 issues.
 
  Mike Campbellemail: [EMAIL PROTECTED]
 
 Craig
 
 


__
Do You Yahoo!?
Yahoo! Photos - Share your holiday photos online!
http://photos.yahoo.com/



Re: if/elseif tag?

2000-12-22 Thread Ted Husted

On 12/22/2000 at 4:22 PM Mike Campbell wrote:
As luck would have it, that book arrived at my door just last night,
so I'll be checking that out over the holidays.

It's a good read, you'll enjoy it. 

I just finished a quick skim of Core JSP (1st edition), but haven't
quite decided about it. There's a healthy amount of hard information,
but the writing is choppy. But I guess that comes with being a 1st
edition.

No question about Marty Hall's though. A definite keeper.

*** REPLY SEPARATOR  ***

 "TH" == Ted Husted [EMAIL PROTECTED] writes:

TH See  http://archive.coreservlets.com , Chapter 14, Using Nested
Tags.
TH This is the source code from Marty Hall's Core Servlets and
JavaServer
TH Pages.

Excellent.  
Thanks again Ted!