You are viewing a plain text version of this content. The canonical link for it is here.
Posted to user@struts.apache.org by alexj <al...@freesurf.ch> on 2003/03/01 00:34:07 UTC

[struts-el] What's the benefits ?

I didn't find the benefits of the use of jstl extention.

Who can explain me the benefits ? 

--
Alexandre Jaquet




---------------------------------------------------------------------
To unsubscribe, e-mail: struts-user-unsubscribe@jakarta.apache.org
For additional commands, e-mail: struts-user-help@jakarta.apache.org


Re: [struts-el] What's the benefits ?

Posted by alexj <al...@freesurf.ch>.
yep it's more clearer you rigth ;) 

--
Alexandre Jaquet
----- Original Message ----- 
From: "John Espey" <je...@Tallan.com>
To: "Struts Users Mailing List" <st...@jakarta.apache.org>
Sent: Saturday, March 01, 2003 12:49 AM
Subject: RE: [struts-el] What's the benefits ?


> here is a simple example:
> 
> <logic:present name="mylist">
> <bean:size id="mylist_size" name="mylist"/>
> <logic:equal name="mylist_size" value="0">
> There are no items to be evaluated..
> </logic:equal>
> <logic:greaterThan name="mylist_size" value="0">
> <logic:iterate id="item" name="mylist">
> <bean:write name="item"><br>
> </logic:iterate>
> </logic:greaterThan>
> </logic:present>
> 
> as opposed to:
> 
>       <c:choose>
>             <c:when test="${empty mylist}">
>                There are no items to be evaluated..
>             </c:when>
>             <c:otherwise>
>                   <c:forEach var="item" items="${mylist}">
>                      <c:out value="${item}"/><br>
>                   </c:forEach>
>             </c:otherwise>
>      </c:choose>
> 
> it seems easier to me, do you agree?  (I may be falsely sold on a "new"
> technology, just curious.....)
> 
> > -----Original Message-----
> > From: alexj [mailto:alexj@freesurf.ch]
> > Sent: Friday, February 28, 2003 6:34 PM
> > To: Struts Users Mailing List
> > Subject: [struts-el] What's the benefits ?
> >
> >
> > I didn't find the benefits of the use of jstl extention.
> >
> > Who can explain me the benefits ?
> >
> > --
> > Alexandre Jaquet
> >
> >
> >
> >
> > ---------------------------------------------------------------------
> > To unsubscribe, e-mail: struts-user-unsubscribe@jakarta.apache.org
> > For additional commands, e-mail: struts-user-help@jakarta.apache.org
> >
> 
> 
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: struts-user-unsubscribe@jakarta.apache.org
> For additional commands, e-mail: struts-user-help@jakarta.apache.org
> 

---------------------------------------------------------------------
To unsubscribe, e-mail: struts-user-unsubscribe@jakarta.apache.org
For additional commands, e-mail: struts-user-help@jakarta.apache.org


RE: [struts-el] What's the benefits ?

Posted by John Espey <je...@Tallan.com>.
here is a simple example:

<logic:present name=”mylist”>
	<bean:size id=”mylist_size” name=”mylist”/>
	<logic:equal name=”mylist_size” value=”0”>
		There are no items to be evaluated……
	</logic:equal>
	<logic:greaterThan name=”mylist_size” value=”0”>
		<logic:iterate id=”item” name=”mylist”>
			<bean:write name=”item”><br>
		</logic:iterate>
	</logic:greaterThan>
</logic:present>

as opposed to:

      <c:choose>
            <c:when test="${empty mylist}">
               There are no items to be evaluated….
            </c:when>
            <c:otherwise>
                  <c:forEach var="item" items="${mylist}">
                     <c:out value="${item}"/><br>
                  </c:forEach>
            </c:otherwise>
     </c:choose>

it seems easier to me, do you agree?  (I may be falsely sold on a "new"
technology, just curious.....)

