• Post Reply Bookmark Topic Watch Topic
  • New Topic

Is it possible to use a signature with a generic parameter in a tld?

 
Richard Hayward
Ranch Hand
Posts: 130
4
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
In a tld I can specify a function where the return type uses generic syntax:



It seems to work as expected.

However, if I try to specify a function where the parameter uses generics:



the jsp page that uses the function returns an error:

HTTP Status 500 - The class java.util.List<java.lang.String> specified in the method signature in TLD for the function tt:upcaseStringList cannot be found. java.util.List<java.lang.String>

All the method does is take a List<String> and uppercase its elements.

Is this even currently possible? I've found references on the web saying that generics can't be used in a TLD, but I'm thinking they may be out of date, since it works for me, as described, with a generic return type.

Servlet Engine: 3.0
JSP Engine: 2.2
Application Server: Apache Tomcat/7.0.55
 
Bear Bibeault
Author and ninkuma
Marshal
Posts: 65530
108
IntelliJ IDE Java jQuery Mac Mac OS X
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Return types are not part of the method signature.
 
Richard Hayward
Ranch Hand
Posts: 130
4
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Bear Bibeault wrote:Return types are not part of the method signature.


So the reason my first example worked, was that the return type specified in the <function-signature> tag wasn't wasn't checked anyway?

Testing, I have to specify a return type in <function-signature>, omitting it gives an error. However, if I have a hello() method that returns the string "hello", and yet I declare it in the tld as returning say an int



it all works and the jsp using the tag outputs "hello" to the browser!



 
Bear Bibeault
Author and ninkuma
Marshal
Posts: 65530
108
IntelliJ IDE Java jQuery Mac Mac OS X
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
The TLD apparently requires a return type, but as it's not part of the signature doesn't take part in matching the signature to the actual method.
 
Richard Hayward
Ranch Hand
Posts: 130
4
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Thanks for your help Bear.

Do you know about the issue that I started with? Are parameter types such as List<String> not currently supported in tlds?
 
Bear Bibeault
Author and ninkuma
Marshal
Posts: 65530
108
IntelliJ IDE Java jQuery Mac Mac OS X
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
To be honest, I'm not really up-to-date on the current specifics; you'll need to reference the latest specifications. I've been spending all my time on client-side JavaScript for the past few years.

But, just thinking about it, I'd be surprised if that was supported because with type erasure and all, it seems like it'd be difficult to impossible to implement (but I'm not an expert on that so take it with some salt)

 
Richard Hayward
Ranch Hand
Posts: 130
4
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
ok.
Thanks for your help.
 
Bear Bibeault
Author and ninkuma
Marshal
Posts: 65530
108
IntelliJ IDE Java jQuery Mac Mac OS X
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Sorry to not be able to be more definitive, but if you do find out for certain, it'd be great if you'd post back here.
 
Imran Awan
Greenhorn
Posts: 1
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I think, it is not allowed to add a signature
 
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!