1
votes

I have an issue with Primefaces picklist component. On clicking of a button I am initializing DualListModel object. which has String objects in both the source and target list. Here is my code. XHTML:`

<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;

and after pressing GO button the following code is called.

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`

and when trying to load the page after pressig 'GO' button getting the below error.

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)

Since I am using only String objects, I think no need to use any custom converter. Please suggest

1

1 Answers

0
votes

The problem is that you have a space at the end of

value="#{userAdministrationBean.userTokensList} "

Remove it, works for me after that.

Errormessage could definetly be better!