В моем приложении JSF 2.0 есть важные части:
functions.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 xmlns="http://java.sun.com/JSF/Facelet">
<namespace>http://marius/components</namespace>
<function>
<function-name>empty</function-name>
<function-class>com.test.ui.function.JsfFunctions</function-class>
<function-signature>java.util.Boolean empty(java.lang.Object)</function-signature>
</function>
</facelet-taglib>
Класс JsfFunctions :
package com.test.ui.function.function;
public class JsfFunctions {
public static boolean empty(Object obj) {
return obj == null;
}
}
web.xml
<context-param>
<param-name>org.apache.myfaces.EXPRESSION_FACTORY</param-name>
<param-value>com.sun.el.ExpressionFactoryImpl</param-value>
</context-param>
<context-param>
<param-name>com.sun.faces.expressionFactory</param-name>
<param-value>com.sun.el.ExpressionFactoryImpl</param-value>
</context-param>
<context-param>
<param-name>facelets.LIBRARIES</param-name>
<param-value>/META-INF/functions.taglib.xml</param-value>
</context-param>
pom.xml
<dependency>
<groupId>javax.el</groupId>
<artifactId>el-api</artifactId>
<version>2.2</version>
</dependency>
<dependency>
<groupId>org.glassfish.web</groupId>
<artifactId>el-impl</artifactId>
<version>2.2</version>
</dependency>
XHTML-файл :
<?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">
<ui:composition xmlns="http://www.w3.org/1999/xhtml"
xmlns:h="http://java.sun.com/jsf/html"
xmlns:f="http://java.sun.com/jsf/core"
xmlns:ui="http://java.sun.com/jsf/facelets"
xmlns:c="http://java.sun.com/jsp/jstl/core"
xmlns:t="http://myfaces.apache.org/tomahawk"
xmlns:func="http://marius/components"
xmlns:composite="http://java.sun.com/jsf/composite">
<composite:interface>
<composite:attribute name="rendered" default="#{true}" />
</composite:interface>
<composite:implementation>
<t:dataScroller id="#{cc.attrs.tableId}Scroller"
for="#{cc.attrs.tableId}"
rendered="#{cc.attrs.rendered and !func:empty(cc.attrs.dataModel)}">
....
Я получаю эту ошибку :
javax.el.ELException: Error Parsing: #{cc.attrs.rendered and !cl:empty(cc.attrs.dataModel)}
com.sun.el.lang.ExpressionBuilder.createNodeInternal(ExpressionBuilder.java:171)
com.sun.el.lang.ExpressionBuilder.build(ExpressionBuilder.java:188)
com.sun.el.parser.ParseException: Encountered ":" at line 1, column 28.
Was expecting one of:
"}" ...
"." ...
"[" ...
Когда я отключаю интеграцию EL 2.2, все работает нормально. Означает ли это, что EL 2.2 не работает с пользовательскими функциями EL?