Message box from StiWebDesigerHandler implementation

Stimulsoft Reports.Java discussion
Post Reply
sduchampt
Posts: 3
Joined: Tue Oct 08, 2019 8:26 am

Message box from StiWebDesigerHandler implementation

Post by sduchampt » Tue Oct 08, 2019 12:10 pm

Hello,

I would like to manage message when saving my report.
The only way I found is to throw a RuntimeException in StiWebDesigerHandler implementation :

Code: Select all

public class WebDesignerHandler implements StiWebDesigerHandler {
    public void onSaveReportTemplate(StiReport report, StiRequestParams requestParams, HttpServletRequest request) {
        throw new RuntimeException("Error message from onSaveReportTemplate");
    }
    ...
download/file.php?mode=view&id=24379&am ... 59f30b6b56

Is it the best way to display a message ?
I would like to have carriage return in my message, is it possible ("\n" has no effect) ?
With a RuntimeException, I can only display error message, how can I display a warning or an information message ?

Thanks for your help
Attachments
MessageBox.jpg
MessageBox.jpg (349.79 KiB) Viewed 396 times
Lech Kulikowski
Posts: 1863
Joined: Tue Mar 20, 2018 5:34 am

Re: Message box from StiWebDesigerHandler implementation

Post by Lech Kulikowski » Tue Oct 08, 2019 1:46 pm

Hello,

Please check the following code:

Code: Select all

protected void StiWebDesigner1_SaveReport(object sender, StiSaveReportEventArgs e)
    {        
        StiReportResponse.ResponseString("{\"infoMessage\":\"Report saved successfully <br> next line <br> next line \"}", "application/json", false);
    }
Thank you.
sduchampt
Posts: 3
Joined: Tue Oct 08, 2019 8:26 am

Re: Message box from StiWebDesigerHandler implementation

Post by sduchampt » Wed Oct 09, 2019 10:08 am

Hello,

Thanks for your response.
I can't find any method StiReportResponse.ResponseString...
I tried with StiReportResponse.responseBuffer

Code: Select all

public class WebDesignerHandler implements StiWebDesigerHandler {
    public void onSaveReportTemplate(StiReport report, StiRequestParams requestParams, HttpServletRequest request) {
        // throw new RuntimeException("Error message from onSaveReportTemplate");
        StiReportResponse.responseBuffer(response, "{\"infoMessage\":\"Test\"}".getBytes(), "application/json", false, null, false);
    }
    ...
When running (inside Tomcat9), I have this error (the output buffer seems to be closed) :

Code: Select all

2019-10-09 11:49:29,321 [] [http-nio-6789-exec-1] ERROR c.a.r.webdesigner.WebDesignerHandler - Error [class org.apache.coyote.CloseNowException] when saving report : org.apache.coyote.CloseNowException: Echec d'Úcriture
        at org.apache.coyote.http11.Http11OutputBuffer$SocketOutputBuffer.doWrite(Http11OutputBuffer.java:540)
        at org.apache.coyote.http11.filters.IdentityOutputFilter.doWrite(IdentityOutputFilter.java:73)
        at org.apache.coyote.http11.Http11OutputBuffer.doWrite(Http11OutputBuffer.java:190)
        at org.apache.coyote.Response.doWrite(Response.java:601)
        at org.apache.catalina.connector.OutputBuffer.realWriteBytes(OutputBuffer.java:339)
        at org.apache.catalina.connector.OutputBuffer.flushByteBuffer(OutputBuffer.java:776)
        at org.apache.catalina.connector.OutputBuffer.doFlush(OutputBuffer.java:298)
        at org.apache.catalina.connector.OutputBuffer.flush(OutputBuffer.java:272)
        at org.apache.catalina.connector.CoyoteOutputStream.flush(CoyoteOutputStream.java:118)
        at com.stimulsoft.lib.io.StiIOUtil.writeInputStream(StiIOUtil.java:48)
        at com.stimulsoft.web.helper.StiReportResponse.responseBuffer(StiReportResponse.java:171)
        at com.asis.report.webdesigner.WebDesignerHandler.onSaveReportTemplate(WebDesignerHandler.java:274)
        at com.stimulsoft.webdesigner.StiWebDesignerCommands.commandResult(StiWebDesignerCommands.java:241)
        at com.stimulsoft.webdesigner.StiWebDesignerActions.processRequestResult(StiWebDesignerActions.java:150)
        at com.stimulsoft.webdesigner.StiWebDesignerActions.designerEventResult(StiWebDesignerActions.java:89)
        at com.stimulsoft.webdesigner.servlet.StiWebDesignerActionServlet.processing(StiWebDesignerActionServlet.java:65)
        at com.stimulsoft.webdesigner.servlet.StiWebDesignerActionServlet.doPost(StiWebDesignerActionServlet.java:46)
        at javax.servlet.http.HttpServlet.service(HttpServlet.java:660)
        at javax.servlet.http.HttpServlet.service(HttpServlet.java:741)
        at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:231)
        at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:166)
        at org.apache.tomcat.websocket.server.WsFilter.doFilter(WsFilter.java:53)
        at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:193)
        at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:166)
        at org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:202)
        at org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:96)
        at org.apache.catalina.authenticator.AuthenticatorBase.invoke(AuthenticatorBase.java:526)
        at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:139)
        at org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:92)
        at org.apache.catalina.valves.AbstractAccessLogValve.invoke(AbstractAccessLogValve.java:678)
        at org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:74)
        at org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:343)
        at org.apache.coyote.http11.Http11Processor.service(Http11Processor.java:408)
        at org.apache.coyote.AbstractProcessorLight.process(AbstractProcessorLight.java:66)
        at org.apache.coyote.AbstractProtocol$ConnectionHandler.process(AbstractProtocol.java:860)
        at org.apache.tomcat.util.net.NioEndpoint$SocketProcessor.doRun(NioEndpoint.java:1589)
        at org.apache.tomcat.util.net.SocketProcessorBase.run(SocketProcessorBase.java:49)
        at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1149)
        at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:624)
        at org.apache.tomcat.util.threads.TaskThread$WrappingRunnable.run(TaskThread.java:61)
        at java.lang.Thread.run(Thread.java:748)

