1

我正在尝试在我的 Web 应用程序中使用新的直通属性功能,但是我遇到了可空属性的问题。这是代码:

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" 

"http://www.w3.org/TR/html4/loose.dtd">
<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:ui="http://java.sun.com/jsf/facelets"
      xmlns:p="http://primefaces.org/ui" 
      xmlns:util="http://xmlns.jcp.org/jsf/composite/util"
      xmlns:pt="http://xmlns.jcp.org/jsf/passthrough"
      xmlns:c="http://xmlns.jcp.org/jsp/jstl/core">
...
<p:outputPanel  pt:example="#{mybean.nullableAttribute}"  >
...
</p:outputPanel>

我得到了例外:

ERROR  javax.enterprise.resource.webcontainer.jsf.application 12:01:09.205 [http-listener-1(3)]  - Error Rendering View[/index.xhtml]
java.lang.NullPointerException: null
    at com.sun.faces.renderkit.html_basic.HtmlResponseWriter.getAttributeValue(HtmlResponseWriter.java:1215) ~[javax.faces-2.2.6.jar:2.2.6]
    at com.sun.faces.renderkit.html_basic.HtmlResponseWriter.flushAttributes(HtmlResponseWriter.java:1175) ~[javax.faces-2.2.6.jar:2.2.6]
    at com.sun.faces.renderkit.html_basic.HtmlResponseWriter.closeStartIfNecessary(HtmlResponseWriter.java:1117) ~[javax.faces-2.2.6.jar:2.2.6]
    at com.sun.faces.renderkit.html_basic.HtmlResponseWriter.startElement(HtmlResponseWriter.java:646) ~[javax.faces-2.2.6.jar:2.2.6]
    at org.primefaces.component.growl.GrowlRenderer.encodeEnd(GrowlRenderer.java:38) ~[primefaces-4.0.jar:4.0]
    at javax.faces.component.UIComponentBase.encodeEnd(UIComponentBase.java:919) ~[javax.faces-2.2.6.jar:2.2.6]
    at org.primefaces.renderkit.CoreRenderer.renderChild(CoreRenderer.java:74) ~[primefaces-4.0.jar:4.0]
    at org.primefaces.renderkit.CoreRenderer.renderChildren(CoreRenderer.java:57) ~[primefaces-4.0.jar:4.0]
    at org.primefaces.component.outputpanel.OutputPanelRenderer.encodeMarkup(OutputPanelRenderer.java:64) ~[primefaces-4.0.jar:4.0]
    at org.primefaces.component.outputpanel.OutputPanelRenderer.encodeEnd(OutputPanelRenderer.java:40) ~[primefaces-4.0.jar:4.0]
    at javax.faces.component.UIComponentBase.encodeEnd(UIComponentBase.java:919) ~[javax.faces-2.2.6.jar:2.2.6]
    at javax.faces.component.UIComponent.encodeAll(UIComponent.java:1864) ~[javax.faces-2.2.6.jar:2.2.6]
    at javax.faces.render.Renderer.encodeChildren(Renderer.java:176) ~[javax.faces-2.2.6.jar:2.2.6]
    at javax.faces.component.UIComponentBase.encodeChildren(UIComponentBase.java:889) ~[javax.faces-2.2.6.jar:2.2.6]
    at javax.faces.component.UIComponent.encodeAll(UIComponent.java:1857) ~[javax.faces-2.2.6.jar:2.2.6]
    at javax.faces.component.UIComponent.encodeAll(UIComponent.java:1860) ~[javax.faces-2.2.6.jar:2.2.6]
    at javax.faces.component.UIComponent.encodeAll(UIComponent.java:1860) ~[javax.faces-2.2.6.jar:2.2.6]

当属性为空时。当它不为空时它确实有效。我尝试过使用 mojarra 2.2.0 和 2.2.6(我在 glassfish 4.0 上)

有任何想法吗?

谢谢!

4

2 回答 2

3

此错误已报告为问题 3208已在 Mojarra 2.2.7 中修复。

因此,至少应该升级到该版本。目前,它已经是 2.2.8。

于 2014-09-08T07:29:58.127 回答
0

我终于使用了一个自定义的 EL 函数

于 2014-05-18T09:34:45.887 回答