2016-05-06 13 views
0

Primefaces picklistコンポーネントに問題があります。ボタンをクリックすると、DualListModelオブジェクトが初期化されます。ソースとターゲットの両方のリストにStringオブジェクトがあります。ここに私のコードです。 XHTML: `クラスキャスト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コード:

private DualListModel<String> userTokensList; 

とは、GOボタンを押した後、次のコードが呼び出されます。

List<String> sourceList=new ArrayList<String>(); 
List<String> targetList=new ArrayList<String>(); 
sourceList.add("abc"); 
sourceList.add("234"); 
targetList.add("1234"); 
targetList.add("980");   
userTokensList=new DualListModel<String>(sourceList, targetList); 

//setters and getters provided` 

「GO」ボタンを押した後にページを読み込もうとすると、以下のエラーが表示されます。

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) 

私はStringオブジェクトのみを使用しているので、カスタムコンバーターを使用する必要はないと思います。問題は、あなたがそれを削除

value="#{userAdministrationBean.userTokensList} " 

の末尾にスペースがあることであることの後に私の作品

答えて

0

示唆してください。

Errormessageは間違いなく良いかもしれません!

+0

これは動作しますが、Errormessageは現在のコンテキストとは関係ありません。 – Sagar

関連する問題