> -----Original Message-----
> From: alexj [mailto:alexj@freesurf.ch]
> Sent: Friday, February 28, 2003 6:34 PM
> To: Struts Users Mailing List
> Subject: [struts-el] What's the benefits ?
>
>
> I didn't find the benefits of the use of jstl extention.
>
> Who can explain me the benefits ?
>
> --
> Alexandre Jaquet
>
>
>
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: struts-user-unsubscribe@jakarta.apache.org
> For additional commands, e-mail: struts-user-help@jakarta.apache.org
>


---------------------------------------------------------------------
To unsubscribe, e-mail: struts-user-unsubscribe@jakarta.apache.org
For additional commands, e-mail: struts-user-help@jakarta.apache.org


Re: [struts-el] What's the benefits ?

Posted by alexj <al...@freesurf.ch>.
Oh an old topics ;)) I understoud the benefits and I just buy a
book about JSTL.

Thanks for your clear post Craig.

--
Alexandre Jaquet

----- Original Message -----
From: "Craig R. McClanahan" <cr...@apache.org>
To: "Struts Users Mailing List" <st...@jakarta.apache.org>
Sent: Thursday, March 06, 2003 2:51 AM
Subject: RE: [struts-el] What's the benefits ?


>
>
> > From: alexj [mailto:alexj@freesurf.ch]
> >
> > I didn't find the benefits of the use of jstl extention.
> >
> > Who can explain me the benefits ?
>
> > From: p2 - apache <ap...@hotmail.com>
> >
> > Some body don't want to see <% .... %>? Just a guess.
>
> There's lots of advantages to the expression language that Struts-EL uses
> (copied from JSTL 1.0, and to be embedded everywhere in a JSP page in JSP
> 2.0).  My favorite feature is independence from the underlying
> implementation of the properties.  Consider the following expression:
>
>   ${customer.mailAddress.city}
>
> This works for all of the following scenarios (as well as some others):
>
> * "customer" is a bean with a getMailAddress() getter, which in term
>   returns a bean with a getCity() getter.
>
> * "customer" is a bean where getMailAddress() returns a Map that has
>   (among others) an entry with a key of "city".
>
> * "customer" is a Map that has a key "mailAddress" whose value is a
>   bean with a getCity() method.
>
> * "customer" is a Map with a key of "mailAddress" that returns a Map
>   that has a key of "city" ...
>
> You get the idea?  The business tier developer has a fair amount of
> freedom in how they implement the beans representing the data required by
> the view tier -- or even skips implementing them if Maps do the trick.
> And changing your mind among these choices does not invalidate the syntax
> of the expression that is embedded in your page.
>
> The other thing I like about EL expressions is that the syntax is very
> close to what page authors familiar with JavaScript already understand, so
> it's natural for them to be able to script with it, without having to know
> any java at all.  Consider a personnel management app that wants to
> restrict the display of salary information to managers.  In a JSP 1.2
> environment (with JSTL), you could write:
>
>   <c:if test="${user.role = 'Manager'}">
>     <c:out value="${employee.salary}"/>
>   </c:if>
>
> and have a fair chance that the page author can understand it -- while the
> corresponding scriptlet version is pretty opaque to a non-programmer:
>
>   <%
>      if (user.getRole().equals("Manager")) {
>        out.println(employee.getSalary());
>      }
>   %>
>
> to say nothing of the fact that the Java code requires you to expose
> "user" and "employee" as instance variables in the page class, while the
> tagged version doesn't.  (And, by the way, you'd better be prepared for
> NullPointerException errors in the scriptlet, while the expression
> language deals with them for you.)
>
> By the way, in a JSP 2.0 environment, this example will get even simpler:
>
>   <c:if test="${user.role = 'Manager'}">
>     ${employee.salary}
>   </c:if>
>
> because you will be able to use EL expressions anywhere (including
> template text), not just in tags that understand it.
>
> Craig McClanahan
>
>
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: struts-user-unsubscribe@jakarta.apache.org
> For additional commands, e-mail: struts-user-help@jakarta.apache.org
>


