NPE以编程方式添加复合组件

时间:2015-01-13 09:50:21

标签: jsf-2 omnifaces

以编程方式添加复合组件时出现以下异常

java.lang.NullPointerException: null
    at com.sun.faces.application.view.FaceletViewHandlingStrategy.getComponentMetadata(FaceletViewHandlingStrategy.java:220) ~[javax.faces.jar:2.1.6-SNAPSHOT]
    at com.sun.faces.application.ApplicationImpl.createComponent(ApplicationImpl.java:938) ~[javax.faces.jar:2.1.6-SNAPSHOT]
    at javax.faces.application.ApplicationWrapper.createComponent(ApplicationWrapper.java:605) ~[javax.faces.jar:2.1.6-SNAPSHOT]
    at javax.faces.application.ApplicationWrapper.createComponent(ApplicationWrapper.java:605) ~[javax.faces.jar:2.1.6-SNAPSHOT]
    at javax.faces.application.ApplicationWrapper.createComponent(ApplicationWrapper.java:605) ~[javax.faces.jar:2.1.6-SNAPSHOT]
    at javax.faces.application.ApplicationWrapper.createComponent(ApplicationWrapper.java:605) ~[javax.faces.jar:2.1.6-SNAPSHOT]
    at org.omnifaces.util.Components.includeCompositeComponent(Components.java:320) ~[omnifaces-1.6.jar:1.6]

Components.includeCompositeComponent(form,
        "ccomp", "ccomponent.xhtml", "ccomponentId");

javax.faces.PARTIAL_STATE_SAVING = true时不会出现NPE。但是当true时,在其他地方会出现重复的ID错误。

如何解决这个问题?

1 个答案:

答案 0 :(得分:0)

你可能在错误的阶段做到这一点。尝试在postAddToView阶段执行此操作。

List of JSF 2 events?