I can't populate or display data from My Sql DB in a Custom Widget Table(JSON)

1
0
-1

Hi all

I am a newbie at Bonita 7.2, struggling with displaying values, retrieved from a My SQL DB, in a custom table Widget. I need a little help, please.

Fist thing I did was Show it in a normal table widget, and it works, but then I realized that I need a custom table because I have to show a detail of the row that a I selected in a pannel below the table. And this I think that can't be done with a conventional table.
My Doubt is If I have to use collection, or text parameter/properties to pass the list of values that I want to display in the custom table. The first step is to show something in the custom table Widget, and I can't do this.

Simple Template code of the custom widget:

  1. <table data-toggle="table" calss="table">
  2. <tbody>
  3. <tr>
  4. <th>Id</th>
  5. <th>Reporting Entity</th>
  6. <th>Reporting entity name</th>
  7. <th>Departament</th>
  8. <th>Job Profile</th>
  9. <th>Reporters code</th>
  10. <th>First Name</th>
  11. </tr>
  12. <tr ng-repeat="model in datosTabla">
  13. <!-- <td>
  14. <input type="radio" name="groupName" ng-model="model.selected" />
  15. </td> -->
  16. <td>{{ model.id }}</td>
  17. <td>{{ model.entidad_reportante }}</td>
  18. <td>{{ model.nombre_entidad_reportante }}</td>
  19. <td>{{ model.departamento }}</td>
  20. <td>{{ model.perfil_reportante }}</td>
  21. <td>{{ model.codigo_reportante }}</td>
  22. <td>{{ model.nombre }}</td>
  23. </tr>
  24. </tbody>
  25. </table>

Very simple Controller Code:

  1. function ($scope) {
  2.  
  3. $scope.datosTabla = $scope.properties.datosTablaLocal;
  4. }

The propertie: $scope.properties.datosTablaLocal; is a collection.

I also think that the problem could be in the Groovy script asociated with the data base conector, I have try two types of code to create the collection that I pass to the widget.
This is my actual Groovyscript code of the conector DB:

  1. List milista1 = new ArrayList();
  2. //* mcampo1 y mcampo2 son los nombres que yo utilice para este ejemplo, puede ser cualquier nombre y
  3. // cualquier cantidad de campos
  4.  
  5. def builder = new JsonBuilder();
  6.  
  7. while(resultset.next()){
  8.  
  9. // en va el numero de la columna o registro de nuestra consulta, que tiene el valor
  10. // que queremos poner en este campo de milista, igual con el 2
  11.  
  12. def lin1 = builder {
  13. id resultset.getObject(1).toString()
  14. entidad_reportante resultset.getObject(2).toString()
  15. nombre_entidad_reportante resultset.getObject(3).toString()
  16. departamento resultset.getObject(4).toString()
  17. perfil_reportante resultset.getObject(5).toString()
  18. codigo_reportante resultset.getObject(6).toString();
  19. nombre resultset.getObject(7).toString();
  20. }
  21. milista1.add(lin1);
  22. }
  23. loggerJava.info("Saliendo list reportes")
  24. return milista1;

Another groovy script that I have tryed

  1. final List<List<Object >> resultTable = new ArrayList<List<Object>>();
  2. int maxColumn = resultset.getMetaData().getColumnCount()+1
  3. while(resultset.next())
  4. {
  5. final List<Object> row = new ArrayList<Object>()
  6. for(int colIndex = 1; colIndex < maxColumn ; colIndex++)
  7. {
  8. row.add(resultset.getObject(colIndex))
  9. }
  10. resultTable.add(Collections.unmodifiableList(row));
  11. }
  12. loggerJava.info("Sale list reportes");
  13. return resultTable;

