This week's giveaway is in the Programmer Certification (OCPJP) forum.
We're giving away four copies of Java Mock Exams (software) and have David Mayer on-line!
See this thread for details.
Win a copy of Java Mock Exams (software) this week in the Programmer Certification (OCPJP) 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
  • 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: 9597
36
Android Google Web Toolkit Hibernate IntelliJ IDE Java Spring
  • 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
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Noted with thanks.
 
Frits Walraven
Creator of Enthuware JWS+ V6
Saloon Keeper
Posts: 2778
174
Android Chrome Eclipse IDE
  • 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
 
What are you doing? You are supposed to be reading this tiny ad!
the new thread boost feature brings a LOT of attention to your favorite threads
https://coderanch.com/t/674455/Thread-Boost-feature
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!