---------------------------------------------------------------------
To unsubscribe, e-mail: struts-user-unsubscribe@jakarta.apache.org
For additional commands, e-mail: struts-user-help@jakarta.apache.org


RE: [struts-el] What's the benefits ?

Posted by "Craig R. McClanahan" <cr...@apache.org>.

> From: alexj [mailto:alexj@freesurf.ch]
>
> I didn't find the benefits of the use of jstl extention.
>
> Who can explain me the benefits ?

> From: p2 - apache <ap...@hotmail.com>
>
> Some body don't want to see <% .... %>? Just a guess.

There's lots of advantages to the expression language that Struts-EL uses
(copied from JSTL 1.0, and to be embedded everywhere in a JSP page in JSP
2.0).  My favorite feature is independence from the underlying
implementation of the properties.  Consider the following expression:

  ${customer.mailAddress.city}

This works for all of the following scenarios (as well as some others):

* "customer" is a bean with a getMailAddress() getter, which in term
  returns a bean with a getCity() getter.

* "customer" is a bean where getMailAddress() returns a Map that has
  (among others) an entry with a key of "city".

* "customer" is a Map that has a key "mailAddress" whose value is a
  bean with a getCity() method.

* "customer" is a Map with a key of "mailAddress" that returns a Map
  that has a key of "city" ...

You get the idea?  The business tier developer has a fair amount of
freedom in how they implement the beans representing the data required by
the view tier -- or even skips implementing them if Maps do the trick.
And changing your mind among these choices does not invalidate the syntax
of the expression that is embedded in your page.

The other thing I like about EL expressions is that the syntax is very
close to what page authors familiar with JavaScript already understand, so
it's natural for them to be able to script with it, without having to know
any java at all.  Consider a personnel management app that wants to
restrict the display of salary information to managers.  In a JSP 1.2
environment (with JSTL), you could write:

  <c:if test="${user.role = 'Manager'}">
    <c:out value="${employee.salary}"/>
  </c:if>

and have a fair chance that the page author can understand it -- while the
corresponding scriptlet version is pretty opaque to a non-programmer:

  <%
     if (user.getRole().equals("Manager")) {
       out.println(employee.getSalary());
     }
  %>

to say nothing of the fact that the Java code requires you to expose
"user" and "employee" as instance variables in the page class, while the
tagged version doesn't.  (And, by the way, you'd better be prepared for
NullPointerException errors in the scriptlet, while the expression
language deals with them for you.)

By the way, in a JSP 2.0 environment, this example will get even simpler:

  <c:if test="${user.role = 'Manager'}">
    ${employee.salary}
  </c:if>

because you will be able to use EL expressions anywhere (including
template text), not just in tags that understand it.

Craig McClanahan



---------------------------------------------------------------------
To unsubscribe, e-mail: struts-user-unsubscribe@jakarta.apache.org
For additional commands, e-mail: struts-user-help@jakarta.apache.org


RE: [struts-el] What's the benefits ?

Posted by p2 - apache <ap...@hotmail.com>.

Some body don't want to see <% .... %>? Just a guess.


-----Original Message-----
From: alexj [mailto:alexj@freesurf.ch] 
Sent: February 28, 2003 6:34 PM
To: Struts Users Mailing List
Subject: [struts-el] What's the benefits ?

I didn't find the benefits of the use of jstl extention.

Who can explain me the benefits ? 

--
Alexandre Jaquet




---------------------------------------------------------------------
To unsubscribe, e-mail: struts-user-unsubscribe@jakarta.apache.org
For additional commands, e-mail: struts-user-help@jakarta.apache.org

---------------------------------------------------------------------
To unsubscribe, e-mail: struts-user-unsubscribe@jakarta.apache.org
For additional commands, e-mail: struts-user-help@jakarta.apache.org