aspose file tools*
The moose likes Web Component Certification (SCWCD/OCPJWCD) and the fly likes Passing array in an EL taglib function Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Certification » Web Component Certification (SCWCD/OCPJWCD)
Bookmark "Passing array in an EL taglib function" Watch "Passing array in an EL taglib function" New topic
Author

Passing array in an EL taglib function

Allan Cheong
Ranch Hand

Joined: Nov 12, 2009
Posts: 71

Hi all,

I am playing with some codes and found that I am unable to create such function:

.tld


MyFunction.java


.jsp


The problem occurs at .jsp I believe. However if I change the .jsp to the following, it works.


Any ideas on how I can pass array (String ...) in a taglib function in JSP?


SCJP6, SCJD, OCJWCD5
Ankit Garg
Sheriff

Joined: Aug 03, 2008
Posts: 9321
    
  17

As far as I remember this is not supported yet...


SCJP 6 | SCWCD 5 | Javaranch SCJP FAQ | SCWCD Links
Allan Cheong
Ranch Hand

Joined: Nov 12, 2009
Posts: 71

Noted with thanks.
Frits Walraven
Creator of Enthuware JWS+ V6
Bartender

Joined: Apr 07, 2010
Posts: 1734
    
  25

Any ideas on how I can pass array (String ...) in a taglib function in JSP?

If variable arguments where supported you would have to define the function in the TLD like this:

but that gives the following error:
The class java.lang.String... specified in the method signature in TLD for the function formTags:testFunction cannot be found.

It is expecting a fully qualified class name as parameter.

The proof can actually be found in the jsp2.0 specs:
JSP.C.1XML Schema for TLD, JSP 2.0
<xsd:element name="function-signature" type="j2ee:string">
<xsd:annotation>

<xsd:documentation>
Provides the signature, of the static Java method that is
to be used to implement the function. The syntax of the

function-signature element is as follows:

FunctionSignature ::= ReturnType S MethodName S? '(' S? Parameters? S? ')'
ReturnType ::= Type
MethodName ::= Identifier
Parameters ::= Parameter | ( Parameter S? ',' S? Parameters )
Parameter ::= Type
Where:
* Type is a basic type or a fully qualified Java class name (including package name), as per the 'Type' production in the Java Language Specification


Regards,
Frits
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: Passing array in an EL taglib function