2016-05-06 8 views
0

Ich habe ein Problem mit der Picklist-Komponente von Primefaces. Beim Klicken auf eine Schaltfläche initialisiere ich das DualListModel-Objekt. mit String-Objekten in der Quell- und Zielliste. Hier ist mein Code. XHTML: `Class cast Ausnahme mit p: pickList

<p:commandButton value="Go" update="userTokens" 
    actionListener="#{userAdministrationBean.fetchUserTokens}" /> 
<p:pickList value="#{userAdministrationBean.userTokensList} " 
       id="userTokens" var="token" itemLabel="#{token}" itemValue="#{token}"> 
</p:pickList> 

Java-Code:

private DualListModel<String> userTokensList; 

und nach GO-Taste der folgende Code drücken aufgerufen.

und wenn Sie versuchen, die Seite nach dem Drücken der Schaltfläche "GO" zu laden, wird der folgende Fehler angezeigt.

StackTrace:java.lang.ClassCastException: java.lang.String incompatible with org.primefaces.model.DualListModel 
    at org.primefaces.component.picklist.PickListRenderer.encodeMarkup(PickListRenderer.java:66) 
    at org.primefaces.component.picklist.PickListRenderer.encodeEnd(PickListRenderer.java:59) 
    at javax.faces.component.UIComponentBase.encodeEnd(UIComponentBase.java:535) 
    at javax.faces.component.UIComponent.encodeAll(UIComponent.java:626) 
    at org.apache.myfaces.context.servlet.PartialViewContextImpl$PhaseAwareVisitCallback.processRenderComponent(PartialViewContextImpl.java:559) 
    at org.apache.myfaces.context.servlet.PartialViewContextImpl$PhaseAwareVisitCallback.visit(PartialViewContextImpl.java:537) 
    at org.apache.myfaces.component.visit.PartialVisitContext.invokeVisitCallback(PartialVisitContext.java:207) 
    at javax.faces.component.UIComponent.visitTree(UIComponent.java:773) 
    at javax.faces.component.UIComponentBase.visitTree(UIComponentBase.java:1007) 
    at javax.faces.component.UIComponent.visitTree(UIComponent.java:793) 
    at javax.faces.component.UIComponentBase.visitTree(UIComponentBase.java:1007) 
    at javax.faces.component.UIForm.visitTree(UIForm.java:269) 
    at javax.faces.component.UIComponent.visitTree(UIComponent.java:793) 
    at javax.faces.component.UIComponentBase.visitTree(UIComponentBase.java:1007) 
    at javax.faces.component.UIComponent.visitTree(UIComponent.java:793) 
    at javax.faces.component.UIComponentBase.visitTree(UIComponentBase.java:1007) 
    at org.apache.myfaces.context.servlet.PartialViewContextImpl.processPartialRendering(PartialViewContextImpl.java:426) 
    at org.apache.myfaces.context.servlet.PartialViewContextImpl.processPartial(PartialViewContextImpl.java:346) 
    at org.primefaces.context.PrimePartialViewContext.processPartial(PrimePartialViewContext.java:60) 
    at javax.faces.component.UIViewRoot.encodeChildren(UIViewRoot.java:390) 
    at javax.faces.component.UIComponent.encodeAll(UIComponent.java:617) 
    at org.apache.myfaces.view.facelets.FaceletViewDeclarationLanguage.renderView(FaceletViewDeclarationLanguage.java:1320) 
    at org.apache.myfaces.application.ViewHandlerImpl.renderView(ViewHandlerImpl.java:263) 
    at org.apache.myfaces.lifecycle.RenderResponseExecutor.execute(RenderResponseExecutor.java:85) 
    at org.apache.myfaces.lifecycle.LifecycleImpl.render(LifecycleImpl.java:240) 
    at javax.faces.webapp.FacesServlet.service(FacesServlet.java:191) 
    at com.ibm.ws.webcontainer.servlet.ServletWrapper.service(ServletWrapper.java:1227) 
    at com.ibm.ws.webcontainer.servlet.ServletWrapper.handleRequest(ServletWrapper.java:776) 
    at com.ibm.ws.webcontainer.servlet.ServletWrapper.handleRequest(ServletWrapper.java:458) 
    at com.ibm.ws.webcontainer.servlet.ServletWrapperImpl.handleRequest(ServletWrapperImpl.java:178) 
    at com.ibm.ws.webcontainer.filter.WebAppFilterChain.invokeTarget(WebAppFilterChain.java:136) 
    at com.ibm.ws.webcontainer.filter.WebAppFilterChain.doFilter(WebAppFilterChain.java:97) 
    at org.primefaces.webapp.filter.FileUploadFilter.doFilter(FileUploadFilter.java:100) 
    at com.ibm.ws.webcontainer.filter.FilterInstanceWrapper.doFilter(FilterInstanceWrapper.java:195) 
    at com.ibm.ws.webcontainer.filter.WebAppFilterChain.doFilter(WebAppFilterChain.java:91) 
    at com.csx.rarsafety.filter.RendererFilter.doFilter(RendererFilter.java:285) 
    at com.ibm.ws.webcontainer.filter.FilterInstanceWrapper.doFilter(FilterInstanceWrapper.java:195) 
    at com.ibm.ws.webcontainer.filter.WebAppFilterChain.doFilter(WebAppFilterChain.java:91) 
    at com.csx.rarsafety.view.user.NoCompatibilityMode.doFilter(NoCompatibilityMode.java:26) 
    at com.ibm.ws.webcontainer.filter.FilterInstanceWrapper.doFilter(FilterInstanceWrapper.java:195) 
    at com.ibm.ws.webcontainer.filter.WebAppFilterChain.doFilter(WebAppFilterChain.java:91) 
    at com.csx.enterprise.webframework.security.CSXSamlSecurityFilter.doFilter(CSXSamlSecurityFilter.java:59) 
    at com.ibm.ws.webcontainer.filter.FilterInstanceWrapper.doFilter(FilterInstanceWrapper.java:195) 
    at com.ibm.ws.webcontainer.filter.WebAppFilterChain.doFilter(WebAppFilterChain.java:91) 
    at com.ibm.ws.webcontainer.filter.WebAppFilterManager.doFilter(WebAppFilterManager.java:928) 
    at com.ibm.ws.webcontainer.filter.WebAppFilterManager.invokeFilters(WebAppFilterManager.java:1025) 
    at com.ibm.ws.webcontainer.servlet.CacheServletWrapper.handleRequest(CacheServletWrapper.java:87) 
    at com.ibm.ws.webcontainer.WebContainer.handleRequest(WebContainer.java:909) 
    at com.ibm.ws.webcontainer.WSWebContainer.handleRequest(WSWebContainer.java:1662) 
    at com.ibm.ws.webcontainer.channel.WCChannelLink.ready(WCChannelLink.java:200) 
    at com.ibm.ws.http.channel.inbound.impl.HttpInboundLink.handleDiscrimination(HttpInboundLink.java:459) 
    at com.ibm.ws.http.channel.inbound.impl.HttpInboundLink.handleNewRequest(HttpInboundLink.java:526) 
    at com.ibm.ws.http.channel.inbound.impl.HttpInboundLink.processRequest(HttpInboundLink.java:312) 
    at com.ibm.ws.http.channel.inbound.impl.HttpInboundLink.ready(HttpInboundLink.java:283) 
    at com.ibm.ws.ssl.channel.impl.SSLConnectionLink.determineNextChannel(SSLConnectionLink.java:1048) 
    at com.ibm.ws.ssl.channel.impl.SSLConnectionLink.readyInboundPostHandshake(SSLConnectionLink.java:716) 
    at com.ibm.ws.ssl.channel.impl.SSLConnectionLink$MyHandshakeCompletedCallback.complete(SSLConnectionLink.java:412) 
    at com.ibm.ws.ssl.channel.impl.SSLUtils.handleHandshake(SSLUtils.java:1066) 
    at com.ibm.ws.ssl.channel.impl.SSLHandshakeIOCallback.complete(SSLHandshakeIOCallback.java:87) 
    at com.ibm.ws.tcp.channel.impl.AioReadCompletionListener.futureCompleted(AioReadCompletionListener.java:175) 
    at com.ibm.io.async.AbstractAsyncFuture.invokeCallback(AbstractAsyncFuture.java:217) 
    at com.ibm.io.async.AsyncChannelFuture.fireCompletionActions(AsyncChannelFuture.java:161) 
    at com.ibm.io.async.AsyncFuture.completed(AsyncFuture.java:138) 
    at com.ibm.io.async.ResultHandler.complete(ResultHandler.java:204) 
    at com.ibm.io.async.ResultHandler.runEventProcessingLoop(ResultHandler.java:775) 
    at com.ibm.io.async.ResultHandler$2.run(ResultHandler.java:905) 
    at com.ibm.ws.util.ThreadPool$Worker.run(ThreadPool.java:1862) 

Da ich nur String-Objekte verwende, denke ich, dass Sie keinen benutzerdefinierten Konverter verwenden müssen. Bitte legen nahe,

Antwort

0

Das Problem ist, dass Sie ein Leerzeichen am Ende des

value="#{userAdministrationBean.userTokensList} " 

entfernen es haben, funktioniert für mich danach.

Fehlermeldung könnte definitiv besser sein!

+0

Ya das funktioniert, ist Errormessage nicht auf den aktuellen Kontext bezogen. – Sagar

Verwandte Themen