Page 1 of 1

Show error on designer handler

Posted: Mon Jul 13, 2015 1:31 pm
by rafaelwithoeft
Hello, i need to show errors on actions of handler designer.

Code: Select all

StiWebDesigerHandler handler = new StiWebDesigerHandler() {
    public StiReport getEditedReport(HttpServletRequest request) {}
    public void onOpenReportTemplate(StiReport report, HttpServletRequest request) {}
    public void onNewReportTemplate(StiReport report, HttpServletRequest request) {}
    public void onSaveReportTemplate(StiReport report, String reportName, HttpServletRequest request) {
        try {					
            //EXAMPLE CODE
        } catch (BancoDadosException e) {
            //Not work
	        throw new RuntimeException(ErrorHelper.ERROR_DIRETA_BANCO_DE_DADOS);
	    }
    }
}
Using the same dialog like this, if possible:

http://forum.stimulsoft.com/viewtopic.p ... 162#p79257

How i do it?
Thank you

Re: Show error on designer handler

Posted: Tue Jul 14, 2015 6:21 am
by Vladimir
Hello,

For this you need to send to the client the following JSON response:

Code: Select all

{"error": "Custom error message"}
Also the attached archive contains a fix to correctly display this dialog box:
stimulsoft.reports-webdesigner-2015.1.12-trial.zip
(1.27 MiB) Downloaded 299 times
Thank you.

Re: Show error on designer handler

Posted: Tue Jul 14, 2015 12:26 pm
by rafaelwithoeft
I tried this code, but not workd:

Code: Select all

response.setContentType("application/json");
response.setCharacterEncoding("utf-8");
PrintWriter out = response.getWriter();

StiWebDesigerHandler handler = new StiWebDesigerHandler() {
	public StiReport getEditedReport(HttpServletRequest request) {
		StiReport report = null;
		try {
			//Code
		} catch (RelatorioNaoEncontradoException e) {
			out.print( ErrorHelper.getErrorJsonObject( ErrorHelper.ERROR_RELATORIO_NAO_ENCONTRADO ) );
			out.flush();
		}
		return report;
	}

	public void onOpenReportTemplate(StiReport report, HttpServletRequest request) {
	}

	public void onNewReportTemplate(StiReport report, HttpServletRequest request) {
	}

	public void onSaveReportTemplate(StiReport report, String reportName, HttpServletRequest request) {
		try {
			//Code
		} catch (BancoDadosException e) {
			System.out.println( ErrorHelper.getErrorJsonObject( ErrorHelper.ERROR_BANCO_DE_DADOS ).toString() );
			out.print( ErrorHelper.getErrorJsonObject( ErrorHelper.ERROR_BANCO_DE_DADOS ).toString() );
			out.flush();
		} catch (NullPointerException e) {
			out.print( ErrorHelper.getErrorJsonObject( ErrorHelper.ERROR_BANCO_DE_DADOS ).toString() );
			out.flush();
		}
	}
};


//Output of JsonObject : {"error":"Não foi possível completar a requisição ao banco de dados. Por favor, entre em contato com o suporte."}
Can you give me one example?
PS: I downloaded latest version using registered users area.

Thank you

Re: Show error on designer handler

Posted: Wed Jul 15, 2015 8:23 am
by Vladimir
Hello,

We checked out the code to display error messages - need to make some improvements to work it properly.
This improvement is added to the TO-DO list and sent to developers. It will take some time.
We will let you know as soon as any changes in this direction.

Thank you.

Re: Show error on designer handler

Posted: Wed Jul 15, 2015 11:14 am
by rafaelwithoeft
Ok

Thank you