JSON representatinos that I'm displaying in the form in a text field:
JSON from the first groovy script:

  1. [
  2. {
  3. "id": "1",
  4. "entidad_reportante": "Spain Other Aircraft Ground Handling Organization",
  5. "nombre_entidad_reportante": "Atlantica",
  6. "departamento": "Operaciones Vuelo",
  7. "perfil_reportante": "Tripulante de Vuelo",
  8. "codigo_reportante": "Y15678909",
  9. "nombre": "Marta"
  10. },
  11. {
  12. "id": "2",
  13. "entidad_reportante": "Spain Other Aircraft Maintenance organization",
  14. "nombre_entidad_reportante": "Bintertechnic",
  15. "departamento": "Control Operacional",
  16. "perfil_reportante": "Officer",
  17. "codigo_reportante": "X34538909",
  18. "nombre": "Carlos"
  19. }
  20. ]

Json resulting from the second groovy script:

  1. [
  2. [
  3. 1,
  4. "Spain Other Aircraft Ground Handling Organization",
  5. "Atlantica",
  6. "Operaciones Vuelo",
  7. "Tripulante de Vuelo",
  8. "Y15678909",
  9. "Marta",
  10. "López Sánches",
  11. "mlopez@naysa.es",
  12. 1,
  13. 111,
  14. 1,
  15. "11",
  16. 1467846000000,
  17. "12:00",
  18. "2016-07-07 00:00:00",
  19. "Narrativa",
  20. "es",
  21. "adjuntos",
  22. "tipo reporte",
  23. 1467846000000,
  24. "C78715649",
  25. 1467846000000,
  26. "G45678098",
  27. 1467846000000,
  28. "Rapida",
  29. 1
  30. ],
  31. [
  32. 2,
  33. "Spain Other Aircraft Maintenance organization",
  34. "Bintertechnic",
  35. "Control Operacional",
  36. "Officer",
  37. "X34538909",
  38. "Carlos",
  39. "Cardenas Bermudez",
  40. "ccardenas@naysa.es",
  41. 1,
  42. 111,
  43. 1,
  44. "11",
  45. 1467846000000,
  46. "12:00",
  47. "2016-07-07 00:00:00",
  48. "Narrativa",
  49. "es",
  50. "adjuntos",
  51. "tipo reporte",
  52. 1467846000000,
  53. "C78715649",
  54. 1467846000000,
  55. "G45678098",
  56. 1467846000000,
  57. "Rapida",
  58. 1
  59. ]
  60. ]

