Win a copy of Soft Skills: The software developer's life manual this week in the Jobs Discussion forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Passing array in an EL taglib function

 
Allan Cheong
Ranch Hand
Posts: 71
Eclipse IDE Java Scala
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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?
 
Ankit Garg
Sheriff
Posts: 9495
22
Android Google Web Toolkit Hibernate IntelliJ IDE Java Spring
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
As far as I remember this is not supported yet...
 
Allan Cheong
Ranch Hand
Posts: 71
Eclipse IDE Java Scala
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Noted with thanks.
 
Frits Walraven
Creator of Enthuware JWS+ V6
Saloon Keeper
Pie
Posts: 2164
57
Android Chrome Eclipse IDE
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic