1
我正在使用示例方法在Facelets中编写一个简单的自定义函数。问题在于JSF 2应用程序无法找到该函数。错误消息是:未找到Facelets自定义函数
/test.xhtml @15,73 rendered="#{test:isGranted('ONE_ROLE')}" Function 'test:isGranted' not found.
我一直在检查和重新检查,找不到问题。这里的任何评论都会非常感谢,因为很明显我错过了一些东西(但似乎涉及的步骤非常简单)。
您是否知道是否还有其他必需品?
在此先感谢。
相关的代码:
在web.xml中标签XML描述符声明
<context-param>
<param-name>javax.faces.FACELETS_LIBRARIES</param-name>
<param-value>/WEB-INF/test.taglib.xml</param-value>
</context-param>
文件test.taglib.xml:
<?xml version="1.0"?>
<!DOCTYPE facelet-taglib PUBLIC
"-//Sun Microsystems, Inc.//DTD Facelet Taglib 1.0//EN"
"http://java.sun.com/dtd/facelet-taglib_1_0.dtd">
<facelet-taglib>
<namespace>http://www.test.com/security/tags</namespace>
<function>
<function-name>isGranted</function-name>
<function-class>com.test.security.taglibs.IsGranted</function-class>
<function-signature>boolean isGranted(java.lang.String role)</function-signature>
</function>
</facelet-taglib>
的标签类别:
public class IsGranted extends TagHandler {
public static boolean isGranted(String role) {
// Do nothing. Just a test.
return false;
}
}
而且测试文件:
<?xml version='1.0' encoding='UTF-8' ?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml"
xmlns:h="http://java.sun.com/jsf/html"
xmlns:test="http://www.test.com/security/tags">
<body>
<h:outputText value="You should NOT see this." rendered="#{test:isGranted('ONE_ROLE')}"/>
</body>
</html>