One of the errors that I get, is a problem with JSON:

  1. SyntaxError: Unexpected end of JSON input
  2. at Object.parse (native)
  3. at tc (http://localhost:8080/bonita/portal/resource/taskInstance/RegistroSimpleNotificacion/5.4/RevisarCamposNotificacion/content/js/vendor.min.js:14:245)
  4. at bc (http://localhost:8080/bonita/portal/resource/taskInstance/RegistroSimpleNotificacion/5.4/RevisarCamposNotificacion/content/js/vendor.min.js:77:7)
  5. at http://localhost:8080/bonita/portal/resource/taskInstance/RegistroSimpleNotificacion/5.4/RevisarCamposNotificacion/content/js/vendor.min.js:77:369
  6. at q (http://localhost:8080/bonita/portal/resource/taskInstance/RegistroSimpleNotificacion/5.4/RevisarCamposNotificacion/content/js/vendor.min.js:7:322)
  7. at dd (http://localhost:8080/bonita/portal/resource/taskInstance/RegistroSimpleNotificacion/5.4/RevisarCamposNotificacion/content/js/vendor.min.js:77:351)
  8. at c (http://localhost:8080/bonita/portal/resource/taskInstance/RegistroSimpleNotificacion/5.4/RevisarCamposNotificacion/content/js/vendor.min.js:78:495)
  9. at http://localhost:8080/bonita/portal/resource/taskInstance/RegistroSimpleNotificacion/5.4/RevisarCamposNotificacion/content/js/vendor.min.js:112:182
  10. at m.$eval (http://localhost:8080/bonita/portal/resource/taskInstance/RegistroSimpleNotificacion/5.4/RevisarCamposNotificacion/content/js/vendor.min.js:126:250)
  11. at m.$digest (http://localhost:8080/bonita/portal/resource/taskInstance/RegistroSimpleNotificacion/5.4/RevisarCamposNotificacion/content/js/vendor.min.js:123:365)

Another erro show in t browser log:

  1. vendor.min.js:102 the pbInput property named "value" need to be bound to a variable

This another error showed in the browser log:

  1. vendor.min.js:102 Error: [$parse:syntax] http://errors.angularjs.org/1.3.18/$parse/syntax?p0=panel&p1=is%20an%20unexpected%20token&p2=7&p3=panel%20panel-default&p4=panel-default
  2. at Error (native)
  3. at http://localhost:8080/bonita/portal/resource/taskInstance/RegistroSimpleNotificacion/5.4/RevisarCamposNotificacion/content/js/vendor.min.js:6:417
  4. at lb.throwError (http://localhost:8080/bonita/portal/resource/taskInstance/RegistroSimpleNotificacion/5.4/RevisarCamposNotificacion/content/js/vendor.min.js:192:113)
  5. at lb.parse (http://localhost:8080/bonita/portal/resource/taskInstance/RegistroSimpleNotificacion/5.4/RevisarCamposNotificacion/content/js/vendor.min.js:190:406)
  6. at http://localhost:8080/bonita/portal/resource/taskInstance/RegistroSimpleNotificacion/5.4/RevisarCamposNotificacion/content/js/vendor.min.js:110:366
  7. at new n (http://localhost:8080/bonita/portal/resource/taskInstance/RegistroSimpleNotificacion/5.4/RevisarCamposNotificacion/content/js/runtime.min.js:1:10017)
  8. at Object.create (http://localhost:8080/bonita/portal/resource/taskInstance/RegistroSimpleNotificacion/5.4/RevisarCamposNotificacion/content/js/runtime.min.js:1:8209)
  9. at http://localhost:8080/bonita/portal/resource/taskInstance/RegistroSimpleNotificacion/5.4/RevisarCamposNotificacion/content/js/runtime.min.js:1:12401
  10. at Array.forEach (native)
  11. at Object.create (http://localhost:8080/bonita/portal/resource/taskInstance/RegistroSimpleNotificacion/5.4/RevisarCamposNotificacion/content/js/runtime.min.js:1:12373) <div pb-property-values="59c870ab-b357-45f3-b176-25f60338efb0" class="ng-scope">

This is the error that you get in bonita log:

  1. GRAVE: An exception occured writing the response entity
  2. com.fasterxml.jackson.databind.JsonMappingException: [no message for java.lang.NullPointerException]
  3. at com.fasterxml.jackson.databind.ser.DefaultSerializerProvider.serializeValue(DefaultSerializerProvider.java:261)
  4. at com.fasterxml.jackson.databind.ObjectWriter._configAndWriteValue(ObjectWriter.java:802)
  5. at com.fasterxml.jackson.databind.ObjectWriter.writeValue(ObjectWriter.java:642)
  6. at org.restlet.ext.jackson.JacksonRepresentation.write(JacksonRepresentation.java:464)
  7. at org.restlet.engine.adapter.ServerCall.writeResponseBody(ServerCall.java:510)
  8. at org.restlet.engine.adapter.ServerCall.sendResponse(ServerCall.java:454)
  9. at org.restlet.ext.servlet.internal.ServletCall.sendResponse(ServletCall.java:421)
  10. at org.restlet.engine.adapter.ServerAdapter.commit(ServerAdapter.java:187)
  11. at org.restlet.engine.adapter.HttpServerHelper.handle(HttpServerHelper.java:144)
  12. at org.restlet.ext.servlet.ServerServlet.service(ServerServlet.java:1117)
  13. at javax.servlet.http.HttpServlet.service(HttpServlet.java:731)
  14. at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:303)
  15. at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:208)
  16. at org.apache.tomcat.websocket.server.WsFilter.doFilter(WsFilter.java:52)
  17. at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:241)
  18. at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:208)
  19. at org.tuckey.web.filters.urlrewrite.RuleChain.handleRewrite(RuleChain.java:176)
  20. at org.tuckey.web.filters.urlrewrite.RuleChain.doRules(RuleChain.java:145)
  21. at org.tuckey.web.filters.urlrewrite.UrlRewriter.processRequest(UrlRewriter.java:92)
  22. at org.tuckey.web.filters.urlrewrite.UrlRewriteFilter.doFilter(UrlRewriteFilter.java:394)
  23. at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:241)
  24. at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:208)
  25. at org.bonitasoft.console.common.server.login.filter.AbstractAuthorizationFilter.doFilter(AbstractAuthorizationFilter.java:60)
  26. at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:241)
  27. at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:208)
  28. at org.apache.catalina.core.ApplicationDispatcher.invoke(ApplicationDispatcher.java:747)
  29. at org.apache.catalina.core.ApplicationDispatcher.processRequest(ApplicationDispatcher.java:485)
  30. at org.apache.catalina.core.ApplicationDispatcher.doForward(ApplicationDispatcher.java:410)
  31. at org.apache.catalina.core.ApplicationDispatcher.forward(ApplicationDispatcher.java:337)
  32. at org.bonitasoft.console.common.server.page.PageServlet.service(PageServlet.java:77)
  33. at javax.servlet.http.HttpServlet.service(HttpServlet.java:731)
  34. at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:303)
  35. at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:208)
  36. at org.apache.tomcat.websocket.server.WsFilter.doFilter(WsFilter.java:52)
  37. at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:241)
  38. at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:208)
  39. at org.tuckey.web.filters.urlrewrite.RuleChain.handleRewrite(RuleChain.java:176)
  40. at org.tuckey.web.filters.urlrewrite.RuleChain.doRules(RuleChain.java:145)
  41. at org.tuckey.web.filters.urlrewrite.UrlRewriter.processRequest(UrlRewriter.java:92)
  42. at org.tuckey.web.filters.urlrewrite.UrlRewriteFilter.doFilter(UrlRewriteFilter.java:394)
  43. at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:241)
  44. at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:208)
  45. at org.bonitasoft.console.common.server.login.filter.AuthenticationFilter.isAuthorized(AuthenticationFilter.java:152)
  46. at org.bonitasoft.console.common.server.login.filter.AuthenticationFilter.doAuthenticationFiltering(AuthenticationFilter.java:134)
  47. at org.bonitasoft.console.common.server.login.filter.AuthenticationFilter.doFilter(AuthenticationFilter.java:119)
  48. at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:241)
  49. at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:208)
  50. at org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:220)
  51. at org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:122)
  52. at org.apache.catalina.authenticator.AuthenticatorBase.invoke(AuthenticatorBase.java:505)
  53. at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:169)
  54. at org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:103)
  55. at org.bonitasoft.console.security.SessionFixationValve.invoke(SessionFixationValve.java:77)
  56. at org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:116)
  57. at org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:423)
  58. at org.apache.coyote.http11.AbstractHttp11Processor.process(AbstractHttp11Processor.java:1079)
  59. at org.apache.coyote.AbstractProtocol$AbstractConnectionHandler.process(AbstractProtocol.java:625)
  60. at org.apache.tomcat.util.net.JIoEndpoint$SocketProcessor.run(JIoEndpoint.java:318)
  61. at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1145)
  62. at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:615)
  63. at org.apache.tomcat.util.threads.TaskThread$WrappingRunnable.run(TaskThread.java:61)
  64. at java.lang.Thread.run(Thread.java:745)
  65. Caused by: java.lang.NullPointerException
  66. at org.bonitasoft.web.rest.server.utils.JacksonSerializerHelper.writeValueAndStringValue(JacksonSerializerHelper.java:48)
  67. at org.bonitasoft.web.rest.server.utils.DataInstanceSerializer.serialize(DataInstanceSerializer.java:43)
  68. at org.bonitasoft.web.rest.server.utils.DataInstanceSerializer.serialize(DataInstanceSerializer.java:27)
  69. at com.fasterxml.jackson.databind.ser.DefaultSerializerProvider.serializeValue(DefaultSerializerProvider.java:250)
  70. ... 61 more

