我创建了一个动态页面,其中包含一些 ace:tabPane,每个 xhtml 页面中都有一棵树:
<ui:define name="subContent">
<div>
<h:form>
<ace:tabSet binding="#{configProfilesBean.tabSet}"
>
</ace:tabSet>
</h:form>
</div>
</ui:define>
在页面后面我有一个 bean configProfilesBean,我在其中创建绑定在页面中的选项卡集并动态一些 ace:tabPane:
tabSet = new TabSet();
tabSet.getChildren().clear();
tabSet.setId("tabSetConfigProfiles");
tabSet.setClientSide(false);
for (FunzioneDTO f : funzioni) {
tabSet.getChildren().add(createTabPane(f));
}
方法createTabPane(FunzioneDTO function)
:
private TabPane createTabPane (FunzioneDTO function){
TabPane tabPane = new TabPane();
tabPane.setId("fnz_"+function.getId());
tabPane.setLabel(function.getNome());
Tree tree = new Tree();
TreeModel model = new TreeModel(function);
tree.setId("tr_"+function.getId());
tree.setValue(model.getModel());
tabPane.getChildren().add(tree);
return tabPane;
}
然后这是 TreeModel 的类:
public class TreeModel implements javax.swing.tree.TreeModel{
private DefaultTreeModel model;
private DefaultMutableTreeNode rootTreeNode;
private FunzioneDTO function;
public TreeModel(FunzioneDTO function){
this.function = function;
IceUserObject rootObject = new IceUserObject(getRootTreeNode());
rootObject.setText("ROOT");
rootObject.setExpanded(true);
getRootTreeNode().setUserObject(rootObject);
if(function.getAzioni().size()>0){
for(AzioneDTO a : function.getAzioni()){
getRootTreeNode().add(addActionChildNode(a));
}
}
}
private DefaultMutableTreeNode addActionChildNode(AzioneDTO action){
DefaultMutableTreeNode childAction = new DefaultMutableTreeNode();
IceUserObject actionObject = new IceUserObject(childAction);
actionObject.setText("A_"+action.getId());
actionObject.setLeaf(true);
childAction.setUserObject(actionObject);
return childAction;
}
public DefaultTreeModel getModel() {
if(model == null){
model = new DefaultTreeModel(getRootTreeNode());
}
return model;
}
public void setModel(DefaultTreeModel model) {
this.model = model;
}
public DefaultMutableTreeNode getRootTreeNode() {
if(rootTreeNode == null){
rootTreeNode = new DefaultMutableTreeNode();
}
return rootTreeNode;
}
public void setRootTreeNode(DefaultMutableTreeNode rootTreeNode) {
this.rootTreeNode = rootTreeNode;
}
public FunzioneDTO getFunction() {
return function;
}
public void setFunction(FunzioneDTO function) {
this.function = function;
}
@Override
public Object getRoot() {
return getModel().getRoot();
}
@Override
public Object getChild(Object parent, int index) {
return getModel().getChild(parent, index);
}
@Override
public int getChildCount(Object parent) {
return getModel().getChildCount(parent);
}
@Override
public boolean isLeaf(Object node) {
return getModel().isLeaf(node);
}
@Override
public void valueForPathChanged(TreePath path, Object newValue) {
getModel().valueForPathChanged(path, newValue);
}
@Override
public int getIndexOfChild(Object parent, Object child) {
return getModel().getIndexOfChild(parent, child);
}
@Override
public void addTreeModelListener(TreeModelListener l) {
getModel().addTreeModelListener(l);
}
@Override
public void removeTreeModelListener(TreeModelListener l) {
getModel().removeTreeModelListener(l);
}
}
当我转到该页面时,我有一个由 nullpointerexception 引起的堆栈跟踪,我不知道如何解决:
15:31:25,204 Grave [javax.enterprise.resource.webcontainer.jsf.application] Error Rendering View[/views/protected/profiles/configProfiles.xhtml]: java.lang.NullPointerException
at com.icesoft.faces.component.tree.Tree.getModel(Tree.java:277) [:]
at com.icesoft.faces.component.tree.Tree.visitRows(Tree.java:1459) [:]
at com.icesoft.faces.component.tree.Tree.visitTree(Tree.java:1414) [:]
at javax.faces.component.UIComponent.visitTree(UIComponent.java:1623) [:2.1.17]
at javax.faces.component.UIComponent.visitTree(UIComponent.java:1623) [:2.1.17]
at javax.faces.component.UIComponent.visitTree(UIComponent.java:1623) [:2.1.17]
at javax.faces.component.UIForm.visitTree(UIForm.java:371) [:2.1.17]
at javax.faces.component.UIComponent.visitTree(UIComponent.java:1623) [:2.1.17]
at javax.faces.component.UIComponent.visitTree(UIComponent.java:1623) [:2.1.17]
at javax.faces.component.UIComponent.visitTree(UIComponent.java:1623) [:2.1.17]
at javax.faces.component.UIComponent.visitTree(UIComponent.java:1623) [:2.1.17]
at org.icefaces.impl.event.RestoreResourceDependencies.processEvent(RestoreResourceDependencies.java:24) [:]
at javax.faces.event.SystemEvent.processListener(SystemEvent.java:106) [:2.1.17]
at com.sun.faces.application.ApplicationImpl.processListeners(ApplicationImpl.java:2169) [:2.1.17]
at com.sun.faces.application.ApplicationImpl.invokeListenersFor(ApplicationImpl.java:2145) [:2.1.17]
at com.sun.faces.application.ApplicationImpl.publishEvent(ApplicationImpl.java:303) [:2.1.17]
at com.sun.faces.application.ApplicationImpl.publishEvent(ApplicationImpl.java:247) [:2.1.17]
at javax.faces.component.UIComponentBase.encodeBegin(UIComponentBase.java:812) [:2.1.17]
at javax.faces.component.UIViewRoot.encodeBegin(UIViewRoot.java:963) [:2.1.17]
at javax.faces.component.UIComponent.encodeAll(UIComponent.java:1777) [:2.1.17]
at com.sun.faces.application.view.FaceletViewHandlingStrategy.renderView(FaceletViewHandlingStrategy.java:437) [:2.1.17]
at com.sun.faces.application.view.MultiViewHandler.renderView(MultiViewHandler.java:124) [:2.1.17]
at com.sun.faces.lifecycle.RenderResponsePhase.execute(RenderResponsePhase.java:120) [:2.1.17]
at com.sun.faces.lifecycle.Phase.doPhase(Phase.java:101) [:2.1.17]
at com.sun.faces.lifecycle.LifecycleImpl.render(LifecycleImpl.java:139) [:2.1.17]
at javax.faces.webapp.FacesServlet.service(FacesServlet.java:594) [:2.1.17]
at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:324) [:6.1.0.Final]
at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:242) [:6.1.0.Final]
at it.pegaso2000.access.web.filter.AccessFilter.doFilter(AccessFilter.java:77) [:]
at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:274) [:6.1.0.Final]
at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:242) [:6.1.0.Final]
at org.springframework.security.web.FilterChainProxy$VirtualFilterChain.doFilter(FilterChainProxy.java:330) [:3.1.3.RELEASE]
at org.springframework.security.web.access.intercept.FilterSecurityInterceptor.invoke(FilterSecurityInterceptor.java:118) [:3.1.3.RELEASE]
at org.springframework.security.web.access.intercept.FilterSecurityInterceptor.doFilter(FilterSecurityInterceptor.java:84) [:3.1.3.RELEASE]
at org.springframework.security.web.FilterChainProxy$VirtualFilterChain.doFilter(FilterChainProxy.java:342) [:3.1.3.RELEASE]
at org.springframework.security.web.access.ExceptionTranslationFilter.doFilter(ExceptionTranslationFilter.java:113) [:3.1.3.RELEASE]
at org.springframework.security.web.FilterChainProxy$VirtualFilterChain.doFilter(FilterChainProxy.java:342) [:3.1.3.RELEASE]
at org.springframework.security.web.authentication.logout.LogoutFilter.doFilter(LogoutFilter.java:105) [:3.1.3.RELEASE]
at org.springframework.security.web.FilterChainProxy$VirtualFilterChain.doFilter(FilterChainProxy.java:342) [:3.1.3.RELEASE]
at org.springframework.security.web.authentication.preauth.AbstractPreAuthenticatedProcessingFilter.doFilter(AbstractPreAuthenticatedProcessingFilter.java:94) [:3.1.3.RELEASE]
at org.springframework.security.web.FilterChainProxy$VirtualFilterChain.doFilter(FilterChainProxy.java:342) [:3.1.3.RELEASE]
at org.springframework.security.web.context.SecurityContextPersistenceFilter.doFilter(SecurityContextPersistenceFilter.java:87) [:3.1.3.RELEASE]
at org.springframework.security.web.FilterChainProxy$VirtualFilterChain.doFilter(FilterChainProxy.java:342) [:3.1.3.RELEASE]
at org.springframework.security.web.FilterChainProxy.doFilterInternal(FilterChainProxy.java:192) [:3.1.3.RELEASE]
at org.springframework.security.web.FilterChainProxy.doFilter(FilterChainProxy.java:160) [:3.1.3.RELEASE]
at org.springframework.web.filter.DelegatingFilterProxy.invokeDelegate(DelegatingFilterProxy.java:346) [:3.1.3.RELEASE]
at org.springframework.web.filter.DelegatingFilterProxy.doFilter(DelegatingFilterProxy.java:259) [:3.1.3.RELEASE]
at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:274) [:6.1.0.Final]
at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:242) [:6.1.0.Final]
at org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:275) [:6.1.0.Final]
at org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:161) [:6.1.0.Final]
at org.jboss.web.tomcat.security.SecurityAssociationValve.invoke(SecurityAssociationValve.java:181) [:6.1.0.Final]
at org.apache.catalina.authenticator.AuthenticatorBase.invoke(AuthenticatorBase.java:593) [:6.1.0.Final]
at org.jboss.modcluster.catalina.CatalinaContext$RequestListenerValve.event(CatalinaContext.java:285) [:1.1.0.Final]
at org.jboss.modcluster.catalina.CatalinaContext$RequestListenerValve.invoke(CatalinaContext.java:261) [:1.1.0.Final]
at org.jboss.web.tomcat.security.JaccContextValve.invoke(JaccContextValve.java:88) [:6.1.0.Final]
at org.jboss.web.tomcat.security.SecurityContextEstablishmentValve.invoke(SecurityContextEstablishmentValve.java:100) [:6.1.0.Final]
at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:159) [:6.1.0.Final]
at org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:102) [:6.1.0.Final]
at org.jboss.web.tomcat.service.jca.CachedConnectionValve.invoke(CachedConnectionValve.java:158) [:6.1.0.Final]
at org.apache.catalina.authenticator.SingleSignOn.invoke(SingleSignOn.java:416) [:6.1.0.Final]
at org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:109) [:6.1.0.Final]
at org.jboss.web.tomcat.service.request.ActiveRequestResponseCacheValve.invoke(ActiveRequestResponseCacheValve.java:53) [:6.1.0.Final]
at org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:362) [:6.1.0.Final]
at org.apache.coyote.http11.Http11Processor.process(Http11Processor.java:877) [:6.1.0.Final]
at org.apache.coyote.http11.Http11Protocol$Http11ConnectionHandler.process(Http11Protocol.java:654) [:6.1.0.Final]
at org.apache.tomcat.util.net.JIoEndpoint$Worker.run(JIoEndpoint.java:951) [:6.1.0.Final]
at java.lang.Thread.run(Thread.java:722) [:1.7.0]
15:31:25,250 Avvertenza [org.icefaces.impl.application.ExtendedExceptionHandler] queued exception: java.lang.NullPointerException
at com.icesoft.faces.component.tree.Tree.getModel(Tree.java:277) [:]
at com.icesoft.faces.component.tree.Tree.visitRows(Tree.java:1459) [:]
at com.icesoft.faces.component.tree.Tree.visitTree(Tree.java:1414) [:]
at javax.faces.component.UIComponent.visitTree(UIComponent.java:1623) [:2.1.17]
at javax.faces.component.UIComponent.visitTree(UIComponent.java:1623) [:2.1.17]
at javax.faces.component.UIComponent.visitTree(UIComponent.java:1623) [:2.1.17]
at javax.faces.component.UIForm.visitTree(UIForm.java:371) [:2.1.17]
at javax.faces.component.UIComponent.visitTree(UIComponent.java:1623) [:2.1.17]
at javax.faces.component.UIComponent.visitTree(UIComponent.java:1623) [:2.1.17]
at javax.faces.component.UIComponent.visitTree(UIComponent.java:1623) [:2.1.17]
at javax.faces.component.UIComponent.visitTree(UIComponent.java:1623) [:2.1.17]
at org.icefaces.impl.event.RestoreResourceDependencies.processEvent(RestoreResourceDependencies.java:24) [:]
at javax.faces.event.SystemEvent.processListener(SystemEvent.java:106) [:2.1.17]
at com.sun.faces.application.ApplicationImpl.processListeners(ApplicationImpl.java:2169) [:2.1.17]
at com.sun.faces.application.ApplicationImpl.invokeListenersFor(ApplicationImpl.java:2145) [:2.1.17]
at com.sun.faces.application.ApplicationImpl.publishEvent(ApplicationImpl.java:303) [:2.1.17]
at com.sun.faces.application.ApplicationImpl.publishEvent(ApplicationImpl.java:247) [:2.1.17]
at javax.faces.component.UIComponentBase.encodeBegin(UIComponentBase.java:812) [:2.1.17]
at javax.faces.component.UIViewRoot.encodeBegin(UIViewRoot.java:963) [:2.1.17]
at javax.faces.component.UIComponent.encodeAll(UIComponent.java:1777) [:2.1.17]
at com.sun.faces.application.view.FaceletViewHandlingStrategy.renderView(FaceletViewHandlingStrategy.java:437) [:2.1.17]
at com.sun.faces.application.view.MultiViewHandler.renderView(MultiViewHandler.java:124) [:2.1.17]
at com.sun.faces.lifecycle.RenderResponsePhase.execute(RenderResponsePhase.java:120) [:2.1.17]
at com.sun.faces.lifecycle.Phase.doPhase(Phase.java:101) [:2.1.17]
at com.sun.faces.lifecycle.LifecycleImpl.render(LifecycleImpl.java:139) [:2.1.17]
at javax.faces.webapp.FacesServlet.service(FacesServlet.java:594) [:2.1.17]
at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:324) [:6.1.0.Final]
at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:242) [:6.1.0.Final]
at it.pegaso2000.access.web.filter.AccessFilter.doFilter(AccessFilter.java:77) [:]
at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:274) [:6.1.0.Final]
at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:242) [:6.1.0.Final]
at org.springframework.security.web.FilterChainProxy$VirtualFilterChain.doFilter(FilterChainProxy.java:330) [:3.1.3.RELEASE]
at org.springframework.security.web.access.intercept.FilterSecurityInterceptor.invoke(FilterSecurityInterceptor.java:118) [:3.1.3.RELEASE]
at org.springframework.security.web.access.intercept.FilterSecurityInterceptor.doFilter(FilterSecurityInterceptor.java:84) [:3.1.3.RELEASE]
at org.springframework.security.web.FilterChainProxy$VirtualFilterChain.doFilter(FilterChainProxy.java:342) [:3.1.3.RELEASE]
at org.springframework.security.web.access.ExceptionTranslationFilter.doFilter(ExceptionTranslationFilter.java:113) [:3.1.3.RELEASE]
at org.springframework.security.web.FilterChainProxy$VirtualFilterChain.doFilter(FilterChainProxy.java:342) [:3.1.3.RELEASE]
at org.springframework.security.web.authentication.logout.LogoutFilter.doFilter(LogoutFilter.java:105) [:3.1.3.RELEASE]
at org.springframework.security.web.FilterChainProxy$VirtualFilterChain.doFilter(FilterChainProxy.java:342) [:3.1.3.RELEASE]
at org.springframework.security.web.authentication.preauth.AbstractPreAuthenticatedProcessingFilter.doFilter(AbstractPreAuthenticatedProcessingFilter.java:94) [:3.1.3.RELEASE]
at org.springframework.security.web.FilterChainProxy$VirtualFilterChain.doFilter(FilterChainProxy.java:342) [:3.1.3.RELEASE]
at org.springframework.security.web.context.SecurityContextPersistenceFilter.doFilter(SecurityContextPersistenceFilter.java:87) [:3.1.3.RELEASE]
at org.springframework.security.web.FilterChainProxy$VirtualFilterChain.doFilter(FilterChainProxy.java:342) [:3.1.3.RELEASE]
at org.springframework.security.web.FilterChainProxy.doFilterInternal(FilterChainProxy.java:192) [:3.1.3.RELEASE]
at org.springframework.security.web.FilterChainProxy.doFilter(FilterChainProxy.java:160) [:3.1.3.RELEASE]
at org.springframework.web.filter.DelegatingFilterProxy.invokeDelegate(DelegatingFilterProxy.java:346) [:3.1.3.RELEASE]
at org.springframework.web.filter.DelegatingFilterProxy.doFilter(DelegatingFilterProxy.java:259) [:3.1.3.RELEASE]
at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:274) [:6.1.0.Final]
at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:242) [:6.1.0.Final]
at org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:275) [:6.1.0.Final]
at org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:161) [:6.1.0.Final]
at org.jboss.web.tomcat.security.SecurityAssociationValve.invoke(SecurityAssociationValve.java:181) [:6.1.0.Final]
at org.apache.catalina.authenticator.AuthenticatorBase.invoke(AuthenticatorBase.java:593) [:6.1.0.Final]
at org.jboss.modcluster.catalina.CatalinaContext$RequestListenerValve.event(CatalinaContext.java:285) [:1.1.0.Final]
at org.jboss.modcluster.catalina.CatalinaContext$RequestListenerValve.invoke(CatalinaContext.java:261) [:1.1.0.Final]
at org.jboss.web.tomcat.security.JaccContextValve.invoke(JaccContextValve.java:88) [:6.1.0.Final]
at org.jboss.web.tomcat.security.SecurityContextEstablishmentValve.invoke(SecurityContextEstablishmentValve.java:100) [:6.1.0.Final]
at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:159) [:6.1.0.Final]
at org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:102) [:6.1.0.Final]
at org.jboss.web.tomcat.service.jca.CachedConnectionValve.invoke(CachedConnectionValve.java:158) [:6.1.0.Final]
at org.apache.catalina.authenticator.SingleSignOn.invoke(SingleSignOn.java:416) [:6.1.0.Final]
at org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:109) [:6.1.0.Final]
at org.jboss.web.tomcat.service.request.ActiveRequestResponseCacheValve.invoke(ActiveRequestResponseCacheValve.java:53) [:6.1.0.Final]
at org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:362) [:6.1.0.Final]
at org.apache.coyote.http11.Http11Processor.process(Http11Processor.java:877) [:6.1.0.Final]
at org.apache.coyote.http11.Http11Protocol$Http11ConnectionHandler.process(Http11Protocol.java:654) [:6.1.0.Final]
at org.apache.tomcat.util.net.JIoEndpoint$Worker.run(JIoEndpoint.java:951) [:6.1.0.Final]
at java.lang.Thread.run(Thread.java:722) [:1.7.0]
有人知道如何解决吗?谢谢