tomcat-taglibs-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Shawn Bayern <bay...@essentially.net>
Subject Re: "evaluating custom action attribute" Error
Date Fri, 02 Aug 2002 13:11:12 GMT
On Thu, 1 Aug 2002, Vernon Wu wrote:

> To my understanding, in the following example
> 
> <jsp:useBean id="customer" type="sample.Customer" scope="request"/> ...
> Customer Name: <%=customer.getName()%>
> ...
> <% if (customer.getState().equals("CO")){ %>
> ...
> <%}%>
> 
> 
> is equalised to:
> 
> 
> Customer Name: ${ customer. name}
> <c:if test="${customer. state == param. state}">
> ...
> </c:if>

In rough form, that's true.  One example compares against "CO," and the
other compares against request.getParameter("state").  Otherwise, they're
pretty similar.

> Where the "name" is not essential to be an attribute of the Customer
> class as long as the class has a method called "getName".

That's what makes it a property (not attribute) of the Customer
class.  More generally, any JavaBeans property -- whether it be inferred
based on the pattern of accessor names or explicitly provided through a
BeanInfo class -- is accessible using the JSTL expression language.

> I see some examples from PetStore 1.3.1. In the product.jsp, for
> example,
> 
> <jsp:useBean
>   id="catalog"
>   class="com.sun.j2ee.blueprints.catalog.client.CatalogHelper"
>   scope="session"
> />
> ....
> <c:set value="${catalog.items}" var="pageResults" />
> 
> There is not an attribute named "items", but a method "getItems" in
> the class CatalogHelper.

If by "attribute" you mean "field" (instance variable), then yes; the EL
is not for accessing fields, but higher level "properties," as defined
above.

> But when I use ${agentHelper.blocks} where the "blocks" is not an
> attribute, I get an error message as:
> 
> An error occurred while evaluating custom action attribute "value"
> with value "${agentHelper.blocks}": An error occurred while getting
> property "blocks" from an instance of class ....
> 
> This error message indicates that "blocks" has to be an attribute of
> the class.

It means that no "blocks" property was found -- either that no getBlocks()
method was found, the getBlocks() method was unsuitable for another reason
(e.g., accepting an argument, or having a setBlocks() method that doesn't
correspond to it in data type), or a BeanInfo overrides it.

-- 
Shawn Bayern
"JSTL in Action"   http://www.jstlbook.com


--
To unsubscribe, e-mail:   <mailto:taglibs-user-unsubscribe@jakarta.apache.org>
For additional commands, e-mail: <mailto:taglibs-user-help@jakarta.apache.org>


Mime
View raw message