• 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

TLD/EL "The function *** cannot be located with the specified prefix"

 
Greenhorn
Posts: 2
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi all,

I've been lurking around this site for a while now , and I would like to think that I know a thing or two about Java. Unfortunately, I am new to dealing with TLD files and EL.

Basically, I'm trying to call a method on a jsp page. Originally I used a scriptlet, but I heard that was bad programming practice and I am now switching my code to JSTL. I still need to call that method, however.

Here is some of my code:

functions.tld


Here is some of my JSTL code:


And here is the error message I get:



Any help would be appreciated. Thanks in advance.
 
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
Welcome to the Ranch!

Tim March wrote:
<function>
<name>f</name>


${f:addDoi(doiInput,doiType,filename,source,productType,productLine,registrationMessage,url,urlDescription,urlMetadata)}


If you want to call the function by addDoi, why did you name it "f"?

(And what is a Doi? Spell it out! Freeze-drying names is not a good practice.)
 
Bartender
Posts: 1845
10
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
General reactions to this code:

#1: It belongs in a servlet, rather than a JSP. Model1 vs Model2/MVC
#2: Your method could possibly be improved by passing in an object rather than all of these related parameters.
ie addDoi(DoiObject doi)

where DoiObject has attributes of input, type etc etc as applicable.

Once you have that object, the majority of those <c:set> commands you have can probably be made redundant, as you can then populate the bean automagically from request parameters (either using a framework, or just a jsp:useBean and jsp:setProperty)






 
Sheriff
Posts: 17644
300
Mac Android IntelliJ IDE Eclipse IDE Spring Debian Java Ubuntu Linux
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

Bear Bibeault wrote:Freeze-drying names is not a good practice


This is the first time I've ever seen the term "freeze-drying" used to refer to the practice of crypticizing names... I like it Does this also apply to such classics as "pkgNbr", "bktCd", "pktSz", "trkWt", "trkLn" and other vowel-phobic names? (Translations: packageNumber, bracketCode, packetSize, truckWeight, trackLength).
 
Tim March
Greenhorn
Posts: 2
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Thanks for all your help guys. It turned out that the method I was calling was not static. Changed that and everything works perfectly.

For future googlers:

When referencing methods through .tld files --- make the method static!
 
Ranch Hand
Posts: 115
Eclipse IDE Tomcat Server Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
if tou want to create the EL functions , firstly the function must be a static. in the TLD in which we define the <function-signature> we need to describe the full package name of type class. like you define the function in which you define String type parameter , but in TLD file if define the function signature , then describe the fully package name of class type , like java.lang.String for exmple :-
[code] <function-signature>void addDoi(java.lang.String doiInput, java.lang.String doiType, java.lang.String filename, java.lang.String source, java.lang.String productType, java.lang.String productLine, java.lang.String registrationMessage,
java.lang.String url, java.lang.String urlDescription, java.lang.String urlMetadata)</function-signature>[\code]

the basic type are automaticaly handel , there is no need to define full package name , like int , float etc
 
reply
    Bookmark Topic Watch Topic
  • New Topic