Maven 来自位于同一jar中的xhtml的引用EL函数
因此,我有一个jar,其中包含几个常见的.xhtml文件,我在web项目(Wildfly 8.1服务器中的JSF2.2)中使用这些文件作为自定义组件 另外,在同一个.jar中,我有一个实用程序类(ViewUtils),它有一个函数,我可以从web项目中的.xhtml文件调用该函数 问题是,我实际上想从位于函数所在的同一个jar中的.xhtml文件访问EL函数,但我不能。JBoss说EL表达式无法识别。但是,我可以从web项目(.war)中的.xhtml文件调用该函数 我要解释我自己吗? 这是代码 这是my.jar中的代码Maven 来自位于同一jar中的xhtml的引用EL函数,maven,jsf,el,taglib,Maven,Jsf,El,Taglib,因此,我有一个jar,其中包含几个常见的.xhtml文件,我在web项目(Wildfly 8.1服务器中的JSF2.2)中使用这些文件作为自定义组件 另外,在同一个.jar中,我有一个实用程序类(ViewUtils),它有一个函数,我可以从web项目中的.xhtml文件调用该函数 问题是,我实际上想从位于函数所在的同一个jar中的.xhtml文件访问EL函数,但我不能。JBoss说EL表达式无法识别。但是,我可以从web项目(.war)中的.xhtml文件调用该函数 我要解释我自己吗? 这是代码
public final class ViewUtils {
(...)
public static String getEnumMessageKey(final Enum<?> e) {
String key = "";
try {
key = "enum_" + e.getClass().getSimpleName().toLowerCase() + '_' + e.name().toLowerCase();
} catch (Exception e) {
LOG.debug("Key not found or null.");
}
return key;
}
(...)
}
如果有什么不清楚的地方,请问我。
提前谢谢。我解决了。
这个问题与外部罐子或其他任何东西无关
在我的代码中,我调用了.xhtml中的函数,如下所示:
<html xmlns="http://www.w3.org/1999/xhtml" xmlns:h="http://java.sun.com/jsf/html" xmlns:f="http://java.sun.com/jsf/core" xmlns:p="http://primefaces.org/ui"
xmlns:ui="http://java.sun.com/jsf/facelets" xmlns:composite="http://java.sun.com/jsf/composite" xmlns:cx="http://mycompany.com/taglib">
(...)
<li>#{i18n[cx:enum_key(cc.attrs.enumParam)]}: #{cc.attrs.afiliado.numeroDocumento}</li>
(...)
</composite:implementation>
</html>
<html xmlns="http://www.w3.org/1999/xhtml" xmlns:h="http://java.sun.com/jsf/html" xmlns:f="http://java.sun.com/jsf/core" xmlns:p="http://primefaces.org/ui"
xmlns:ui="http://java.sun.com/jsf/facelets" xmlns:composite="http://java.sun.com/jsf/composite" xmlns:cx="http://mycompany.com/taglib">
(...)
<li><h:outputText value="#{i18n[cx:enum_key(cc.attrs.enumParam)]} #{cc.attrs.afiliado.numeroDocumento}" /></li>
(...)
</composite:implementation>
</html>
(...)
#{i18n[cx:enum_key(cc.attrs.enumParam)]}:{cc.attrs.afiliado.numeroDocumento}
(...)
EL表达式应该位于如下值属性中:
<html xmlns="http://www.w3.org/1999/xhtml" xmlns:h="http://java.sun.com/jsf/html" xmlns:f="http://java.sun.com/jsf/core" xmlns:p="http://primefaces.org/ui"
xmlns:ui="http://java.sun.com/jsf/facelets" xmlns:composite="http://java.sun.com/jsf/composite" xmlns:cx="http://mycompany.com/taglib">
(...)
<li>#{i18n[cx:enum_key(cc.attrs.enumParam)]}: #{cc.attrs.afiliado.numeroDocumento}</li>
(...)
</composite:implementation>
</html>
<html xmlns="http://www.w3.org/1999/xhtml" xmlns:h="http://java.sun.com/jsf/html" xmlns:f="http://java.sun.com/jsf/core" xmlns:p="http://primefaces.org/ui"
xmlns:ui="http://java.sun.com/jsf/facelets" xmlns:composite="http://java.sun.com/jsf/composite" xmlns:cx="http://mycompany.com/taglib">
(...)
<li><h:outputText value="#{i18n[cx:enum_key(cc.attrs.enumParam)]} #{cc.attrs.afiliado.numeroDocumento}" /></li>
(...)
</composite:implementation>
</html>
(...)
(...)
所以,无论如何,谢谢你 Mojarra以前在解决复合材料中的EL函数时有缺陷。您使用的是哪个Mojarra 2.2.x版本?当您将
xmlns:cx=“…”
从根标记移动到
标记时,它是否工作?您是否也在composite之外的普通Facelet中对其进行了测试?实际上,我可以在my.war中的composites中执行该函数。问题在于.jar中的composites中的函数:S-Version是2.2.2-没有尝试过,但现在我尝试过,但仍然无法工作:(-是的,我尝试过在复合材料之外。我在.war内部的许多地方称之为复合材料(不是所有的都是复合材料)。谢谢!你的问题/答案中有一条红鲱鱼。是cx:
还是cnx:
?谢谢你的警告!已经编辑过了,两种情况下都是cx:
<html xmlns="http://www.w3.org/1999/xhtml" xmlns:h="http://java.sun.com/jsf/html" xmlns:f="http://java.sun.com/jsf/core" xmlns:p="http://primefaces.org/ui"
xmlns:ui="http://java.sun.com/jsf/facelets" xmlns:composite="http://java.sun.com/jsf/composite" xmlns:cx="http://mycompany.com/taglib">
(...)
<li>#{i18n[cx:enum_key(cc.attrs.enumParam)]}: #{cc.attrs.afiliado.numeroDocumento}</li>
(...)
</composite:implementation>
</html>
<html xmlns="http://www.w3.org/1999/xhtml" xmlns:h="http://java.sun.com/jsf/html" xmlns:f="http://java.sun.com/jsf/core" xmlns:p="http://primefaces.org/ui"
xmlns:ui="http://java.sun.com/jsf/facelets" xmlns:composite="http://java.sun.com/jsf/composite" xmlns:cx="http://mycompany.com/taglib">
(...)
<li><h:outputText value="#{i18n[cx:enum_key(cc.attrs.enumParam)]} #{cc.attrs.afiliado.numeroDocumento}" /></li>
(...)
</composite:implementation>
</html>