Announcement

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

    HTTP ERROR: 405 after calling RESTful @delete

    Hey,

    I am developing with the build in Jetty. When I call delete transaction with the following rest service. I get 405 error. How can I activate those options in Jetty?

    Thanks
    Andy

    Restful Service:
    Code:
    // http://127.0.0.1:8888/rest/sql/deleteEmail/1
        @DELETE
        @Path("deleteEmail/{id}")
        @Produces(MediaType.APPLICATION_XML)
        public DEmail deleteEmail(@PathParam("id") long id) {
            DEmail email = read(id);
            if(null != email) {
                EntityManager em = factory.createEntityManager();
                em.remove(email);  
            }
            return email;
        }
    
    Error Message

    Code:
    HTTP ERROR: 405
    
    Method Not Allowed
    RequestURI=/rest/sql/deleteEmail/1
    
    Powered by Jetty://

    #2
    can somebody help? Is there no way to configure Jetty of SmartGWT?

    Thanks
    Andy

    Comment


      #3
      I ran into the same problem. The document indicates that I can change the http method to DELETE for remove operation to work. I tried this and get "error 405: http method DELETE is not supported by this URL". Please find more detailed information below. Thanks!

      1. the *complete* SmartGWT or SmartClient version from the lower left-hand corner of the Developer Console (see FAQ for how to open Developer Console), for example, \"v8.2p_2012-04-18/PowerEdition Deployment\"

      SmartClient Version: v9.0p_2014-01-09/EVAL Deployment (expires 2014.03.10_09.41.58) Licensed to: Isomorphic Software (#ISC_EVAL_NIGHTLY)

      2. browser(s) and version(s) involved

      Firefox 19.0.2

      3. for a server-side problem, the *complete* logs generated during processing of the failing request (do *not* trim to just the error message)

      === 2014-02-19 22:02:57,309 [l0-4] DEBUG IDACall - Header Name:Value pair: Accept:text/html,application/xhtml+xml,application/xml;q=0.9,*/*;q=0.8
      === 2014-02-19 22:02:57,309 [l0-4] DEBUG IDACall - Header Name:Value pair: Accept-Language:en-us,en;q=0.5
      === 2014-02-19 22:02:57,309 [l0-4] DEBUG IDACall - Header Name:Value pair: Accept-Encoding:gzip, deflate
      === 2014-02-19 22:02:57,309 [l0-4] DEBUG IDACall - Header Name:Value pair: Connection:keep-alive
      === 2014-02-19 22:02:57,309 [l0-4] DEBUG IDACall - Header Name:Value pair: Cookie:GLog=%7B%0D%20%20%20%20left%3A0%2C%20%0D%20%20%20%20top%3A146%2C%20%0D%20%20%20%20width%3A1910%2C%20%0D%20%20%20%20height%3A738%2C%20%0D%20%20%20%20priorityDefaults%3A%7B%0D%20%20%20%20%20%20%20%20Log%3A4%0D%20%20%20%20%7D%2C%20%0D%20%20%20%20defaultPriority%3A3%2C%20%0D%20%20%20%20trackRPC%3Atrue%0D%7D; isc_cState=ready; JSESSIONID=7gskhr6oi3l0
      === 2014-02-19 22:02:57,309 [l0-4] DEBUG IDACall - Header Name:Value pair: Referer:http://127.0.0.1:8888/showcase/sc/system/helpers/Log.html
      === 2014-02-19 22:02:57,309 [l0-4] DEBUG IDACall - Header Name:Value pair: Content-Type:application/x-www-form-urlencoded; charset=UTF-8
      === 2014-02-19 22:02:57,309 [l0-4] DEBUG IDACall - Header Name:Value pair: Content-Length:677
      === 2014-02-19 22:02:57,309 [l0-4] DEBUG IDACall - Header Name:Value pair: Pragma:no-cache
      === 2014-02-19 22:02:57,309 [l0-4] DEBUG IDACall - Header Name:Value pair: Cache-Control:no-cache
      === 2014-02-19 22:02:57,309 [l0-4] DEBUG IDACall - session exists: 7gskhr6oi3l0
      === 2014-02-19 22:02:57,309 [l0-4] DEBUG IDACall - remote user: null
      === 2014-02-19 22:02:57,318 [l0-4] DEBUG XML - Parsed XML from (in memory stream): 1ms
      === 2014-02-19 22:02:57,320 [l0-4] DEBUG XML - Parsed XML from /usr/local/mshen/smartgwtee-4.0p/samples/showcase/war/showcase/sc/system/schema/List.ds.xml: 1ms
      === 2014-02-19 22:02:57,321 [l0-4] DEBUG RPCManager - Processing 1 requests.
      === 2014-02-19 22:02:57,321 [l0-4] DEBUG RPCManager - Request #1 (RPCRequest) data: {
      appID:"isc_builtin",
      className:"builtin",
      methodName:"getAvailableScriptEngines",
      arguments:[
      ],
      is_ISC_RPC_DMI:true
      }
      === 2014-02-19 22:02:57,321 [l0-4] INFO IDACall - Performing 1 operation(s)
      === 2014-02-19 22:02:57,327 [l0-4] DEBUG XML - Parsed XML from jar:file:/usr/local/mshen/smartgwtee-4.0p/samples/showcase/war/WEB-INF/lib/isomorphic_core_rpc.jar!/isc_builtin.app.xml: 2ms
      === 2014-02-19 22:02:57,328 [l0-4] DEBUG XML - Parsed XML from /usr/local/mshen/smartgwtee-4.0p/samples/showcase/war/showcase/sc/system/schema/Application.ds.xml: 1ms
      === 2014-02-19 22:02:57,330 [l0-4] DEBUG XML - Parsed XML from /usr/local/mshen/smartgwtee-4.0p/samples/showcase/war/showcase/sc/system/schema/Method.ds.xml: 1ms
      === 2014-02-19 22:02:57,334 [l0-4] DEBUG RPCDMI - appConfig: isc.Application.create({
      rpcBindings:[
      {
      ID:"builtin",
      className:"com.isomorphic.rpc.BuiltinRPC",
      visibleMethods:[
      {
      name:"downloadWSDL"
      },
      {
      name:"downloadClientContent"
      },
      {
      name:"downloadClientExport"
      },
      {
      name:"xmlToJS"
      },
      {
      name:"uploadProgressCheck"
      },
      {
      name:"saveFile"
      },
      {
      name:"appendToFile"
      },
      {
      name:"loadFile"
      },
      {
      name:"deleteFile"
      },
      {
      name:"loadSharedXML"
      },
      {
      name:"saveSharedXML"
      },
      {
      name:"getAvailableScriptEngines"
      },
      {
      name:"devConsoleEvalServerScript"
      },
      {
      name:"evalJava"
      },
      {
      name:"getLogNames"
      },
      {
      name:"getLogEntries"
      },
      {
      name:"getLogThresholds"
      },
      {
      name:"setLogThreshold"
      },
      {
      name:"getPdfObject"
      },
      {
      name:"exportImage"
      },
      {
      name:"areServerTimingsTracked"
      },
      {
      name:"trackServerTimings"
      }
      ]
      },
      {
      ID:"builtin_tools",
      className:"com.isomorphic.tools.BuiltinRPC",
      visibleMethods:[
      {
      name:"getDataSourceFromTable"
      },
      {
      name:"getDataSourceJSONFromTable"
      },
      {
      name:"getDataSourceFromHibernateMapping"
      },
      {
      name:"getDataSourceJSONFromHibernateMapping"
      },
      {
      name:"getTables"
      },
      {
      name:"getFieldsFromTable"
      },
      {
      name:"getBeanFields"
      },
      {
      name:"getHibernateBeans"
      },
      {
      name:"getDatabaseProductNameAndVersion"
      },
      {
      name:"getDatabaseTableTypes"
      },
      {
      name:"setAttributes"
      },
      {
      name:"clearAttributes"
      },
      {
      name:"getAttributes"
      },
      {
      name:"getAttribute"
      },
      {
      name:"getDataSourceConfigFromJavaClass"
      },
      {
      args:"cName",
      language:"groovy",
      name:"getJavaSource",
      script:"\n if (!com.isomorphic.auth.DevModeAuthFilter.devModeAuthorized(request)) throw new Exception(\"Not Authorized\"); \n //import org.apache.bcel.Repository;\n\n try {\n return org.apache.bcel.Repository.lookupClass(cName).toString();\n } catch (Throwable e) {\n return \"Unable to reverse engineer class \"+cName+\": \"+e.getMessage();\n }\n "
      },
      {
      name:"loadDataSource"
      },
      {
      name:"dsFromXML"
      },
      {
      name:"dsConfigFromXML"
      },
      {
      name:"getDefinedDataSources"
      }
      ]
      },
      {
      ID:"builtin_adminconsole",
      className:"com.isomorphic.tools.AdminConsole",
      visibleMethods:[
      {
      name:"getDefinedDatabases"
      },
      {
      name:"testDB"
      },
      {
      name:"saveDBConfig"
      },
      {
      name:"setDefaultDB"
      },
      {
      name:"importDataSources"
      },
      {
      name:"discoverJNDIDatabases"
      }
      ]
      }
      ]
      })

      === 2014-02-19 22:02:57,357 [l0-4] DEBUG RPCDMI - rpc returned data
      === 2014-02-19 22:02:57,358 [l0-4] DEBUG RPCManager - Content type for RPC transaction: text/plain; charset=UTF-8
      === 2014-02-19 22:02:57,359 [l0-4] INFO Compression - /showcase/sc/IDACall: 96 -> 99 bytes
      === 2014-02-19 22:13:08,041 [l0-6] INFO RequestContext - URL: '/showcase/sc/IDACall', User-Agent: 'Mozilla/5.0 (X11; Linux x86_64; rv:10.0.12) Gecko/20130110 Firefox/10.0.12': Moz (Gecko) with Accept-Encoding header
      === 2014-02-19 22:13:08,058 [l0-6] INFO Compression - /showcase/sc/IDACall: 81 -> 86 bytes
      === 2014-02-19 22:13:08,210 [l0-6] INFO RequestContext - URL: '/showcase/sc/IDACall', User-Agent: 'Mozilla/5.0 (X11; Linux x86_64; rv:10.0.12) Gecko/20130110 Firefox/10.0.12': Moz (Gecko) with Accept-Encoding header
      === 2014-02-19 22:13:08,237 [l0-6] INFO Compression - /showcase/sc/IDACall: 118288 -> 7166 bytes
      === 2014-02-19 22:14:09,079 [l0-6] INFO RequestContext - URL: '/showcase/sc/IDACall', User-Agent: 'Mozilla/5.0 (X11; Linux x86_64; rv:10.0.12) Gecko/20130110 Firefox/10.0.12': Moz (Gecko) with Accept-Encoding header
      === 2014-02-19 22:14:09,102 [l0-6] INFO Compression - /showcase/sc/IDACall: 118345 -> 7185 bytes
      === 2014-02-19 22:14:29,627 [l0-6] INFO RequestContext - URL: '/showcase/sc/IDACall', User-Agent: 'Mozilla/5.0 (X11; Linux x86_64; rv:10.0.12) Gecko/20130110 Firefox/10.0.12': Moz (Gecko) with Accept-Encoding header
      === 2014-02-19 22:14:29,628 [l0-6] DEBUG IDACall - Header Name:Value pair: Host:127.0.0.1:8888
      === 2014-02-19 22:14:29,629 [l0-6] DEBUG IDACall - Header Name:Value pair: User-Agent:Mozilla/5.0 (X11; Linux x86_64; rv:10.0.12) Gecko/20130110 Firefox/10.0.12
      === 2014-02-19 22:14:29,629 [l0-6] DEBUG IDACall - Header Name:Value pair: Accept:text/html,application/xhtml+xml,application/xml;q=0.9,*/*;q=0.8
      === 2014-02-19 22:14:29,629 [l0-6] DEBUG IDACall - Header Name:Value pair: Accept-Language:en-us,en;q=0.5
      === 2014-02-19 22:14:29,629 [l0-6] DEBUG IDACall - Header Name:Value pair: Accept-Encoding:gzip, deflate
      === 2014-02-19 22:14:29,629 [l0-6] DEBUG IDACall - Header Name:Value pair: Connection:keep-alive
      === 2014-02-19 22:14:29,629 [l0-6] DEBUG IDACall - Header Name:Value pair: Content-Type:application/x-www-form-urlencoded; charset=UTF-8
      === 2014-02-19 22:14:29,629 [l0-6] DEBUG IDACall - Header Name:Value pair: Referer:http://127.0.0.1:8888/showcase/sc/system/helpers/Log.html
      === 2014-02-19 22:14:29,629 [l0-6] DEBUG IDACall - Header Name:Value pair: Content-Length:675
      === 2014-02-19 22:14:29,629 [l0-6] DEBUG IDACall - Header Name:Value pair: Cookie:GLog=%7B%0D%20%20%20%20left%3A0%2C%20%0D%20%20%20%20top%3A146%2C%20%0D%20%20%20%20width%3A1910%2C%20%0D%20%20%20%20height%3A703%2C%20%0D%20%20%20%20priorityDefaults%3A%7B%0D%20%20%20%20%20%20%20%20Log%3A4%0D%20%20%20%20%7D%2C%20%0D%20%20%20%20defaultPriority%3A3%2C%20%0D%20%20%20%20trackRPC%3Atrue%0D%7D; isc_cState=ready; JSESSIONID=7gskhr6oi3l0
      === 2014-02-19 22:14:29,629 [l0-6] DEBUG IDACall - Header Name:Value pair: Pragma:no-cache
      === 2014-02-19 22:14:29,629 [l0-6] DEBUG IDACall - Header Name:Value pair: Cache-Control:no-cache
      === 2014-02-19 22:14:29,629 [l0-6] DEBUG IDACall - session exists: 7gskhr6oi3l0
      === 2014-02-19 22:14:29,629 [l0-6] DEBUG IDACall - remote user: null
      === 2014-02-19 22:14:29,632 [l0-6] DEBUG XML - Parsed XML from (in memory stream): 2ms
      === 2014-02-19 22:14:29,633 [l0-6] DEBUG RPCManager - Processing 1 requests.
      === 2014-02-19 22:14:29,633 [l0-6] DEBUG RPCManager - Request #1 (RPCRequest) data: {
      appID:"isc_builtin",
      className:"builtin",
      methodName:"areServerTimingsTracked",
      arguments:[
      ],
      is_ISC_RPC_DMI:true
      }
      === 2014-02-19 22:14:29,633 [l0-6] INFO IDACall - Performing 1 operation(s)
      === 2014-02-19 22:14:29,634 [l0-6] DEBUG RPCDMI - appConfig: isc.Application.create({
      rpcBindings:[
      {
      ID:"builtin",
      className:"com.isomorphic.rpc.BuiltinRPC",
      visibleMethods:[
      {
      name:"downloadWSDL"
      },
      {
      name:"downloadClientContent"
      },
      {
      name:"downloadClientExport"
      },
      {
      name:"xmlToJS"
      },
      {
      name:"uploadProgressCheck"
      },
      {
      name:"saveFile"
      },
      {
      name:"appendToFile"
      },
      {
      name:"loadFile"
      },
      {
      name:"deleteFile"
      },
      {
      name:"loadSharedXML"
      },
      {
      name:"saveSharedXML"
      },
      {
      name:"getAvailableScriptEngines"
      },
      {
      name:"devConsoleEvalServerScript"
      },
      {
      name:"evalJava"
      },
      {
      name:"getLogNames"
      },
      {
      name:"getLogEntries"
      },
      {
      name:"getLogThresholds"
      },
      {
      name:"setLogThreshold"
      },
      {
      name:"getPdfObject"
      },
      {
      name:"exportImage"
      },
      {
      name:"areServerTimingsTracked"
      },
      {
      name:"trackServerTimings"
      }
      ]
      },
      {
      ID:"builtin_tools",
      className:"com.isomorphic.tools.BuiltinRPC",
      visibleMethods:[
      {
      name:"getDataSourceFromTable"
      },
      {
      name:"getDataSourceJSONFromTable"
      },
      {
      name:"getDataSourceFromHibernateMapping"
      },
      {
      name:"getDataSourceJSONFromHibernateMapping"
      },
      {
      name:"getTables"
      },
      {
      name:"getFieldsFromTable"
      },
      {
      name:"getBeanFields"
      },
      {
      name:"getHibernateBeans"
      },
      {
      name:"getDatabaseProductNameAndVersion"
      },
      {
      name:"getDatabaseTableTypes"
      },
      {
      name:"setAttributes"
      },
      {
      name:"clearAttributes"
      },
      {
      name:"getAttributes"
      },
      {
      name:"getAttribute"
      },
      {
      name:"getDataSourceConfigFromJavaClass"
      },
      {
      args:"cName",
      language:"groovy",
      name:"getJavaSource",
      script:"\n if (!com.isomorphic.auth.DevModeAuthFilter.devModeAuthorized(request)) throw new Exception(\"Not Authorized\"); \n //import org.apache.bcel.Repository;\n\n try {\n return org.apache.bcel.Repository.lookupClass(cName).toString();\n } catch (Throwable e) {\n return \"Unable to reverse engineer class \"+cName+\": \"+e.getMessage();\n }\n "
      },
      {
      name:"loadDataSource"
      },
      {
      name:"dsFromXML"
      },
      {
      name:"dsConfigFromXML"
      },
      {
      name:"getDefinedDataSources"
      }
      ]
      },
      {
      ID:"builtin_adminconsole",
      className:"com.isomorphic.tools.AdminConsole",
      visibleMethods:[
      {
      name:"getDefinedDatabases"
      },
      {
      name:"testDB"
      },
      {
      name:"saveDBConfig"
      },
      {
      name:"setDefaultDB"
      },
      {
      name:"importDataSources"
      },
      {
      name:"discoverJNDIDatabases"
      }
      ]
      }
      ]
      })

      === 2014-02-19 22:14:29,634 [l0-6] DEBUG RPCDMI - rpc returned RPCResponse
      === 2014-02-19 22:14:29,634 [l0-6] DEBUG RPCManager - Content type for RPC transaction: text/plain; charset=UTF-8
      === 2014-02-19 22:14:29,635 [l0-6] INFO Compression - /showcase/sc/IDACall: 68 -> 74 bytes
      === 2014-02-19 22:16:09,946 [l0-6] INFO RequestContext - URL: '/showcase/sc/IDACall', User-Agent: 'Mozilla/5.0 (X11; Linux x86_64; rv:10.0.12) Gecko/20130110 Firefox/10.0.12': Moz (Gecko) with Accept-Encoding header
      === 2014-02-19 22:16:09,954 [l0-6] INFO Compression - /showcase/sc/IDACall: 81 -> 86 bytes
      === 2014-02-19 22:16:10,054 [l0-6] INFO RequestContext - URL: '/showcase/sc/IDACall', User-Agent: 'Mozilla/5.0 (X11; Linux x86_64; rv:10.0.12) Gecko/20130110 Firefox/10.0.12': Moz (Gecko) with Accept-Encoding header
      === 2014-02-19 22:16:10,069 [l0-6] INFO Compression - /showcase/sc/IDACall: 123231 -> 7176 bytes
      === 2014-02-19 22:17:14,762 [l0-6] INFO RequestContext - URL: '/showcase/sc/IDACall', User-Agent: 'Mozilla/5.0 (X11; Linux x86_64; rv:10.0.12) Gecko/20130110 Firefox/10.0.12': Moz (Gecko) with Accept-Encoding header

      4. for any problem processing a server response, the actual response as shown in the RPC tab in the Developer Console

      Response:
      <html>
      <head>
      <meta http-equiv="Content-Type" content="text/html; charset=ISO-8859-1"/>
      <title>Error 405 Http method DELETE is not supported by this URL</title>
      </head>
      <body><h2>HTTP ERROR: 405</h2><pre>Http method DELETE is not supported by this URL</pre>
      <p>RequestURI=/data/sampleRemoveData.js</p><p><i><small><a href="http://jetty.mortbay.org/">Powered by Jetty://</a></small></i></p><br/>
      <br/>
      <br/>
      <br/>
      <br/>
      <br/>
      <br/>
      <br/>
      <br/>
      <br/>
      <br/>
      <br/>
      <br/>
      <br/>
      <br/>
      <br/>
      <br/>
      <br/>
      <br/>
      <br/>

      </body>
      </html>

      RPCRequest:
      {
      "actionURL":"data/sampleRemoveData.js",
      "showPrompt":true,
      "transport":"xmlHttpRequest",
      "useSimpleHttp":true,
      "promptStyle":"cursor",
      "params":{
      "col1":"row1",
      "col2":"value1",
      "_selection_4":true,
      "_operationType":"remove",
      "_componentId":"isc_ListGrid_0",
      "_dataSource":"isc_MyRestSample_3_0",
      "isc_metaDataPrefix":"_",
      "isc_dataFormat":"json"
      },
      "httpMethod":"DELETE",
      "bypassCache":true,
      "data":null
      }

      DSRequest:
      {
      dataSource:"isc_MyRestSample_3_0",
      operationType:"remove",
      componentId:"isc_ListGrid_0",
      data:{
      col1:"row1",
      col2:"value1",
      isc_metaDataPrefix:"_",
      isc_dataFormat:"json"
      },
      callback:{
      target:[ListGrid ID:isc_ListGrid_0],
      methodName:"removeDataComplete"
      },
      showPrompt:true,
      requestId:"isc_MyRestSample_3_0$6271",
      clientContext:{
      removeDataCallback:{
      },
      editInfo:{
      rowNum:0,
      values:Obj,
      editCompletionEvent:"programmatic"
      }
      },
      fallbackToEval:false,
      lastClientEventThreadCode:"MUP8",
      bypassCache:true,
      httpMethod:"DELETE",
      isRestRequest:true,
      dataFormat:"json"
      }

      5. if there is a JavaScript error, the stack trace logged in the Developer Console (see FAQ)
      14:01:43.314:INFO:Log:initialized
      14:01:43.369:WARN:Log:NOTE: Firebug is enabled. Firebug greatly slows the performance of applications that make heavy use of JavaScript. Isomorphic highly recommends Firebug for troubleshooting, but Firebug and other development tools should be disabled when assessing the real-world performance of SmartClient applications.
      14:01:54.208:WARN:Label:isc_Label_1:ignoring bad or negative height: auto [enable 'sizing' log for stack trace]
      14:02:00.716:INFO:Log:isc.Page is loaded
      14:03:04.692:XRP7:WARN:RPCManager:Server returned TRANSPORT_ERROR with no error message performing operation 'isc_MyRestSample_3_0_remove'. - response: {operationId: "isc_MyRestSample_3_0_remove",
      clientContext: Obj,
      context: Obj,
      transactionNum: 1,
      httpResponseCode: 405,
      httpResponseText: "<html>\n<head>\n<meta http-equiv="Content-..."[1486],
      xmlHttpRequest: [object XMLHttpRequest],
      transport: "xmlHttpRequest",
      status: -90,
      clientOnly: undef,
      httpHeaders: Obj,
      isStructured: true,
      callbackArgs: null,
      results: Obj,
      data: Obj}


      6. sample code if applicable

      package com.smartgwt.sample.showcase.client.webservice;

      import com.smartgwt.client.data.DSRequest;
      import com.smartgwt.client.data.DSResponse;
      import com.smartgwt.client.data.OperationBinding;
      import com.smartgwt.client.data.RestDataSource;
      import com.smartgwt.client.data.fields.DataSourceTextField;
      import com.smartgwt.client.types.DSDataFormat;
      import com.smartgwt.client.types.DSProtocol;
      import com.smartgwt.client.types.SelectionAppearance;
      import com.smartgwt.client.types.SelectionStyle;
      import com.smartgwt.client.widgets.Canvas;
      import com.smartgwt.client.widgets.IButton;
      import com.smartgwt.client.widgets.events.ClickEvent;
      import com.smartgwt.client.widgets.events.ClickHandler;
      import com.smartgwt.client.widgets.grid.ListGrid;
      import com.smartgwt.client.widgets.grid.ListGridRecord;
      import com.smartgwt.client.widgets.layout.HLayout;
      import com.smartgwt.client.widgets.layout.VLayout;
      import com.smartgwt.sample.showcase.client.PanelFactory;
      import com.smartgwt.sample.showcase.client.ShowcasePanel;

      public class MyRestSample extends ShowcasePanel {

      private static final String DESCRIPTION = "<p>Smart GWT Server includes an HTTP proxy servlet which "
      + "supports contacting REST and WSDL web services as though they were hosted by a local web server, avoiding"
      + " the \"same origin policy\" restriction which normally prevents web applications from accessing remote services.</p>"
      + "<p>The proxy is used automatically whenever an attempt is made to contact a URL on another host - no special code "
      + "is needed. In this example, a RestDataSource is configured to get/post data, "
      + "with no server-side code or proxy configuration required.</p>"
      + "<p>Configuration files allow for restricting proxying to specific services that users are allowed to contact through your application.</p>";

      public static class Factory implements PanelFactory {

      private String id;

      @Override
      public ShowcasePanel create() {
      MyRestSample panel = new MyRestSample();
      id = panel.getID();
      return panel;
      }

      @Override
      public String getID() {
      return id;
      }

      @Override
      public String getDescription() {
      return DESCRIPTION;
      }
      }

      private ListGrid grid;

      @Override
      public Canvas getViewPanel() {
      VLayout layout = new VLayout(15);
      layout.setAutoHeight();

      grid = createListGrid();

      HLayout hLayout = new HLayout(15);

      final IButton removeButton = new IButton("Remove");
      removeButton.setWidth(150);
      removeButton.addClickHandler(new ClickHandler() {
      @Override
      public void onClick(ClickEvent event) {
      ListGridRecord record = new ListGridRecord();
      grid.removeData(grid.getSelectedRecord());
      }
      });
      hLayout.addMember(removeButton);

      layout.setMembers(grid, hLayout);
      return layout;
      }

      @Override
      public String getIntro() {
      return DESCRIPTION;
      }

      private ListGrid createListGrid() {
      ListGrid grid = new ListGrid();
      grid.setHeight(100);
      grid.setDataSource(createRestDataSource());
      grid.setAutoFetchData(true);

      grid.setSelectionType(SelectionStyle.SINGLE);
      grid.setSelectionAppearance(SelectionAppearance.CHECKBOX);
      return grid;
      }

      private RestDataSource createRestDataSource() {
      RestDataSource ds = new RestDataSource() {

      @Override
      protected Object transformRequest(DSRequest dsRequest) {
      switch (dsRequest.getOperationType()) {
      case REMOVE:
      dsRequest.setHttpMethod("DELETE");
      default:
      }
      return super.transformRequest(dsRequest);
      }

      @Override
      protected void transformResponse(DSResponse response,
      DSRequest request, Object data) {
      super.transformResponse(response, request, data);
      }
      };

      ds.setDataFormat(DSDataFormat.JSON);

      DataSourceTextField col1Field = new DataSourceTextField("col1",
      "Column 1");
      col1Field.setPrimaryKey(true);
      col1Field.setCanEdit(false);

      DataSourceTextField col2Field = new DataSourceTextField("col2",
      "Column 2");
      ds.setFields(col1Field, col2Field);

      ds.setFetchDataURL("data/sampleData.js");
      ds.setRemoveDataURL("data/sampleRemoveData.js");

      return ds;
      }

      public ListGridRecord createRecord(String val1, String val2) {
      ListGridRecord record = new ListGridRecord();
      record.setAttribute("col1", val1);
      record.setAttribute("col2", val2);
      return record;
      }

      }

      Comment


        #4
        This request is being rejected by Jetty before it reaches any SmartGWT code, so this is properly a question for the Jetty forum, not here.

        Comment


          #5
          Got it. Thanks!

          Comment

          Working...
          X