From 08111d145c744a8161a7b6fd877a2e34b4da194c Mon Sep 17 00:00:00 2001 From: Marco Zanon Date: Wed, 1 Feb 2012 18:31:42 +0000 Subject: [PATCH] Modified code to be slightly more logic. --- .../marcozanon/macaco/web/ui/MWebApplicationServlet.java | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/src/java/com/marcozanon/macaco/web/ui/MWebApplicationServlet.java b/src/java/com/marcozanon/macaco/web/ui/MWebApplicationServlet.java index c04a63c..8a08959 100644 --- a/src/java/com/marcozanon/macaco/web/ui/MWebApplicationServlet.java +++ b/src/java/com/marcozanon/macaco/web/ui/MWebApplicationServlet.java @@ -201,17 +201,17 @@ public abstract class MWebApplicationServlet extends MHttpServlet { // prepare response content byte[] responseContent = null; if (ajaxMode) { - MJsonObject returnValue = null; try { + MJsonObject returnValue = null; returnValue = new MJsonObject(); returnValue.setValue("errorMode", new MJsonNumber("" + MWebApplicationServlet.ErrorMode.CLEAN.ordinal())); MJsonString jsonParameter = new MJsonString(); jsonParameter.setValue(new String(content, MInformation.TEXT_ENCODING)); returnValue.setValue("parameter", jsonParameter); + responseContent = returnValue.getJsonValue().getBytes(MInformation.TEXT_ENCODING); } catch (MInvalidValueJsonException exception) { // cannot happen } - responseContent = returnValue.getJsonValue().getBytes(MInformation.TEXT_ENCODING); } else { responseContent = content; @@ -241,8 +241,8 @@ public abstract class MWebApplicationServlet extends MHttpServlet { try { if (MWebApplicationServlet.ErrorMode.DEBUG == errorMode) { if (ajaxMode) { - MJsonObject returnValue = null; try { + MJsonObject returnValue = null; returnValue = new MJsonObject(); returnValue.setValue("errorMode", new MJsonNumber("" + errorMode.ordinal())); MJsonString jsonParameter = new MJsonString(); @@ -253,10 +253,10 @@ public abstract class MWebApplicationServlet extends MHttpServlet { jsonParameter.setValue(content.getClass().getName()); } returnValue.setValue("parameter", jsonParameter); + responseContent = returnValue.getJsonValue().getBytes(MInformation.TEXT_ENCODING); } catch (MInvalidValueJsonException exception) { // should not happen } - responseContent = returnValue.getJsonValue().getBytes(MInformation.TEXT_ENCODING); } else { if (null != content.getMessage()) { -- 2.30.2