Topic
  • No replies
Wolfie
Wolfie
1 Post

Pinned topic Problems using user defined functions in EL via a TLD file

‏2011-11-19T15:57:57Z |
Hi,

I try to follow a simple example form a book on how to do a simple function usable in EL (Expressionless Language) in RSA 7.5.5.5 .
Looks to me I do it the right way but something must be wrong as it doesn't work.
Appreciate all help and hints

First I make the function itself in Java Resources\src\foo

===========================================================
package foo;

public class DiceRoller {
public static int rollDice(){
return (int)((Math.random() * 6) + 1);
}
}

===================================================================
Pretty straightforward code to return an int between 1 and 6.
Get no errors or warnings here.

Then I put the TLD file myFunctions tld in the WEB-INF directory

===================================================================================

<?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>
int rollDice()
</function-signature>
</function>
</taglib>

=============================================================

I get the following warning here :
Description Resource Path Location Type
No grammar constraints (DTD or XML schema) detected for the document. myFunctions.tld FirstWeb/WebContent/WEB-INF line 1 XML Problem

This might be the problem but the code looks like other examples I have seen on the web.
But please comment this message if you have any hints. Version No comes at hand but have tried to change them without a fixing the problem and I haven't managed to find any info on tag lib versions supported by RSA (So if you know about versions please comment) I wish there was a "new TLD" function in RSA to be sure all the headings was correct.

Finally a simple JSP to use it in the WebContent directory

==================================================================

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"><%@page
language="java" contentType="text/html; charset=ISO-8859-1"
pageEncoding="ISO-8859-1"%>
<html>
<head>
<title>rollTester</title>
<meta http-equiv="Content-Type" content="text/html; charset=ISO-8859-1">
<meta name="GENERATOR"
content="Rational Software Architect for WebSphere Software">
</head>

<%@ taglib prefix="mine" uri="DiceFunctions" %>

<body>
Let us see what the dice will roll!!!

${mine:rollIt()}

</body>
</html>

==============================================================================================

On this page I actually get a Syntax error on the EL expression, but it looks all right to me according to samples I have seen.

As I said all help and hints appreciated.

Best Regards

Wolfie