Win a copy of Re-engineering Legacy Software this week in the Refactoring forum
or Docker in Action in the Cloud/Virtualization forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

can tld have more than 1 function signature?

 
Veena Pointi
Ranch Hand
Posts: 442
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
can tld have more than 1 function signature?something like this



<b>When I call the second function using the code</b> ${mine:rollDiceNonVoid()} ,it throws following exception




Thanks
Veena

[ April 06, 2006: Message edited by: Veena Point ]
[ April 06, 2006: Message edited by: Veena Point ]
 
shweta bulbule
Ranch Hand
Posts: 30
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
you don't call it with the function signature in EL but u call it with name..rollIt...i guess this is the problem
 
Veena Pointi
Ranch Hand
Posts: 442
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Good guess .I changed to have different name as follows

<?xml version="1.0" encoding="ISO-8859-1" ?>

<taglib xmlns="http://java.sun.com/xml/ns/j2ee"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://java.sun.com/xml/ns/j2ee/web-jsptaglibrary_2_0.xsd"
version="2.0">

<tlib-version>1.2</tlib-version>
<uri>DiceFunctions</uri>
<function>
<name>rollIt</name>
<function-class>foo.DiceRoller</function-class>
<function-signature>
void rollDiceNonVoid()
</function-signature>
<name>rollItNonVoid</name>
<function-class>foo.DiceRoller</function-class>
<function-signature>
int rollDice()
</function-signature>
</function>
</taglib>

But it throws following exception.

jspCh8ELimplicit.jsp(45,44) The function rollIt cannot be located with the specified prefix
 
Veena Pointi
Ranch Hand
Posts: 442
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
It worked after the following change

<?xml version="1.0" encoding="ISO-8859-1" ?>

<taglib xmlns="http://java.sun.com/xml/ns/j2ee"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://java.sun.com/xml/ns/j2ee/web-jsptaglibrary_2_0.xsd"
version="2.0">

<tlib-version>1.2</tlib-version>
<uri>DiceFunctions</uri>
<function>
<name>rollIt</name>
<function-class>foo.DiceRoller</function-class>
<function-signature>
void rollDiceNonVoid()
</function-signature>
</function>
<function>
<name>rollItNonVoid</name>
<function-class>foo.DiceRoller</function-class>
<function-signature>
int rollDice()
</function-signature>
</function>
</taglib>

Thanks for the help Shweta.

Veena
 
Narendra Dhande
Ranch Hand
Posts: 951
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi,

That means you are defining two different functions for two different methods in the same class, this is perfectly valid in the tld. The <name> component must be unique in the tld, but you can use same class and signature in the two <function> element, to define the different name to use in EL.

Also you can not place multiple entries of <function-class> and <function-signature> under <function> element.

Hope this help you.

Thanks
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic