Martin Cooper wrote:
> 
>>-----Original Message-----
>>From: Hans Bergsten [mailto:[EMAIL PROTECTED]]
>>
>>Shawn is rarely wrong, but here actually missed one detail: 
>>JSP 2.0 adds
>>_functions_ to the EL, but not _methods_ as is used in this example.
>>A function is a method on a specific class, declared in the 
>>TLD. It can
>>then be used in an EL expression like this:
>>
>>   ${mylib:customer(mybean, pageScope.range * 2)}
> 
> 
> How would this map back to Java code? Is there any inferred relationship
> between 'customer' and the method being called, and between 'mybean' and the
> class on which the method is being invoked?

Note that it's a "function" call, not a "method" call; a "function" is
not targetted to a specific object, as a method is, so all info must be
passed as parameters.

"mylib" is the prefix assigned to the taglib that contains the function
declaration.
"customer" is the function name declared in the TLD, and "mybean" is
an variable of the type declared for the customer() functions first
parameter.

Does that help?

> The syntax above seems to imply that, at least in this case, 'mybean'
> corresponds to 'this'. I'm guessing that the method name need bear no
> relation to the function name used in JSP, and that the mapping is specified
> in the TLD? What about calling static methods?
> 
> I guess I should really go read the spec...

Yes :-) But here's what the JSP 2.0 PFD says:

   JSP.2.6.2 Tag Library Descriptor Information
   Each tag library may include zero or more n-ary (static) functions.
   The Tag Library Descriptor (TLD) associated with a tag library lists
   the functions. Each such function is given a name (as seen in the EL),
   and a static method in a specific class that will implement the
   function. The class specified in the TLD must be a public non-abstract
   class. The specified method must be a public static method in the
   specified class. [...]

   JSP.2.6.3 Example
   The following TLD fragment describes a function with name nickname
   that is intended to fetch the nickname of the user:

   <taglib>
     ...
     <function>
       <name>nickname</name>
       <function-class>mypkg.MyFunctions</function-class>
       <function-signature>String nickName(String)</function-signature>
     </function>
   </taglib>

   The following EL fragment shows the invocation of the function:

   <h2>Dear ${my:nickname(user)}</h2>

Hans
-- 
Hans Bergsten           [EMAIL PROTECTED]
Gefion Software         http://www.gefionsoftware.com
JavaServer Pages        http://TheJSPBook.com


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

Reply via email to