Win a copy of Kotlin in Action this week in the Kotlin forum!
  • Post Reply Bookmark Topic Watch Topic
  • New Topic

TLD example in HFSJ  RSS feed

 
Sreedhar
Greenhorn
Posts: 6
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
In HFSJ, there is a example for writing functions in TLD.
Example on page 389.

--------------------------------------
Code in TLD:


<description>JSTL 1.1 functions library</description>
<display-name>JSTL functions</display-name>
<tlib-version>1.1</tlib-version>
<short-name>mine</short-name>
<uri>DiceFunctions</uri>

<function>
<description>
User defined TLD.
</description>
<name>rollIt</name>
<function-class>com.scwcd.apps.util.DiceRoller</function-class>
<function-signature>int rollIt()</function-signature>
</function>

Code on JSP:

<%@ taglib prefix="mine" uri="DiceFunctions"%>
${mine.rollIt()}
I get error :

The function rollIt must be used with a prefix when a default namespace is not specified

But if i change the code to --> ${mine.rollIt} // here the brackets are removed. I do not get any error but i also do not get any output.

----------------------------------------------------

Thanks in advance.
 
Paolo Metafune
Ranch Hand
Posts: 34
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
${mine:rollIt()} should be correct.
Try it so.

${mine.rollIt} works but you don't have any output because "mine" attribute is searched for in any scope but it doesn't exist and null value in output bacomes an empty string

Bye.
 
Consider Paul's rocket mass heater.
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!