Announcement

Collapse
No announcement yet.
X
  • Filter
  • Time
Clear All
new posts

    List of Strings

    Hi All:

    I am using SmartGWT 2.4. I am trying to use the DMI functionality with my pre-existing DTO's.

    Many of the attributes of my DTO has a List<String> defined in it. On create, When I pass in multiple attributes, everything works great. However, when I pass in a single attribute to be added to my list of strings, it blows up. Is there a way to define a list of text values?

    Current code Below. (Items in plural are lists of strings)

    Thanks!



    Code:
    <DataSource ID="productGroupDMI" serverType="generic" testFileName="test_data/productGroup.data.xml">
    	<fields>
    		<field name="productGroupId" type="sequence" primaryKey="true" />
    		<field name="dateUpdated" type="date" />
    		<field name="dateInserted" type="date"  />
    		<field name="name" type="text" />
    		<field name="designTemplateNames" />
    		<field name="shankMetalOnes" />
    		<field name="shankMetalTwos" />
    		<field name="centerSettingMetals" />
    		<field name="sideSettingMetals" />
    		<field name="centerStones" />
    		<field name="accentStoneOnes" />
    		<field name="accentStoneTwos" />
    	</fields>
    	<serverObject lookupStyle="new" className="com.gemvara.siteadmin.server.pricing.ProductGroupDMI" />
    </DataSource>
    Code:
        public ProductGroupValue add(ProductGroupValue productGroupValue) throws DALException
        {
            productGroupValue = RemoteObjectFacade.getInstance().getSKUPriceAdminManagerRemote().createProductGroupValue(productGroupValue);
            return productGroupValue;
        }
    Stacktrace:

    Code:
    08:22:24,587 ERROR [STDERR] java.lang.ClassCastException: java.lang.String cannot be cast to java.util.Collection
    08:22:24,587 ERROR [STDERR] 	at com.isomorphic.base.Reflection.adaptValue(Reflection.java:1111)
    08:22:24,587 ERROR [STDERR] 	at com.isomorphic.util.DataTools.coerceProperty(DataTools.java:2546)
    08:22:24,587 ERROR [STDERR] 	at com.isomorphic.util.DataTools.setProperties(DataTools.java:2395)
    08:22:24,587 ERROR [STDERR] 	at com.isomorphic.datasource.DataSource.setProperties(DataSource.java:918)
    08:22:24,587 ERROR [STDERR] 	at com.isomorphic.base.Reflection.adaptValue(Reflection.java:1363)
    08:22:24,587 ERROR [STDERR] 	at com.isomorphic.base.Reflection.adaptArgsAndInvoke(Reflection.java:828)
    08:22:24,587 ERROR [STDERR] 	at com.isomorphic.datasource.DataSourceDMI.execute(DataSourceDMI.java:553)
    08:22:24,587 ERROR [STDERR] 	at com.isomorphic.datasource.DataSourceDMI.execute(DataSourceDMI.java:63)
    08:22:24,587 ERROR [STDERR] 	at com.isomorphic.datasource.DSRequest.execute(DSRequest.java:1379)
    08:22:24,588 ERROR [STDERR] 	at com.isomorphic.servlet.IDACall.handleDSRequest(IDACall.java:155)
    08:22:24,588 ERROR [STDERR] 	at com.isomorphic.servlet.IDACall.processRequest(IDACall.java:106)
    08:22:24,588 ERROR [STDERR] 	at com.isomorphic.servlet.IDACall.doPost(IDACall.java:54)
    08:22:24,588 ERROR [STDERR] 	at javax.servlet.http.HttpServlet.service(HttpServlet.java:637)
    08:22:24,588 ERROR [STDERR] 	at com.isomorphic.servlet.BaseServlet.service(BaseServlet.java:152)
    08:22:24,588 ERROR [STDERR] 	at javax.servlet.http.HttpServlet.service(HttpServlet.java:717)
    08:22:24,588 ERROR [STDERR] 	at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:290)
    08:22:24,588 ERROR [STDERR] 	at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:206)
    08:22:24,588 ERROR [STDERR] 	at com.isomorphic.servlet.CompressionFilter.doFilter(CompressionFilter.java:259)
    08:22:24,588 ERROR [STDERR] 	at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:235)
    08:22:24,588 ERROR [STDERR] 	at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:206)
    08:22:24,588 ERROR [STDERR] 	at org.jboss.web.tomcat.filters.ReplyHeaderFilter.doFilter(ReplyHeaderFilter.java:96)
    08:22:24,588 ERROR [STDERR] 	at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:235)
    08:22:24,588 ERROR [STDERR] 	at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:206)
    08:22:24,588 ERROR [STDERR] 	at org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:235)
    08:22:24,588 ERROR [STDERR] 	at org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:191)
    08:22:24,588 ERROR [STDERR] 	at org.jboss.web.tomcat.security.SecurityAssociationValve.invoke(SecurityAssociationValve.java:190)
    08:22:24,588 ERROR [STDERR] 	at org.apache.catalina.authenticator.AuthenticatorBase.invoke(AuthenticatorBase.java:525)
    08:22:24,588 ERROR [STDERR] 	at org.jboss.web.tomcat.security.JaccContextValve.invoke(JaccContextValve.java:92)
    08:22:24,589 ERROR [STDERR] 	at org.jboss.web.tomcat.security.SecurityContextEstablishmentValve.process(SecurityContextEstablishmentValve.java:126)
    08:22:24,589 ERROR [STDERR] 	at org.jboss.web.tomcat.security.SecurityContextEstablishmentValve.invoke(SecurityContextEstablishmentValve.java:70)
    08:22:24,589 ERROR [STDERR] 	at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:127)
    08:22:24,589 ERROR [STDERR] 	at org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:102)
    08:22:24,589 ERROR [STDERR] 	at org.jboss.web.tomcat.service.jca.CachedConnectionValve.invoke(CachedConnectionValve.java:158)
    08:22:24,589 ERROR [STDERR] 	at org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:109)
    08:22:24,589 ERROR [STDERR] 	at org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:330)
    08:22:24,589 ERROR [STDERR] 	at org.apache.coyote.http11.Http11Processor.process(Http11Processor.java:829)
    08:22:24,589 ERROR [STDERR] 	at org.apache.coyote.http11.Http11Protocol$Http11ConnectionHandler.process(Http11Protocol.java:598)
    08:22:24,589 ERROR [STDERR] 	at org.apache.tomcat.util.net.JIoEndpoint$Worker.run(JIoEndpoint.java:447)
    08:22:24,589 ERROR [STDERR] 	at java.lang.Thread.run(Thread.java:619)

    #2
    Here is the value object definition (excluding accessors and class wrapper).

    Code:
        private Integer productGroupId;
        private Date dateUpdated;
        private Date dateInserted;
        private String name;
        private List<String> designTemplateNames;
        private List<String> shankMetalOnes;
        private List<String> shankMetalTwos;
        private List<String> centerSettingMetals;
        private List<String> sideSettingMetals;
        private List<String> centerStones;
        private List<String> accentStoneOnes;
        private List<String> accentStoneTwos;
        private Boolean status;

    Comment


      #3
      Two ways to handle this:

      1. in your DMI method, declare a DSRequest as the sole argument, removing ProductGroupValue. You can use dsRequest.getValues() to obtain the Map of inbound values, check the value for each of your List<String> fields and change it to a Collection of Strings if it's singular, then apply it to an new instance of ProductGroupValue via DataSource.setProperties().

      2. change the client-side code to ensure that a Collection of Strings is always passed

      Comment


        #4
        Note we've actually gone ahead and added support such that if the dsRequest contains a value for a field of type X and the target setter method takes takes Collection<X>, a Collection will automatically be created. So if you download the next nightly (smartclient.com/builds) you could try this out.

        Comment


          #5
          Great. Thanks! This will be very useful.

          Comment


            #6
            Is there anyway I could get a patch for 2.4? I don't mind updating the JAR if it is just a new class file.

            I am worried about the stability of a nightly build.

            Comment


              #7
              Sorry no, you'll need to use nightly builds at the least until you become a customer with Enterprise Support. Generally, nightly builds are stable, and lots of users run with them on an ongoing basis.

              Comment

              Working...
              X