java.lang.RuntimeException: ERROR : Echec d'écriture
class org.apache.coyote.CloseNowException
        at com.asis.report.webdesigner.WebDesignerHandler.onSaveReportTemplate(WebDesignerHandler.java:286)
        at com.stimulsoft.webdesigner.StiWebDesignerCommands.commandResult(StiWebDesignerCommands.java:241)
        at com.stimulsoft.webdesigner.StiWebDesignerActions.processRequestResult(StiWebDesignerActions.java:150)
        at com.stimulsoft.webdesigner.StiWebDesignerActions.designerEventResult(StiWebDesignerActions.java:89)
        at com.stimulsoft.webdesigner.servlet.StiWebDesignerActionServlet.processing(StiWebDesignerActionServlet.java:65)
        at com.stimulsoft.webdesigner.servlet.StiWebDesignerActionServlet.doPost(StiWebDesignerActionServlet.java:46)
        at javax.servlet.http.HttpServlet.service(HttpServlet.java:660)
        at javax.servlet.http.HttpServlet.service(HttpServlet.java:741)
        at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:231)
        at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:166)
        at org.apache.tomcat.websocket.server.WsFilter.doFilter(WsFilter.java:53)
        at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:193)
        at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:166)
        at org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:202)
        at org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:96)
        at org.apache.catalina.authenticator.AuthenticatorBase.invoke(AuthenticatorBase.java:526)
        at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:139)
        at org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:92)
        at org.apache.catalina.valves.AbstractAccessLogValve.invoke(AbstractAccessLogValve.java:678)
        at org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:74)
        at org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:343)
        at org.apache.coyote.http11.Http11Processor.service(Http11Processor.java:408)
        at org.apache.coyote.AbstractProcessorLight.process(AbstractProcessorLight.java:66)
        at org.apache.coyote.AbstractProtocol$ConnectionHandler.process(AbstractProtocol.java:860)
        at org.apache.tomcat.util.net.NioEndpoint$SocketProcessor.doRun(NioEndpoint.java:1589)
        at org.apache.tomcat.util.net.SocketProcessorBase.run(SocketProcessorBase.java:49)
        at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1149)
        at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:624)
        at org.apache.tomcat.util.threads.TaskThread$WrappingRunnable.run(TaskThread.java:61)
        at java.lang.Thread.run(Thread.java:748)
Is there other possibilities instead of "infoMessage" ? Perhaps errorMessage, warningMessage ?

Thanks
Lech Kulikowski
Posts: 1863
Joined: Tue Mar 20, 2018 5:34 am

Re: Message box from StiWebDesigerHandler implementation

Post by Lech Kulikowski » Wed Oct 09, 2019 11:11 am

Hello,

That code as a sample, you can use the similar code for Java version.

Thank you.
sduchampt
Posts: 3
Joined: Tue Oct 08, 2019 8:26 am

Re: Message box from StiWebDesigerHandler implementation

Post by sduchampt » Wed Oct 09, 2019 5:30 pm

Hello,

I agree, it's the reason why I used StiReportResponse.responseBuffer.
But it's not working, I get an error (present in my last post)

Thanks
Vadim
Posts: 221
Joined: Tue Apr 23, 2013 11:23 am

Re: Message box from StiWebDesigerHandler implementation

Post by Vadim » Fri Oct 11, 2019 2:44 pm

Hello.
Unfortunately, for Java version in onSaveReportTemplate(StiReport report, StiRequestParams requestParams, HttpServletRequest request) no HttpServletResponse object.
It's impossible to send message when saving report.
Post Reply