NEXT Button - adding OnClick causes a 500 (Internal Server Error) response

Hi there,

I have a process Human Task with two forms. Form1 has a HTML Widget which I want to pass to the second screen and also save to a Bonita variable.

I’m using this post as reference: http://community.bonitasoft.com//answers/where-use-javascript-html-widget#comment-38851

In line with the refPost I have a SimpleButton to save the data to the Bonita variable using REST, and this works with no problem. The code is very simple

onclick=“setData();”

What happens on Form1 is:

  1. complete the field in the HTML Widget with text,
  2. click on SimpleButton which uses REST to save the data to Bonita Variable,
  3. Click Next to get to the next form.

This displays the data correctly.

But on this form I don’t want the SimpleButton, so I add the code

onclick=“setData();”

to the Next Button

What I expect is:

the function setData() to be executed and then the second Form (Form2) to be displayed with the correct data.

This is where it fails with the 500 Error. Any thoughts? How do I get the OnClick for the Next Button to work correctly so I can remove the SimpleButton?

It looks like the NEXT button cannot reference the Forms Data.

Thanks and regards
Seán

The log data is as follows:

INFO: THREAD_ID=147 | HOSTNAME=Mainframe | TENANT_ID=1 | The user has started the process instance <11005> of process in version <1.3> and id <7581065748905170840> 2015-04-07 10:39:16 org.bonitasoft.web.toolkit.server.servlet.ToolkitHttpServlet SEVERE: Attribute 'value' must be specified org.bonitasoft.web.toolkit.client.common.exception.api.APIException: Attribute 'value' must be specified at org.bonitasoft.web.rest.server.api.bpm.cases.APICaseVariableAttributeChecker.checkUpdateAttributes(APICaseVariableAttributeChecker.java:40) at org.bonitasoft.web.rest.server.api.bpm.cases.APICaseVariable.runUpdate(APICaseVariable.java:37) at org.bonitasoft.web.rest.server.api.bpm.cases.APICaseVariable.runUpdate(APICaseVariable.java:30) at org.bonitasoft.web.rest.server.framework.APIServletCall.doPut(APIServletCall.java:244) at org.bonitasoft.web.toolkit.server.servlet.ToolkitHttpServlet.doPut(ToolkitHttpServlet.java:193) at javax.servlet.http.HttpServlet.service(HttpServlet.java:649) at org.bonitasoft.web.toolkit.server.servlet.ToolkitHttpServlet.service(ToolkitHttpServlet.java:75) at javax.servlet.http.HttpServlet.service(HttpServlet.java:727) at org.bonitasoft.web.toolkit.server.servlet.ToolkitHttpServlet.service(ToolkitHttpServlet.java:226) at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:303) at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:208) at org.apache.tomcat.websocket.server.WsFilter.doFilter(WsFilter.java:52) at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:241) at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:208) at org.apache.catalina.core.ApplicationDispatcher.invoke(ApplicationDispatcher.java:748) at org.apache.catalina.core.ApplicationDispatcher.processRequest(ApplicationDispatcher.java:486) at org.apache.catalina.core.ApplicationDispatcher.doForward(ApplicationDispatcher.java:411) at org.apache.catalina.core.ApplicationDispatcher.forward(ApplicationDispatcher.java:338) at org.tuckey.web.filters.urlrewrite.NormalRewrittenUrl.doRewrite(NormalRewrittenUrl.java:213) at org.tuckey.web.filters.urlrewrite.RuleChain.handleRewrite(RuleChain.java:171) at org.tuckey.web.filters.urlrewrite.RuleChain.doRules(RuleChain.java:145) at org.tuckey.web.filters.urlrewrite.UrlRewriter.processRequest(UrlRewriter.java:92) at org.tuckey.web.filters.urlrewrite.UrlRewriteFilter.doFilter(UrlRewriteFilter.java:394) at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:241) at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:208) at org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:220) at org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:122) at org.apache.catalina.authenticator.AuthenticatorBase.invoke(AuthenticatorBase.java:501) at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:171) at org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:103) at org.bonitasoft.console.security.SessionFixationValve.invoke(SessionFixationValve.java:77) at org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:116) at org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:408) at org.apache.coyote.http11.AbstractHttp11Processor.process(AbstractHttp11Processor.java:1070) at org.apache.coyote.AbstractProtocol$AbstractConnectionHandler.process(AbstractProtocol.java:611) at org.apache.tomcat.util.net.JIoEndpoint$SocketProcessor.run(JIoEndpoint.java:314) at java.util.concurrent.ThreadPoolExecutor.runWorker(Unknown Source) at java.util.concurrent.ThreadPoolExecutor$Worker.run(Unknown Source) at org.apache.tomcat.util.threads.TaskThread$WrappingRunnable.run(TaskThread.java:61) at java.lang.Thread.run(Unknown Source)

