Win a copy of Functional Reactive Programming this week in the Other Languages forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

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

 
Tim March
Greenhorn
Posts: 2
  • Mark post as helpful
  • send pies
  • 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.
 
Bear Bibeault
Author and ninkuma
Marshal
Pie
Posts: 65225
95
IntelliJ IDE Java jQuery Mac Mac OS X
  • Mark post as helpful
  • send pies
  • 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.)
 
Stefan Evans
Bartender
Posts: 1784
10
  • Mark post as helpful
  • send pies
  • 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)






 
Junilu Lacar
Bartender
Pie
Posts: 7771
62
Android Eclipse IDE IntelliJ IDE Java Linux Mac Scala Spring Ubuntu
  • Mark post as helpful
  • send pies
  • 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
  • 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!
 
Singh Harmeet
Ranch Hand
Posts: 115
Eclipse IDE Java Tomcat Server
  • Mark post as helpful
  • send pies
  • 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
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic