I am trying to use a SelectItem with setMultiple(true), allowing the user to pick values for a ManyToMany relationship.
When rendering the form, though, I get a ClassCastException if there are previously assigned values for the relationship.
I have tried to reduce the problem to a simple test case, but the error does not occur in my test case app. Have you seen this before? I've been trying to compare the successful version of this to the failing version; I cannot find the coding error that must exist. Perhaps this rings a bell for someone.
In the failing version, the values are actually populated most of the time, even after the warning dialog that pops up with the ClassCastException message. Sometimes, though, the numeric values are not re-rendered as the "displayField" values.
Please find the relevant supporting details below.
1. SmartClient Version: SNAPSHOT_v8.3d_2012-09-25/Enterprise Deployment (built 2012-09-25)
2. Browser: Internet Explorer 9
3. Server Log:
4. Response in the Developer Console:
5. N/A
6. Code
Creating the SelectItem:
Defining the relationship in the datasource:
When rendering the form, though, I get a ClassCastException if there are previously assigned values for the relationship.
Code:
java.lang.ClassCastException: Value '[418, 417]' of type 'class java.util.ArrayList' can not be cast to type 'class java.lang.Long'.
In the failing version, the values are actually populated most of the time, even after the warning dialog that pops up with the ClassCastException message. Sometimes, though, the numeric values are not re-rendered as the "displayField" values.
Please find the relevant supporting details below.
1. SmartClient Version: SNAPSHOT_v8.3d_2012-09-25/Enterprise Deployment (built 2012-09-25)
2. Browser: Internet Explorer 9
3. Server Log:
Code:
16:55:26,519 INFO [STDOUT] === 2012-09-27 16:55:26,510 [80-1] DEBUG RPCManager - Request #1 (DSRequest) payload: { criteria:{ id:[ 418, 417 ] }, operationConfig:{ dataSource:"authorHB", operationType:"fetch" }, componentId:"isc_DynamicForm_17", appID:"builtinApplication", operation:"authorHB_fetch", oldValues:{ id:[ 418, 417 ] } } 16:55:26,528 INFO [STDOUT] === 2012-09-27 16:55:26,519 [80-1] INFO IDACall - Performing 1 operation(s) 16:55:26,529 INFO [STDOUT] === 2012-09-27 16:55:26,529 [80-1] DEBUG DeclarativeSecurity - Processing security checks for DataSource null, field null 16:55:26,529 INFO [STDOUT] === 2012-09-27 16:55:26,529 [80-1] DEBUG DeclarativeSecurity - DataSource authorHB is not in the pre-checked list, processing... 16:55:26,529 INFO [STDOUT] === 2012-09-27 16:55:26,529 [80-1] DEBUG DeclarativeSecurity - Processing security checks for DataSource authorTypeHB, field authorTypeDescription 16:55:26,529 INFO [STDOUT] === 2012-09-27 16:55:26,529 [80-1] DEBUG DeclarativeSecurity - DataSource authorTypeHB is not in the pre-checked list, processing... 16:55:26,530 INFO [STDOUT] === 2012-09-27 16:55:26,529 [80-1] DEBUG AppBase - [builtinApplication.authorHB_fetch] No userTypes defined, allowing anyone access to all operations for this application 16:55:26,530 INFO [STDOUT] === 2012-09-27 16:55:26,530 [80-1] DEBUG AppBase - [builtinApplication.authorHB_fetch] No public zero-argument method named '_authorHB_fetch' found, performing generic datasource operation 16:55:26,530 INFO [STDOUT] === 2012-09-27 16:55:26,530 [80-1] INFO HibernateDataSource - [builtinApplication.authorHB_fetch] Performing fetch operation with criteria: {id:[418,417]} values: {id:[418,417]} 16:55:26,531 INFO [STDOUT] === 2012-09-27 16:55:26,531 [80-1] WARN RequestContext - dsRequest.execute() failed: java.lang.ClassCastException: Value '[418, 417]' of type 'class java.util.ArrayList' can not be cast to type 'class java.lang.Long'. at com.isomorphic.util.DataTools.castValue(DataTools.java:4218) at com.isomorphic.hibernate.HibernateDataSource.createPrimaryKey(HibernateDataSource.java:1417) at com.isomorphic.hibernate.HibernateDataSource.processRequest(HibernateDataSource.java:839) at com.isomorphic.hibernate.HibernateDataSource.executeFetch(HibernateDataSource.java:727) at com.isomorphic.datasource.DataSource.execute(DataSource.java:1356) at com.isomorphic.application.AppBase.executeDefaultDSOperation(AppBase.java:726) at com.isomorphic.application.AppBase.executeAppOperation(AppBase.java:658) at com.isomorphic.application.AppBase.execute(AppBase.java:491) at com.isomorphic.datasource.DSRequest.execute(DSRequest.java:2000) at com.isomorphic.servlet.IDACall.handleDSRequest(IDACall.java:216) at com.isomorphic.servlet.IDACall.processRPCTransaction(IDACall.java:173) at com.isomorphic.servlet.IDACall.processRequest(IDACall.java:138) at com.isomorphic.servlet.IDACall.doPost(IDACall.java:74) at javax.servlet.http.HttpServlet.service(HttpServlet.java:637) at com.isomorphic.servlet.BaseServlet.service(BaseServlet.java:152) at javax.servlet.http.HttpServlet.service(HttpServlet.java:717) at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:290) at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:206) at com.isomorphic.servlet.CompressionFilter.doFilter(CompressionFilter.java:259) at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:235) at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:206) at org.jboss.web.tomcat.filters.ReplyHeaderFilter.doFilter(ReplyHeaderFilter.java:96) at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:235) at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:206) at org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:235) at org.apache.catalina.core.StandardContextValve.__invoke(StandardContextValve.java:191) at org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java) at org.jboss.web.tomcat.security.SecurityAssociationValve.invoke(SecurityAssociationValve.java:183) at org.apache.catalina.authenticator.AuthenticatorBase.invoke(AuthenticatorBase.java:534) at org.jboss.web.tomcat.security.JaccContextValve.invoke(JaccContextValve.java:95) at org.jboss.web.tomcat.security.SecurityContextEstablishmentValve.process(SecurityContextEstablishmentValve.java:126) at org.jboss.web.tomcat.security.SecurityContextEstablishmentValve.invoke(SecurityContextEstablishmentValve.java:70) at org.apache.catalina.core.StandardHostValve.__invoke(StandardHostValve.java:127) at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java) at org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:102) at org.jboss.web.tomcat.service.jca.CachedConnectionValve.invoke(CachedConnectionValve.java:158) at org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:109) at org.jboss.web.tomcat.service.request.ActiveRequestResponseCacheValve.internalProcess(ActiveRequestResponseCacheValve.java:74) at org.jboss.web.tomcat.service.request.ActiveRequestResponseCacheValve.invoke(ActiveRequestResponseCacheValve.java:47) at org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:330) at org.apache.coyote.http11.Http11Processor.process(Http11Processor.java:829) at org.apache.coyote.http11.Http11Protocol$Http11ConnectionHandler.process(Http11Protocol.java:599) at org.apache.tomcat.util.net.JIoEndpoint$Worker.run(JIoEndpoint.java:451) at java.lang.Thread.run(Thread.java:662)
Code:
[ { data:"Value '[1883, 418, 417]' of type 'class java.util.ArrayList' can not be cast to type 'class java.lang.Long'.", invalidateCache:false, isDSResponse:true, queueStatus:-1, status:-1 } ]
6. Code
Creating the SelectItem:
Code:
final SelectItem selectItem = new SelectItem("authors"); selectItem.setOptionDataSource(DataSource.get("authorHB")); selectItem.setDisplayField("description"); selectItem.setMultiple(true); selectItem.setSortField("description");
Code:
<field name="authors" multiple="true" foreignKey="authorHB.id" />
Comment