2015-04-07 10:41:08 org.bonitasoft.web.toolkit.server.servlet.ToolkitHttpServlet
SEVERE: Attribute ‘value’ must be specified
org.bonitasoft.web.toolkit.client.common.exception.api.APIException: Attribute ‘value’ must be specified
at org.bonitasoft.web.rest.server.api.bpm.cases.APICaseVariableAttributeChecker.checkUpdateAttributes(APICaseVariableAttributeChecker.java:40)
at org.bonitasoft.web.rest.server.api.bpm.cases.APICaseVariable.runUpdate(APICaseVariable.java:37)
at org.bonitasoft.web.rest.server.api.bpm.cases.APICaseVariable.runUpdate(APICaseVariable.java:30)
at org.bonitasoft.web.rest.server.framework.APIServletCall.doPut(APIServletCall.java:244)
at org.bonitasoft.web.toolkit.server.servlet.ToolkitHttpServlet.doPut(ToolkitHttpServlet.java:193)
at javax.servlet.http.HttpServlet.service(HttpServlet.java:649)
at org.bonitasoft.web.toolkit.server.servlet.ToolkitHttpServlet.service(ToolkitHttpServlet.java:75)
at javax.servlet.http.HttpServlet.service(HttpServlet.java:727)
at org.bonitasoft.web.toolkit.server.servlet.ToolkitHttpServlet.service(ToolkitHttpServlet.java:226)
at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:303)
at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:208)
at org.apache.tomcat.websocket.server.WsFilter.doFilter(WsFilter.java:52)
at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:241)
at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:208)
at org.apache.catalina.core.ApplicationDispatcher.invoke(ApplicationDispatcher.java:748)
at org.apache.catalina.core.ApplicationDispatcher.processRequest(ApplicationDispatcher.java:486)
at org.apache.catalina.core.ApplicationDispatcher.doForward(ApplicationDispatcher.java:411)
at org.apache.catalina.core.ApplicationDispatcher.forward(ApplicationDispatcher.java:338)
at org.tuckey.web.filters.urlrewrite.NormalRewrittenUrl.doRewrite(NormalRewrittenUrl.java:213)
at org.tuckey.web.filters.urlrewrite.RuleChain.handleRewrite(RuleChain.java:171)
at org.tuckey.web.filters.urlrewrite.RuleChain.doRules(RuleChain.java:145)
at org.tuckey.web.filters.urlrewrite.UrlRewriter.processRequest(UrlRewriter.java:92)
at org.tuckey.web.filters.urlrewrite.UrlRewriteFilter.doFilter(UrlRewriteFilter.java:394)
at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:241)
at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:208)
at org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:220)
at org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:122)
at org.apache.catalina.authenticator.AuthenticatorBase.invoke(AuthenticatorBase.java:501)
at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:171)
at org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:103)
at org.bonitasoft.console.security.SessionFixationValve.invoke(SessionFixationValve.java:77)
at org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:116)
at org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:408)
at org.apache.coyote.http11.AbstractHttp11Processor.process(AbstractHttp11Processor.java:1070)
at org.apache.coyote.AbstractProtocol$AbstractConnectionHandler.process(AbstractProtocol.java:611)
at org.apache.tomcat.util.net.JIoEndpoint$SocketProcessor.run(JIoEndpoint.java:314)
at java.util.concurrent.ThreadPoolExecutor.runWorker(Unknown Source)
at java.util.concurrent.ThreadPoolExecutor$Worker.run(Unknown Source)
at org.apache.tomcat.util.threads.TaskThread$WrappingRunnable.run(TaskThread.java:61)
at java.lang.Thread.run(Unknown Source)

The following is from Bonita Bug Reporting and reproduced here so people can understand what is happening,

a working version of Next onclick can be found in post: https://bonita.atlassian.net/browse/BBPMC-260

Hi Sean,

I did reproduce the issue and saw what went wrong by putting some JS alerts to halt page processing.

Here is the sequence of events that take place when you try to submit the form with the next button that has the onclick function:

  1. You click on the button
  2. The form gets cleared and replaced with the animated loading gif
  3. The onclick function is then executed but fails to find the “friendName” input (it was removed in previous step)
  4. The set variable REST method is called with an empty value due to the previous error and fails

To put it simply, the onclick function is triggered too late in the page processing.

We will not fix this as this is quite impacting on the form mechanism but here is a simple workaround.

Use a simple button with an onclick to call the REST API then trigger a click on a hidden next button.

You already have a part of the solution in your current code, but it is not working since the CSS selector for the button is not the right one:

$(‘.submit’).click();

I will upload a fixed version of your process.
Cheers