Announcement

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

    DSRequest("some_datasource", "add") at server side

    Hi,

    while evaluating, got stuck with a very simple case at the first glance: being unable to perform some extra "add" operation at DMI level.

    Code:
      public DSResponse update(DSRequest request) throws Exception {
        ...
        DSRequest addRequest = new DSRequest("role", "add");
        addRequest.setFieldValue("role", "role_1");
        addRequest.execute();
        ...
      }
    and here's the "role" datasource:

    Code:
    <DataSource ID="role" serverType="sql" tableName="role" testFileName="role.data.xml">
    	<fields>
    		<field name="role" type="text" />
    	</fields>
    </DataSource>
    So, an attempt to execute some extra "add" request (which is a simplified clone of the Quick Start Guide sample) leads to the following exception:
    Code:
    ...
    === 2011-02-07 00:18:44,467 [0-30] INFO  SQLDataSource - [builtinApplication.null] Performing add operation with
    	criteria: {}	values: 0 valueSets
    === 2011-02-07 00:18:44,467 [0-30] WARN  SQLDataSource - [builtinApplication.null] Insert, update or replace operation requires non-empty values; check submitted values parameter
    === 2011-02-07 00:18:44,468 [0-30] DEBUG DataSourceDMI - Invocation threw exception
    java.lang.Exception: Insert, update or replace operation requires non-empty values; check submitted values parameter
    	at com.isomorphic.sql.SQLDataSource.SQLExecute(SQLDataSource.java:1205)
    	at com.isomorphic.sql.SQLDataSource.processRequest(SQLDataSource.java:280)
    	at com.isomorphic.sql.SQLDataSource.executeAdd(SQLDataSource.java:232)
    	at com.isomorphic.datasource.DataSource.execute(DataSource.java:1050)
    	at com.isomorphic.application.AppBase.executeDefaultDSOperation(AppBase.java:721)
    	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:1457)
    	at open_automation.portal.server.EmployeesDMIHandler.update(EmployeesDMIHandler.java:56)
    	at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
    	at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
    	at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
    	at java.lang.reflect.Method.invoke(Method.java:597)
    	at com.isomorphic.base.Reflection.adaptArgsAndInvoke(Reflection.java:908)
    	at com.isomorphic.datasource.DataSourceDMI.execute(DataSourceDMI.java:588)
    	at com.isomorphic.datasource.DataSourceDMI.execute(DataSourceDMI.java:64)
    	at com.isomorphic.datasource.DSRequest.execute(DSRequest.java:1454)
    	at com.isomorphic.servlet.IDACall.handleDSRequest(IDACall.java:173)
    	at com.isomorphic.servlet.IDACall.processRPCTransaction(IDACall.java:130)
    	at com.isomorphic.servlet.IDACall.processRequest(IDACall.java:95)
    	at com.isomorphic.servlet.IDACall.doPost(IDACall.java:54)
    	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.mortbay.jetty.servlet.ServletHolder.handle(ServletHolder.java:487)
    	at org.mortbay.jetty.servlet.ServletHandler$CachedChain.doFilter(ServletHandler.java:1097)
    	at com.isomorphic.servlet.CompressionFilter.doFilter(CompressionFilter.java:259)
    	at org.mortbay.jetty.servlet.ServletHandler$CachedChain.doFilter(ServletHandler.java:1088)
    	at org.mortbay.jetty.servlet.ServletHandler.handle(ServletHandler.java:360)
    	at org.mortbay.jetty.security.SecurityHandler.handle(SecurityHandler.java:216)
    	at org.mortbay.jetty.servlet.SessionHandler.handle(SessionHandler.java:181)
    	at org.mortbay.jetty.handler.ContextHandler.handle(ContextHandler.java:729)
    	at org.mortbay.jetty.webapp.WebAppContext.handle(WebAppContext.java:405)
    	at org.mortbay.jetty.handler.HandlerWrapper.handle(HandlerWrapper.java:152)
    	at org.mortbay.jetty.handler.RequestLogHandler.handle(RequestLogHandler.java:49)
    	at org.mortbay.jetty.handler.HandlerWrapper.handle(HandlerWrapper.java:152)
    	at org.mortbay.jetty.Server.handle(Server.java:324)
    	at org.mortbay.jetty.HttpConnection.handleRequest(HttpConnection.java:505)
    	at org.mortbay.jetty.HttpConnection$RequestHandler.content(HttpConnection.java:843)
    	at org.mortbay.jetty.HttpParser.parseNext(HttpParser.java:647)
    	at org.mortbay.jetty.HttpParser.parseAvailable(HttpParser.java:211)
    	at org.mortbay.jetty.HttpConnection.handle(HttpConnection.java:380)
    	at org.mortbay.io.nio.SelectChannelEndPoint.run(SelectChannelEndPoint.java:395)
    	at org.mortbay.thread.QueuedThreadPool$PoolThread.run(QueuedThreadPool.java:488)
    === 2011-02-07 00:18:44,469 [0-30] WARN  RequestContext - dsRequest.execute() failed: 
    java.lang.Exception: Insert, update or replace operation requires non-empty values; check submitted values parameter
    	at com.isomorphic.sql.SQLDataSource.SQLExecute(SQLDataSource.java:1205)
    	at com.isomorphic.sql.SQLDataSource.processRequest(SQLDataSource.java:280)
    	at com.isomorphic.sql.SQLDataSource.executeAdd(SQLDataSource.java:232)
    	at com.isomorphic.datasource.DataSource.execute(DataSource.java:1050)
    	at com.isomorphic.application.AppBase.executeDefaultDSOperation(AppBase.java:721)
    	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:1457)
    	at open_automation.portal.server.EmployeesDMIHandler.update(EmployeesDMIHandler.java:56)
    	at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
    	at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
    	at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
    	at java.lang.reflect.Method.invoke(Method.java:597)
    	at com.isomorphic.base.Reflection.adaptArgsAndInvoke(Reflection.java:908)
    	at com.isomorphic.datasource.DataSourceDMI.execute(DataSourceDMI.java:588)
    	at com.isomorphic.datasource.DataSourceDMI.execute(DataSourceDMI.java:64)
    	at com.isomorphic.datasource.DSRequest.execute(DSRequest.java:1454)
    	at com.isomorphic.servlet.IDACall.handleDSRequest(IDACall.java:173)
    	at com.isomorphic.servlet.IDACall.processRPCTransaction(IDACall.java:130)
    	at com.isomorphic.servlet.IDACall.processRequest(IDACall.java:95)
    	at com.isomorphic.servlet.IDACall.doPost(IDACall.java:54)
    	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.mortbay.jetty.servlet.ServletHolder.handle(ServletHolder.java:487)
    	at org.mortbay.jetty.servlet.ServletHandler$CachedChain.doFilter(ServletHandler.java:1097)
    	at com.isomorphic.servlet.CompressionFilter.doFilter(CompressionFilter.java:259)
    	at org.mortbay.jetty.servlet.ServletHandler$CachedChain.doFilter(ServletHandler.java:1088)
    	at org.mortbay.jetty.servlet.ServletHandler.handle(ServletHandler.java:360)
    	at org.mortbay.jetty.security.SecurityHandler.handle(SecurityHandler.java:216)
    	at org.mortbay.jetty.servlet.SessionHandler.handle(SessionHandler.java:181)
    	at org.mortbay.jetty.handler.ContextHandler.handle(ContextHandler.java:729)
    	at org.mortbay.jetty.webapp.WebAppContext.handle(WebAppContext.java:405)
    	at org.mortbay.jetty.handler.HandlerWrapper.handle(HandlerWrapper.java:152)
    	at org.mortbay.jetty.handler.RequestLogHandler.handle(RequestLogHandler.java:49)
    	at org.mortbay.jetty.handler.HandlerWrapper.handle(HandlerWrapper.java:152)
    	at org.mortbay.jetty.Server.handle(Server.java:324)
    	at org.mortbay.jetty.HttpConnection.handleRequest(HttpConnection.java:505)
    	at org.mortbay.jetty.HttpConnection$RequestHandler.content(HttpConnection.java:843)
    	at org.mortbay.jetty.HttpParser.parseNext(HttpParser.java:647)
    	at org.mortbay.jetty.HttpParser.parseAvailable(HttpParser.java:211)
    	at org.mortbay.jetty.HttpConnection.handle(HttpConnection.java:380)
    	at org.mortbay.io.nio.SelectChannelEndPoint.run(SelectChannelEndPoint.java:395)
    	at org.mortbay.thread.QueuedThreadPool$PoolThread.run(QueuedThreadPool.java:488)
    ...
    as if there are some "empty" values.

    I tried it with SmartGWT EE evaluation of 2011-01-25 and 2011-02-06 nightly builds and HSQLDB 1.8 server version and got same results.

    Extra "remove" operation works nicely at the same place.

    Thanks!

    #2
    Hmm, although setFieldValue is documented as never creating values, it makes sense for an "add" operation, so we'll probably enhance it.

    You can still make a one-liner out of this like so:

    Code:
    addRequest.setValues(new HashMap() {{ put("role", "role_1"); }});

    Comment


      #3
      It works like a charm with "setValues".

      Thanks!

      But... I guess it wasn't my imagination concerning the "setFieldValue" :-).

      Here's a little "pic.png" attachment as a snapshot from "Smart GWT Quick Start Guide", page 48.

      Cheers,
      Vas Bork.
      Attached Files

      Comment


        #4
        You're quite right. That elevates this to a bug given that the reference doc clashes with the QuickStart. Thanks.

        Comment


          #5
          This has been fixed in nightlies.

          Comment


            #6
            Great!

            Very efficiently.

            Comment


              #7
              Hi,

              I noticed that it works great on Add but it's not usable for update-operations.

              Comment


                #8
                This API works for all operationTypes. If you disagree, show a minimal standalone test case demonstrating a problem.

                Comment

                Working...
                X