AnsweredAssumed Answered

Dashlets custom Datalists item

Question asked by cchumi on Apr 11, 2011
Latest reply on Apr 11, 2011 by cchumi
Hi all,
I'm a new developper on alfresco and new on this forum.

I know there is already a topic who speak about that but i tried my own experience.
So i take datagrid.js and copy a part of code into my js.
But the setupdatasource answer me an error 500 :


  _setupDataSources: function DemInter__setupDataSources()
      {

         var listNodeRef = new Alfresco.util.NodeRef('workspace:\/\/SpacesStore\/4c5b7844-78f6-48f0-b753-e73709dd7317');

         for (var i = 0, ii = this.datalistColumns.length; i < ii; i++)
         {
            var column = this.datalistColumns[i],
               columnName = column.name.replace(":", "_"),
               fieldLookup = (column.type == "property" ? "prop" : "assoc") + "_" + columnName;
           
            this.dataRequestFields.push(columnName);
            this.dataResponseFields.push(fieldLookup);
            this.datalistColumns[fieldLookup] = column;
         }

         // DataSource definition
         this.widgets.dataSource = new YAHOO.util.DataSource(Alfresco.constants.PROXY_URI + 'slingshot/datalists/data/node/' + listNodeRef.uri,
         {

            connMethodPost: true,
         connXhrMode: "queueRequests",
            responseType: YAHOO.util.DataSource.TYPE_JSON,
            responseSchema:
            {
               resultsList: "items",
               metaFields:
               {
                  totalRecords: "totalRecords"
               }
            }
         });
      
         this.widgets.dataSource.connMgr.setDefaultPostHeader(Alfresco.util.Ajax.JSON);
         // Intercept data returned from data webscript to extract custom metadata
              this.widgets.dataSource.doBeforeCallback = function DemInter_doBeforeCallback(oRequest, oFullResponse, oParsedResponse)
         {
            // Container userAccess event
                  
            var permissions = oFullResponse.metadata.parent.permissions;
            if (permissions && permissions.userAccess)
            {
               Bubbling.fire("userAccess",
               {
                  userAccess: permissions.userAccess
               });
            }
         
            return oParsedResponse;
         };

      },
As you can see i specified a static NodeRef.
This is the good one i check it in the datalist components page.
But when i set it in my dashboard i got this error :


{
    "status" :
  {
    "code" : 500,
    "name" : "Internal Error",
    "description" : "An error inside the HTTP server which prevented it from fulfilling the request."
  }, 
 
  "message" : "03110011 Failed to convert request to JSON", 
  "exception" : "org.springframework.extensions.webscripts.WebScriptException - 03110011 Failed to convert request to JSON",
 
  "callstack" :
  [
       ""      ,"org.json.JSONException: A JSONObject text must begin with '{' at character 0"
      ,"org.json.JSONTokener.syntaxError(JSONTokener.java:413)"
      ,"org.json.JSONObject.<init>(JSONObject.java:180)"
      ,"org.json.JSONObject.<init>(JSONObject.java:420)"
      ,"org.springframework.extensions.webscripts.json.JSONReader.read(JSONReader.java:77)"
      ,"org.springframework.extensions.webscripts.json.JSONReader.createScriptParameters(JSONReader.java:93)"
      ,"org.springframework.extensions.webscripts.AbstractWebScript.createScriptParameters(AbstractWebScript.java:407)"
      ,"org.springframework.extensions.webscripts.DeclarativeWebScript.execute(DeclarativeWebScript.java:81)"
      ,"org.alfresco.repo.web.scripts.RepositoryContainer$2.execute(RepositoryContainer.java:377)"
      ,"org.alfresco.repo.transaction.RetryingTransactionHelper.doInTransaction(RetryingTransactionHelper.java:381)"
      ,"org.alfresco.repo.web.scripts.RepositoryContainer.transactionedExecute(RepositoryContainer.java:436)"
      ,"org.alfresco.repo.web.scripts.RepositoryContainer.transactionedExecuteAs(RepositoryContainer.java:466)"
      ,"org.alfresco.repo.web.scripts.RepositoryContainer.executeScript(RepositoryContainer.java:304)"
      ,"org.springframework.extensions.webscripts.AbstractRuntime.executeScript(AbstractRuntime.java:333)"
      ,"org.springframework.extensions.webscripts.AbstractRuntime.executeScript(AbstractRuntime.java:189)"
      ,"org.springframework.extensions.webscripts.servlet.WebScriptServlet.service(WebScriptServlet.java:118)"
      ,"javax.servlet.http.HttpServlet.service(HttpServlet.java:717)"
      ,"org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:290)"
      ,"org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:206)"
      ,"org.alfresco.web.app.servlet.GlobalLocalizationFilter.doFilter(GlobalLocalizationFilter.java:58)"
      ,"org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:235)"
      ,"org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:206)"
      ,"org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:233)"
      ,"org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:191)"
      ,"org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:127)"
      ,"org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:102)"
      ,"org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:109)"
      ,"org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:298)"
      ,"org.apache.coyote.http11.Http11Processor.process(Http11Processor.java:852)"
      ,"org.apache.coyote.http11.Http11Protocol$Http11ConnectionHandler.process(Http11Protocol.java:588)"
      ,"org.apache.tomcat.util.net.JIoEndpoint$Worker.run(JIoEndpoint.java:489)"
      ,"java.lang.Thread.run(Thread.java:619)"
      ,"org.springframework.extensions.webscripts.WebScriptException: 03110011 Failed to convert request to JSON"
      ,"org.springframework.extensions.webscripts.json.JSONReader.read(JSONReader.java:82)"

  ],
 
  "server" : "Community v3.4.0 (d 3370) schema 4 113",
  "time" : "11 avr. 2011 13:40:07"
}

