Show error on designer handler

Stimulsoft Reports.JAVA discussion
Post Reply
User avatar
rafaelwithoeft
Posts: 70
Joined: Thu Mar 05, 2015 8:26 pm

Show error on designer handler

Post 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
Vladimir
Posts: 1462
Joined: Fri Apr 13, 2007 4:05 am
Location: Earth

Re: Show error on designer handler

Post 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 228 times
Thank you.
User avatar
rafaelwithoeft
Posts: 70
Joined: Thu Mar 05, 2015 8:26 pm

Re: Show error on designer handler

Post 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
Vladimir
Posts: 1462
Joined: Fri Apr 13, 2007 4:05 am
Location: Earth

Re: Show error on designer handler

Post 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.
User avatar
rafaelwithoeft
Posts: 70
Joined: Thu Mar 05, 2015 8:26 pm

Re: Show error on designer handler

Post by rafaelwithoeft »

Ok

Thank you
Post Reply