• 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
  • Liutauras Vilda
  • Ron McLeod
  • Jeanne Boyarsky
  • Paul Clapham
Sheriffs:
  • Junilu Lacar
  • Tim Cooke
Saloon Keepers:
  • Carey Brown
  • Stephan van Hulst
  • Tim Holloway
  • Peter Rooke
  • Himai Minh
Bartenders:
  • Piet Souris
  • Mikalai Zaikin

Syntax of tld function-signature with varargs

 
Ranch Hand
Posts: 177
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
I'm trying to specify a function in a tld for a method whose argument is a varchar. What's the syntax?

My signature is,
public static String removeEnds(String string, String... prefixes) {

I'm not really sure what to try in the tld, although the obvious does not work:
<function-signature>java.lang.String removeEnds(java.lang.String, java.lang.String...)</function-signature>

When I tried this I got the following runtime error, so it obviously isn't recognizing that "String..." is special sytax, and not the name of a class.
org.apache.jasper.JasperException: The class java.lang.String... specified in the method signature in TLD for the function fn:removeEnds cannot be found. java.lang.String...
 
Sheriff
Posts: 67706
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
I've never tried to do this, but as varargs syntax is just syntactic sugar for arrays, you might try using array notation instead. Please let us know what you discover.

P.S. Please use code tags, rather than bold, to post code fragments. Thanks.
 
Max Rahder
Ranch Hand
Posts: 177
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Thanks for the idea, but that didn't work either. I can't figure it out. I switched the method to take a string and a delimiter -- the routine splits the string and processes the resulting array as before.
 
Bear Bibeault
Sheriff
Posts: 67706
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
I didn't mean to change the method... just how it was specified in the TLD.
 
Max Rahder
Ranch Hand
Posts: 177
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
No, I tried that first -- changed the signature in the tld to array. Then I tried passing in fn:split() on the items, etc. I tried several combinations, and finally waved the white flag and went with the solution above. Thanks for the help. :-)
 
Don't get me started about those stupid light bulbs.
reply
    Bookmark Topic Watch Topic
  • New Topic