So i take a look at the log on my server and the error is


13:40:07,385 ERROR [org.springframework.extensions.webscripts.AbstractRuntime] Exception from executeScript - redirecting to status template error: 03110011 Failed to convert request to JSON
org.springframework.extensions.webscripts.WebScriptException: 03110011 Failed to convert request to JSON
   at org.springframework.extensions.webscripts.json.JSONReader.read(JSONReader.java:82)
   at org.springframework.extensions.webscripts.json.JSONReader.createScriptParameters(JSONReader.java:93)
   at org.springframework.extensions.webscripts.AbstractWebScript.createScriptParameters(AbstractWebScript.java:407)
   at org.springframework.extensions.webscripts.DeclarativeWebScript.execute(DeclarativeWebScript.java:81)
   at org.alfresco.repo.web.scripts.RepositoryContainer$2.execute(RepositoryContainer.java:377)
   at org.alfresco.repo.transaction.RetryingTransactionHelper.doInTransaction(RetryingTransactionHelper.java:381)
   at org.alfresco.repo.web.scripts.RepositoryContainer.transactionedExecute(RepositoryContainer.java:436)
   at org.alfresco.repo.web.scripts.RepositoryContainer.transactionedExecuteAs(RepositoryContainer.java:466)
   at org.alfresco.repo.web.scripts.RepositoryContainer.executeScript(RepositoryContainer.java:304)
   at org.springframework.extensions.webscripts.AbstractRuntime.executeScript(AbstractRuntime.java:333)
   at org.springframework.extensions.webscripts.AbstractRuntime.executeScript(AbstractRuntime.java:189)
   at org.springframework.extensions.webscripts.servlet.WebScriptServlet.service(WebScriptServlet.java:118)
   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 org.alfresco.web.app.servlet.GlobalLocalizationFilter.doFilter(GlobalLocalizationFilter.java:58)
   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:233)
   at org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:191)
   at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:127)
   at org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:102)
   at org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:109)
   at org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:298)
   at org.apache.coyote.http11.Http11Processor.process(Http11Processor.java:852)
   at org.apache.coyote.http11.Http11Protocol$Http11ConnectionHandler.process(Http11Protocol.java:588)
   at org.apache.tomcat.util.net.JIoEndpoint$Worker.run(JIoEndpoint.java:489)
   at java.lang.Thread.run(Thread.java:619)
Caused by: org.json.JSONException: A JSONObject text must begin with '{' at character 0
   at org.json.JSONTokener.syntaxError(JSONTokener.java:413)
   at org.json.JSONObject.<init>(JSONObject.java:180)
   at org.json.JSONObject.<init>(JSONObject.java:420)
   at org.springframework.extensions.webscripts.json.JSONReader.read(JSONReader.java:77)
   … 27 more


I don't understand why the same code run perfectly in the datalist component but not in my dashlet.The only difference is that i set a static noderef. All my column are succesfully set and the datatable is correctly setup except the data item.

Could please explain me what i did wrong.

thanks

P.S : Sorry for my english i'm french so … ;)

Outcomes