Please, any assistance would be greatly appreciated, I've been stuck in this many days and I need to go ahead, some said that can't help me more because of copy rigth, but I only need some orientations.

Kind regards,
Héctor

1 answer

1
0
-1

I save my data in a java object collection, in my groovy script i setup in a josn form from a result of a query:

import groovy.json.JsonBuilder;

List milista1 = new ArrayList(); //mcampo1 y mcampo2 son los nombres que yo utilice para este ejemplo, puede ser cualquier nombre y // cualquier cantidad de campos

def builder = new JsonBuilder();

while(resultset.next()){

def lin1 = builder {
campo1 resultset.getObject(1).toString()
campo2 resultset.getObject(2).toString()
campo3 resultset.getObject(3).toString()
campo4 resultset.getObject(4).toString()
campo5 resultset.getObject(5).toString()
campo6 resultset.getObject(6).toString()
campo7 resultset.getObject(7).toString()
campo8 resultset.getObject(8).toString()
campo9 resultset.getObject(9).toString()
campo10 resultset.getObject(10).toString()
campo11 resultset.getObject(11).toString()
campo12 resultset.getObject(12).toString()
campo13 resultset.getObject(13).toString()
campo14 resultset.getObject(14).toString()

}

milista1.add(lin1);
}

return milista1;

