aspose file tools*
The moose likes Web Component Certification (SCWCD/OCPJWCD) and the fly likes can tld have more than 1 function signature? Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Spring in Action this week in the Spring forum!
JavaRanch » Java Forums » Certification » Web Component Certification (SCWCD/OCPJWCD)
Bookmark "can tld have more than 1 function signature?" Watch "can tld have more than 1 function signature?" New topic
Author

can tld have more than 1 function signature?

Veena Pointi
Ranch Hand

Joined: Jun 20, 2002
Posts: 442
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 ]

SCJP1.4
"Continuous effort - not strength or intelligence - is the key to unlocking our potential."
*Winston Churchill
shweta bulbule
Ranch Hand

Joined: Mar 24, 2006
Posts: 30
you don't call it with the function signature in EL but u call it with name..rollIt...i guess this is the problem


Thanks,<br />Shweta
Veena Pointi
Ranch Hand

Joined: Jun 20, 2002
Posts: 442
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

Joined: Jun 20, 2002
Posts: 442
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

Joined: Dec 04, 2004
Posts: 950
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


Narendra Dhande
SCJP 1.4,SCWCD 1.4, SCBCD 5.0, SCDJWS 5.0, SCEA 5.0
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: can tld have more than 1 function signature?