• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

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

 
Ranch Hand
Posts: 209
13
VI Editor
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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
 
Sheriff
Posts: 67746
173
Mac Mac OS X IntelliJ IDE jQuery TypeScript Java iOS
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Return types are not part of the method signature.
 
Richard Hayward
Ranch Hand
Posts: 209
13
VI Editor
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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
Sheriff
Posts: 67746
173
Mac Mac OS X IntelliJ IDE jQuery TypeScript Java iOS
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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: 209
13
VI Editor
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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
Sheriff
Posts: 67746
173
Mac Mac OS X IntelliJ IDE jQuery TypeScript Java iOS
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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: 209
13
VI Editor
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
ok.
Thanks for your help.
 
Bear Bibeault
Sheriff
Posts: 67746
173
Mac Mac OS X IntelliJ IDE jQuery TypeScript Java iOS
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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.
 
Greenhorn
Posts: 1
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
I think, it is not allowed to add a signature
reply
    Bookmark Topic Watch Topic
  • New Topic