Sorry for my bad inglish

Comments

Submitted by hectorta on Tue, 07/19/2016 - 17:25

Hi Julian, i understand you perfect, but I also speak spanish if you want. I have try the code that you gave me:

  1. try {
  2.  
  3. loggerJava.info("Entra list reportes custom");
  4.  
  5. List milista1 = new ArrayList();
  6. //* mcampo1 y mcampo2 son los nombres que yo utilice para este ejemplo, puede ser cualquier nombre y
  7. // cualquier cantidad de campos
  8.  
  9. def builder = new JsonBuilder();
  10.  
  11. while(resultset.next()){
  12.  
  13. // en va el numero de la columna o registro de nuestra consulta, que tiene el valor
  14. // que queremos poner en este campo de milista, igual con el 2
  15.  
  16. def lin1 = builder {
  17. id resultset.getObject(1).toString()
  18. entidad_reportante resultset.getObject(2).toString()
  19. nombre_entidad_reportante resultset.getObject(3).toString()
  20. departamento resultset.getObject(4).toString()
  21. perfil_reportante resultset.getObject(5).toString()
  22. codigo_reportante resultset.getObject(6).toString();
  23. nombre resultset.getObject(7).toString();
  24. }
  25. loggerJava.info("Reporte custom lin1: "+lin1);
  26. milista1.add(lin1);
  27. }
  28. loggerJava.info("Saliendo list reportes custom")
  29. return milista1;

Error1:

  1. The pbUpload property named "value" need to be bound to a variable

Error2:

  1. SyntaxError: Unexpected end of JSON input
  2. at Object.parse (native)

But it doesn't works, I got some errors.
Do you know this errors?

This is the link to the version in Spanish if you want to speak spanish:
http://community.bonitasoft.com/questions-and-answers/problemas-al-mostrar-un-widget-personalizado-con-una-tabla-no-muestra-valores

Your code works for me only in a Standar widget table, the default of UI Designer, but with the custom one doesn't, may be I am doing something wron in the angular code?

Thank you very much

Notifications