[standard] c:if accepts what expression types?

2002-02-01 Thread Eric . Lewis

Hi

I'm a newbie to JSTL (and Java more or less too) and was extremely confused
about the syntax for the ECMAscript EL. Until I read
http://www.mail-archive.com/taglibs-user@jakarta.apache.org/msg01249.html

Of course, I had first tried something like
   c:if test=$rows.get('element_type') == 'i' || $rows.get('element_type')
== 'I'
and it didn't work.

From my point of view (and the way we'd like to use the JSTL) us programmers
should create the data (=Model), and webmasters should create the HTML
templates (=View). And since most webmasters know JavaScript, ECMAscript
would be the logical choice as an EL. However, it should be really syntax
compatible, otherwise I guess it will confuse everybody.

Best regards,
Eric


swissinfo/Swiss Radio International
Eric Lewis
IT Engineering
Giacomettistrasse 1
CH-3000 Berne 15

Phone:  ++41 31 350 95 42
Fax:++41 31 350 99 40
mailto:[EMAIL PROTECTED]

Switzerland is everywhere. Stay connected!
http://www.swissinfo.org 
http://mobile.swissinfo.org
http:/wap.swissinfo.org

SRG SSR idée suisse



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




[standard] c:if accepts what expression types?

2002-01-02 Thread Paul DuBois

What are the constraints on the type of expressions that may be used
with c:if?

Assume that $x has the value 1: c:set var=x value=1/

This evaluates the body:

c:if test=$x == 1/true/c:if

This does not:

c:if test=1 == $x/true/c:if

So the test must begin with a variable?

Also, it looks like you can test only *one* variable value.
If I try to compare two values like this:

c:if test=$var1 == $var2true/c:if

Then I get: ReferenceError: $var2 is not defined.

If I switch the test to $var2 == $var1, then the error message names $var1.
(That is, it names the second variable each time.)

Is there a way to compare two variables directly from JSTL, if c:if cannot?
I'm using EA3.


P.S. Most of the /standard-doc/Conditionals_FunctionalDescription_1_EA1.html
page uses JSTL core tags in the examples with no c: tag prefix (e.g., when
rather than c:when).

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




Re: [standard] c:if accepts what expression types?

2002-01-02 Thread Shawn Bayern

On Wed, 2 Jan 2002, Paul DuBois wrote:

 What are the constraints on the type of expressions that may be used
 with c:if?

The short answer is 'boolean' or 'Boolean.'

The somewhat longer answer is that for the rtexprvalue library, the only
permissible type is 'boolean'.  For the EL library, the value must resolve
to a Boolean as far as the tag handler's concerned; it's up to the
expression language, not the tag handler, to convert boolean (e.g., a
boolean Bean property) to Boolean.

 Assume that $x has the value 1: c:set var=x value=1/
 
 This evaluates the body:
 
 c:if test=$x == 1/true/c:if
 
 This does not:
 
 c:if test=1 == $x/true/c:if
 
 So the test must begin with a variable?

Note that '$' does not begin a variable, but identifies an EL expression.  
Don't confuse '$' with the Bourne shell (or Perl) variable-reference
operator.  The attribute value 1 == $x represents the String literal
1 == $x; $x == 1 represents the EL expression x == 1.  Thus,
$1 == x should work just fine.

Note that this syntax is certainly not beyond debate.  At a conference
recently, a member of the audience in a presentation I was giving on JSTL
suggested that XSLT's '{}' syntax would be much clearer to adopt than
Unix's '$'.  Do you think that if the syntax had been

   c:if test={x == 1}

and

   c:if test={1 == 1x

that this would have avoided the confusion?  I'd personally be very
interested in any feedback you've got.

 Also, it looks like you can test only *one* variable value. If I try
 to compare two values like this:
 
 c:if test=$var1 == $var2true/c:if
 
 Then I get: ReferenceError: $var2 is not defined.

Same issue here; the 'var2' attribute is referenced as 'var2', not
'$var2'.  ($var2 could be the name of an attribute in its own right; the
ReferenceError comes from findAttribute($var2) failing.

 Is there a way to compare two variables directly from JSTL, if c:if
 cannot? I'm using EA3.

$var1 == var2
$var2 == var1

 P.S. Most of the /standard-doc/Conditionals_FunctionalDescription_1_EA1.html
 page uses JSTL core tags in the examples with no c: tag prefix (e.g., when
 rather than c:when).

Yeah, we have yet to decide how to consistently describe our actions, when
the prefixes are really just suggestions and not mandated in any context.  
I'm facing the same problem with my JSTL book.  I'm personally leaning
toward always using the suggested prefixes in writing.

Shawn


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