details:   /erp/devel/pi/rev/3cc4796f74ed
changeset: 9106:3cc4796f74ed
user:      Gorka Ion Damián <gorkaion.damian <at> openbravo.com>
date:      Mon Dec 13 19:36:51 2010 +0100
summary:   Added FixedValueExpressionCallout to the Fixed Value expression.

details:   /erp/devel/pi/rev/42ca983ccfa0
changeset: 9107:42ca983ccfa0
user:      Gorka Ion Damián <gorkaion.damian <at> openbravo.com>
date:      Mon Dec 13 19:37:44 2010 +0100
summary:   Added onCreateDefault expression to new column.

details:   /erp/devel/pi/rev/5b126a563792
changeset: 9108:5b126a563792
user:      Gorka Ion Damián <gorkaion.damian <at> openbravo.com>
date:      Mon Dec 13 19:38:21 2010 +0100
summary:   Messages moved to Client Application Module.

details:   /erp/devel/pi/rev/2ec72958bb0f
changeset: 9109:2ec72958bb0f
user:      Gorka Ion Damián <gorkaion.damian <at> openbravo.com>
date:      Mon Dec 13 19:38:46 2010 +0100
summary:   Refactored DefaultExpressionCallout to implement JSExpressionCallout.

diffstat:

 
modules/org.openbravo.client.application/src-db/database/model/tables/OBUIAPP_PARAMETER.xml
                         |    2 +-
 
modules/org.openbravo.client.application/src-db/database/sourcedata/AD_CALLOUT.xml
                                  |   12 +
 
modules/org.openbravo.client.application/src-db/database/sourcedata/AD_COLUMN.xml
                                   |    1 +
 
modules/org.openbravo.client.application/src-db/database/sourcedata/AD_MESSAGE.xml
                                  |   24 ++
 
modules/org.openbravo.client.application/src-db/database/sourcedata/AD_MODEL_OBJECT.xml
                             |   12 +
 
modules/org.openbravo.client.application/src-db/database/sourcedata/AD_MODEL_OBJECT_MAPPING.xml
                     |   10 +
 
modules/org.openbravo.client.application/src/org/openbravo/client/application/ApplicationUtils.java
                 |   25 +-
 
modules/org.openbravo.client.application/src/org/openbravo/client/application/FixedValueExpressionCallout.java
      |   39 +++
 
modules/org.openbravo.client.application/src/org/openbravo/client/application/JSExpressionCallout.java
              |  118 ++++++++++
 
modules/org.openbravo.userinterface.selector/src-db/database/sourcedata/AD_MESSAGE.xml
                              |   24 --
 
modules/org.openbravo.userinterface.selector/src/org/openbravo/userinterface/selector/DefaultExpressionCallout.java
 |  116 +--------
 11 files changed, 246 insertions(+), 137 deletions(-)

diffs (truncated from 511 to 300 lines):

diff -r 9685a3560779 -r 2ec72958bb0f 
modules/org.openbravo.client.application/src-db/database/model/tables/OBUIAPP_PARAMETER.xml
--- 
a/modules/org.openbravo.client.application/src-db/database/model/tables/OBUIAPP_PARAMETER.xml
       Mon Dec 13 18:39:10 2010 +0100
+++ 
b/modules/org.openbravo.client.application/src-db/database/model/tables/OBUIAPP_PARAMETER.xml
       Mon Dec 13 19:38:46 2010 +0100
@@ -95,7 +95,7 @@
       </column>
       <column name="EVALUATEFIXEDVALUE" primaryKey="false" required="true" 
type="CHAR" size="1" autoIncrement="false">
         <default><![CDATA[N]]></default>
-        <onCreateDefault/>
+        <onCreateDefault><![CDATA['N']]></onCreateDefault>
       </column>
       <foreign-key foreignTable="AD_CLIENT" name="OBUIAPP_PARAMETER_AD_CLIENT">
         <reference local="AD_CLIENT_ID" foreign="AD_CLIENT_ID"/>
diff -r 9685a3560779 -r 2ec72958bb0f 
modules/org.openbravo.client.application/src-db/database/sourcedata/AD_CALLOUT.xml
--- /dev/null   Thu Jan 01 00:00:00 1970 +0000
+++ 
b/modules/org.openbravo.client.application/src-db/database/sourcedata/AD_CALLOUT.xml
        Mon Dec 13 19:38:46 2010 +0100
@@ -0,0 +1,12 @@
+<?xml version='1.0' encoding='UTF-8'?>
+<data>
+<!--9C99E3CC80944AC388AEE23DE96C87F6--><AD_CALLOUT>
+<!--9C99E3CC80944AC388AEE23DE96C87F6-->  
<AD_CALLOUT_ID><![CDATA[9C99E3CC80944AC388AEE23DE96C87F6]]></AD_CALLOUT_ID>
+<!--9C99E3CC80944AC388AEE23DE96C87F6-->  
<AD_CLIENT_ID><![CDATA[0]]></AD_CLIENT_ID>
+<!--9C99E3CC80944AC388AEE23DE96C87F6-->  <AD_ORG_ID><![CDATA[0]]></AD_ORG_ID>
+<!--9C99E3CC80944AC388AEE23DE96C87F6-->  <ISACTIVE><![CDATA[Y]]></ISACTIVE>
+<!--9C99E3CC80944AC388AEE23DE96C87F6-->  
<NAME><![CDATA[FixedValueExpression]]></NAME>
+<!--9C99E3CC80944AC388AEE23DE96C87F6-->  
<AD_MODULE_ID><![CDATA[9BA0836A3CD74EE4AB48753A47211BCC]]></AD_MODULE_ID>
+<!--9C99E3CC80944AC388AEE23DE96C87F6--></AD_CALLOUT>
+
+</data>
diff -r 9685a3560779 -r 2ec72958bb0f 
modules/org.openbravo.client.application/src-db/database/sourcedata/AD_COLUMN.xml
--- 
a/modules/org.openbravo.client.application/src-db/database/sourcedata/AD_COLUMN.xml
 Mon Dec 13 18:39:10 2010 +0100
+++ 
b/modules/org.openbravo.client.application/src-db/database/sourcedata/AD_COLUMN.xml
 Mon Dec 13 19:38:46 2010 +0100
@@ -2120,6 +2120,7 @@
 <!--927DA01A83403AFAE040A8C0CF072B85-->  
<ISSESSIONATTR><![CDATA[N]]></ISSESSIONATTR>
 <!--927DA01A83403AFAE040A8C0CF072B85-->  
<ISSECONDARYKEY><![CDATA[N]]></ISSECONDARYKEY>
 <!--927DA01A83403AFAE040A8C0CF072B85-->  
<ISDESENCRYPTABLE><![CDATA[N]]></ISDESENCRYPTABLE>
+<!--927DA01A83403AFAE040A8C0CF072B85-->  
<AD_CALLOUT_ID><![CDATA[9C99E3CC80944AC388AEE23DE96C87F6]]></AD_CALLOUT_ID>
 <!--927DA01A83403AFAE040A8C0CF072B85-->  
<DEVELOPMENTSTATUS><![CDATA[RE]]></DEVELOPMENTSTATUS>
 <!--927DA01A83403AFAE040A8C0CF072B85-->  
<AD_MODULE_ID><![CDATA[9BA0836A3CD74EE4AB48753A47211BCC]]></AD_MODULE_ID>
 <!--927DA01A83403AFAE040A8C0CF072B85-->  <POSITION><![CDATA[23]]></POSITION>
diff -r 9685a3560779 -r 2ec72958bb0f 
modules/org.openbravo.client.application/src-db/database/sourcedata/AD_MESSAGE.xml
--- 
a/modules/org.openbravo.client.application/src-db/database/sourcedata/AD_MESSAGE.xml
        Mon Dec 13 18:39:10 2010 +0100
+++ 
b/modules/org.openbravo.client.application/src-db/database/sourcedata/AD_MESSAGE.xml
        Mon Dec 13 19:38:46 2010 +0100
@@ -220,6 +220,18 @@
 <!--6831E84EB2124F08B3FCEF6F50CF8AD1-->  
<AD_MODULE_ID><![CDATA[9BA0836A3CD74EE4AB48753A47211BCC]]></AD_MODULE_ID>
 <!--6831E84EB2124F08B3FCEF6F50CF8AD1--></AD_MESSAGE>
 
+<!--6CFA4900AECA4A45B35FEE55EBA14D01--><AD_MESSAGE>
+<!--6CFA4900AECA4A45B35FEE55EBA14D01-->  
<AD_MESSAGE_ID><![CDATA[6CFA4900AECA4A45B35FEE55EBA14D01]]></AD_MESSAGE_ID>
+<!--6CFA4900AECA4A45B35FEE55EBA14D01-->  
<AD_CLIENT_ID><![CDATA[0]]></AD_CLIENT_ID>
+<!--6CFA4900AECA4A45B35FEE55EBA14D01-->  <AD_ORG_ID><![CDATA[0]]></AD_ORG_ID>
+<!--6CFA4900AECA4A45B35FEE55EBA14D01-->  <ISACTIVE><![CDATA[Y]]></ISACTIVE>
+<!--6CFA4900AECA4A45B35FEE55EBA14D01-->  
<VALUE><![CDATA[OBUIAPP_CALLOUT_JS_EXPR_ERROR]]></VALUE>
+<!--6CFA4900AECA4A45B35FEE55EBA14D01-->  <MSGTEXT><![CDATA[Error evaluating 
expression:]]></MSGTEXT>
+<!--6CFA4900AECA4A45B35FEE55EBA14D01-->  <MSGTIP><![CDATA[Message used for 
prompting an error in the JavaScript expression. Used when defining 
Filter/Default expressions]]></MSGTIP>
+<!--6CFA4900AECA4A45B35FEE55EBA14D01-->  <MSGTYPE><![CDATA[I]]></MSGTYPE>
+<!--6CFA4900AECA4A45B35FEE55EBA14D01-->  
<AD_MODULE_ID><![CDATA[9BA0836A3CD74EE4AB48753A47211BCC]]></AD_MODULE_ID>
+<!--6CFA4900AECA4A45B35FEE55EBA14D01--></AD_MESSAGE>
+
 <!--7192A02FA20F48ADB0578CDCF1EA49EF--><AD_MESSAGE>
 <!--7192A02FA20F48ADB0578CDCF1EA49EF-->  
<AD_MESSAGE_ID><![CDATA[7192A02FA20F48ADB0578CDCF1EA49EF]]></AD_MESSAGE_ID>
 <!--7192A02FA20F48ADB0578CDCF1EA49EF-->  
<AD_CLIENT_ID><![CDATA[0]]></AD_CLIENT_ID>
@@ -352,6 +364,18 @@
 <!--9EFEA3F8412B4F5C836DFB40034156EA-->  
<AD_MODULE_ID><![CDATA[9BA0836A3CD74EE4AB48753A47211BCC]]></AD_MODULE_ID>
 <!--9EFEA3F8412B4F5C836DFB40034156EA--></AD_MESSAGE>
 
+<!--ABFDBB83F58841EA9545D9ED8637513B--><AD_MESSAGE>
+<!--ABFDBB83F58841EA9545D9ED8637513B-->  
<AD_MESSAGE_ID><![CDATA[ABFDBB83F58841EA9545D9ED8637513B]]></AD_MESSAGE_ID>
+<!--ABFDBB83F58841EA9545D9ED8637513B-->  
<AD_CLIENT_ID><![CDATA[0]]></AD_CLIENT_ID>
+<!--ABFDBB83F58841EA9545D9ED8637513B-->  <AD_ORG_ID><![CDATA[0]]></AD_ORG_ID>
+<!--ABFDBB83F58841EA9545D9ED8637513B-->  <ISACTIVE><![CDATA[Y]]></ISACTIVE>
+<!--ABFDBB83F58841EA9545D9ED8637513B-->  
<VALUE><![CDATA[OBUIAPP_CALLOUT_JS_EXPR_RESULT]]></VALUE>
+<!--ABFDBB83F58841EA9545D9ED8637513B-->  <MSGTEXT><![CDATA[Evaluation 
expression result:]]></MSGTEXT>
+<!--ABFDBB83F58841EA9545D9ED8637513B-->  <MSGTIP><![CDATA[Message used for 
prompting the result of evaluating a JavaScript expression in: Default and 
Filter expressions]]></MSGTIP>
+<!--ABFDBB83F58841EA9545D9ED8637513B-->  <MSGTYPE><![CDATA[I]]></MSGTYPE>
+<!--ABFDBB83F58841EA9545D9ED8637513B-->  
<AD_MODULE_ID><![CDATA[9BA0836A3CD74EE4AB48753A47211BCC]]></AD_MODULE_ID>
+<!--ABFDBB83F58841EA9545D9ED8637513B--></AD_MESSAGE>
+
 <!--B05C4EF1C8624EAAAC53764B7DACB2C2--><AD_MESSAGE>
 <!--B05C4EF1C8624EAAAC53764B7DACB2C2-->  
<AD_MESSAGE_ID><![CDATA[B05C4EF1C8624EAAAC53764B7DACB2C2]]></AD_MESSAGE_ID>
 <!--B05C4EF1C8624EAAAC53764B7DACB2C2-->  
<AD_CLIENT_ID><![CDATA[0]]></AD_CLIENT_ID>
diff -r 9685a3560779 -r 2ec72958bb0f 
modules/org.openbravo.client.application/src-db/database/sourcedata/AD_MODEL_OBJECT.xml
--- 
a/modules/org.openbravo.client.application/src-db/database/sourcedata/AD_MODEL_OBJECT.xml
   Mon Dec 13 18:39:10 2010 +0100
+++ 
b/modules/org.openbravo.client.application/src-db/database/sourcedata/AD_MODEL_OBJECT.xml
   Mon Dec 13 19:38:46 2010 +0100
@@ -36,6 +36,18 @@
 <!--86399BCB3F3746A88440887157CF0F57-->  
<OBJECT_TYPE><![CDATA[S]]></OBJECT_TYPE>
 <!--86399BCB3F3746A88440887157CF0F57--></AD_MODEL_OBJECT>
 
+<!--974EBD0DC79A0489E040007F01005279--><AD_MODEL_OBJECT>
+<!--974EBD0DC79A0489E040007F01005279-->  
<AD_MODEL_OBJECT_ID><![CDATA[974EBD0DC79A0489E040007F01005279]]></AD_MODEL_OBJECT_ID>
+<!--974EBD0DC79A0489E040007F01005279-->  
<AD_CLIENT_ID><![CDATA[0]]></AD_CLIENT_ID>
+<!--974EBD0DC79A0489E040007F01005279-->  <AD_ORG_ID><![CDATA[0]]></AD_ORG_ID>
+<!--974EBD0DC79A0489E040007F01005279-->  <ISACTIVE><![CDATA[Y]]></ISACTIVE>
+<!--974EBD0DC79A0489E040007F01005279-->  <ACTION><![CDATA[C]]></ACTION>
+<!--974EBD0DC79A0489E040007F01005279-->  
<CLASSNAME><![CDATA[org.openbravo.client.application.FixedValueExpressionCallout]]></CLASSNAME>
+<!--974EBD0DC79A0489E040007F01005279-->  <ISDEFAULT><![CDATA[Y]]></ISDEFAULT>
+<!--974EBD0DC79A0489E040007F01005279-->  
<AD_CALLOUT_ID><![CDATA[9C99E3CC80944AC388AEE23DE96C87F6]]></AD_CALLOUT_ID>
+<!--974EBD0DC79A0489E040007F01005279-->  
<OBJECT_TYPE><![CDATA[S]]></OBJECT_TYPE>
+<!--974EBD0DC79A0489E040007F01005279--></AD_MODEL_OBJECT>
+
 <!--9A0CA1BBFB5547099F69D6B738D6DB06--><AD_MODEL_OBJECT>
 <!--9A0CA1BBFB5547099F69D6B738D6DB06-->  
<AD_MODEL_OBJECT_ID><![CDATA[9A0CA1BBFB5547099F69D6B738D6DB06]]></AD_MODEL_OBJECT_ID>
 <!--9A0CA1BBFB5547099F69D6B738D6DB06-->  
<AD_CLIENT_ID><![CDATA[0]]></AD_CLIENT_ID>
diff -r 9685a3560779 -r 2ec72958bb0f 
modules/org.openbravo.client.application/src-db/database/sourcedata/AD_MODEL_OBJECT_MAPPING.xml
--- 
a/modules/org.openbravo.client.application/src-db/database/sourcedata/AD_MODEL_OBJECT_MAPPING.xml
   Mon Dec 13 18:39:10 2010 +0100
+++ 
b/modules/org.openbravo.client.application/src-db/database/sourcedata/AD_MODEL_OBJECT_MAPPING.xml
   Mon Dec 13 19:38:46 2010 +0100
@@ -100,6 +100,16 @@
 <!--932C60586CED48DB9A919B291FAD572E-->  <ISDEFAULT><![CDATA[N]]></ISDEFAULT>
 <!--932C60586CED48DB9A919B291FAD572E--></AD_MODEL_OBJECT_MAPPING>
 
+<!--974EBD0DC79B0489E040007F01005279--><AD_MODEL_OBJECT_MAPPING>
+<!--974EBD0DC79B0489E040007F01005279-->  
<AD_MODEL_OBJECT_MAPPING_ID><![CDATA[974EBD0DC79B0489E040007F01005279]]></AD_MODEL_OBJECT_MAPPING_ID>
+<!--974EBD0DC79B0489E040007F01005279-->  
<AD_CLIENT_ID><![CDATA[0]]></AD_CLIENT_ID>
+<!--974EBD0DC79B0489E040007F01005279-->  <AD_ORG_ID><![CDATA[0]]></AD_ORG_ID>
+<!--974EBD0DC79B0489E040007F01005279-->  <ISACTIVE><![CDATA[Y]]></ISACTIVE>
+<!--974EBD0DC79B0489E040007F01005279-->  
<AD_MODEL_OBJECT_ID><![CDATA[974EBD0DC79A0489E040007F01005279]]></AD_MODEL_OBJECT_ID>
+<!--974EBD0DC79B0489E040007F01005279-->  
<MAPPINGNAME><![CDATA[/org.openbravo.client.application.ad_callouts/FixedValueExpression.html]]></MAPPINGNAME>
+<!--974EBD0DC79B0489E040007F01005279-->  <ISDEFAULT><![CDATA[Y]]></ISDEFAULT>
+<!--974EBD0DC79B0489E040007F01005279--></AD_MODEL_OBJECT_MAPPING>
+
 <!--977CBD0E9B50416FAFAD58F8D6170164--><AD_MODEL_OBJECT_MAPPING>
 <!--977CBD0E9B50416FAFAD58F8D6170164-->  
<AD_MODEL_OBJECT_MAPPING_ID><![CDATA[977CBD0E9B50416FAFAD58F8D6170164]]></AD_MODEL_OBJECT_MAPPING_ID>
 <!--977CBD0E9B50416FAFAD58F8D6170164-->  
<AD_CLIENT_ID><![CDATA[0]]></AD_CLIENT_ID>
diff -r 9685a3560779 -r 2ec72958bb0f 
modules/org.openbravo.client.application/src/org/openbravo/client/application/ApplicationUtils.java
--- 
a/modules/org.openbravo.client.application/src/org/openbravo/client/application/ApplicationUtils.java
       Mon Dec 13 18:39:10 2010 +0100
+++ 
b/modules/org.openbravo.client.application/src/org/openbravo/client/application/ApplicationUtils.java
       Mon Dec 13 19:38:46 2010 +0100
@@ -24,6 +24,8 @@
 
 import javax.script.ScriptEngine;
 import javax.script.ScriptEngineManager;
+import javax.script.ScriptException;
+import javax.servlet.http.HttpSession;
 
 import org.apache.log4j.Logger;
 import org.hibernate.criterion.Expression;
@@ -127,18 +129,27 @@
   public static String getParameterFixedValue(Map<String, String> parameters, 
Parameter parameter) {
     if (parameter.isEvaluateFixedValue()) {
       try {
-        final ScriptEngineManager manager = new ScriptEngineManager();
-        final ScriptEngine engine = manager.getEngineByName("js");
-
-        engine.put("OB", new OBBindings(OBContext.getOBContext(), parameters));
-
-        return (String) engine.eval(parameter.getFixedValue());
+        return (String) getJSExpressionResult(parameters, null, 
parameter.getFixedValue());
       } catch (Exception e) {
         log.error(e.getMessage(), e);
+        return null;
       }
-      return null;
     } else {
       return parameter.getFixedValue();
     }
   }
+
+  public static Object getJSExpressionResult(Map<String, String> parameters, 
HttpSession session,
+      String expression) throws ScriptException {
+    final ScriptEngineManager manager = new ScriptEngineManager();
+    final ScriptEngine engine = manager.getEngineByName("js");
+
+    if (session != null) {
+      engine.put("OB", new OBBindings(OBContext.getOBContext(), parameters, 
session));
+    } else {
+      engine.put("OB", new OBBindings(OBContext.getOBContext(), parameters));
+    }
+
+    return engine.eval(expression);
+  }
 }
diff -r 9685a3560779 -r 2ec72958bb0f 
modules/org.openbravo.client.application/src/org/openbravo/client/application/FixedValueExpressionCallout.java
--- /dev/null   Thu Jan 01 00:00:00 1970 +0000
+++ 
b/modules/org.openbravo.client.application/src/org/openbravo/client/application/FixedValueExpressionCallout.java
    Mon Dec 13 19:38:46 2010 +0100
@@ -0,0 +1,39 @@
+/*
+ *************************************************************************
+ * The contents of this file are subject to the Openbravo  Public  License
+ * Version  1.1  (the  "License"),  being   the  Mozilla   Public  License
+ * Version 1.1  with a permitted attribution clause; you may not  use this
+ * file except in compliance with the License. You  may  obtain  a copy of
+ * the License at http://www.openbravo.com/legal/license.html
+ * Software distributed under the License  is  distributed  on  an "AS IS"
+ * basis, WITHOUT WARRANTY OF ANY KIND, either express or implied. See the
+ * License for the specific  language  governing  rights  and  limitations
+ * under the License.
+ * The Original Code is Openbravo ERP.
+ * The Initial Developer of the Original Code is Openbravo SLU
+ * All portions are Copyright (C) 2010 Openbravo SLU
+ * All Rights Reserved.
+ * Contributor(s):  ______________________________________.
+ ************************************************************************
+ */
+package org.openbravo.client.application;
+
+import org.openbravo.base.secureApp.VariablesSecureApp;
+
+/**
+ * 
+ * @author gorkaion
+ */
+public class FixedValueExpressionCallout extends JSExpressionCallout {
+
+  private static final long serialVersionUID = 1L;
+
+  @Override
+  protected String getExpression(VariablesSecureApp vars) {
+    String expression = "";
+    if ("Y".equals(vars.getStringParameter("inpevaluatefixedvalue"))) {
+      expression = vars.getStringParameter("inpfixedvalue");
+    }
+    return expression;
+  }
+}
diff -r 9685a3560779 -r 2ec72958bb0f 
modules/org.openbravo.client.application/src/org/openbravo/client/application/JSExpressionCallout.java
--- /dev/null   Thu Jan 01 00:00:00 1970 +0000
+++ 
b/modules/org.openbravo.client.application/src/org/openbravo/client/application/JSExpressionCallout.java
    Mon Dec 13 19:38:46 2010 +0100
@@ -0,0 +1,118 @@
+/*
+ *************************************************************************
+ * The contents of this file are subject to the Openbravo  Public  License
+ * Version  1.1  (the  "License"),  being   the  Mozilla   Public  License
+ * Version 1.1  with a permitted attribution clause; you may not  use this
+ * file except in compliance with the License. You  may  obtain  a copy of
+ * the License at http://www.openbravo.com/legal/license.html
+ * Software distributed under the License  is  distributed  on  an "AS IS"
+ * basis, WITHOUT WARRANTY OF ANY KIND, either express or implied. See the
+ * License for the specific  language  governing  rights  and  limitations
+ * under the License.
+ * The Original Code is Openbravo ERP.
+ * The Initial Developer of the Original Code is Openbravo SLU
+ * All portions are Copyright (C) 2010 Openbravo SLU
+ * All Rights Reserved.
+ * Contributor(s):  ______________________________________.
+ ************************************************************************
+ */
+package org.openbravo.client.application;
+
+import java.io.IOException;
+import java.io.PrintWriter;
+import java.util.Enumeration;
+import java.util.HashMap;
+import java.util.Map;
+
+import javax.servlet.ServletException;
+import javax.servlet.http.HttpServletRequest;
+import javax.servlet.http.HttpServletResponse;
+
+import org.openbravo.base.secureApp.HttpSecureAppServlet;
+import org.openbravo.base.secureApp.VariablesSecureApp;
+import org.openbravo.erpCommon.utility.Utility;
+import org.openbravo.xmlEngine.XmlDocument;
+
+/**
+ * 
+ * @author gorkaion
+ */
+public abstract class JSExpressionCallout extends HttpSecureAppServlet {
+
+  private static final long serialVersionUID = 1L;
+  private static final String CLEAR_MSG_CODE = "['MESSAGE','']";
+  private static final String JS_ERROR_MSG_PREFIX = 
"sun.org.mozilla.javascript.internal.EcmaError:";
+
+  @Override
+  public void doPost(HttpServletRequest request, HttpServletResponse response) 
throws IOException,
+      ServletException {
+
+    VariablesSecureApp vars = new VariablesSecureApp(request);
+
+    if (vars.commandIn("DEFAULT")) {
+      try {
+        printPage(vars, request, response);
+      } catch (ServletException ex) {
+        pageErrorCallOut(response);
+      }
+    } else {
+      pageError(response);
+    }
+  }
+
+  private void printPage(VariablesSecureApp vars, HttpServletRequest request,
+      HttpServletResponse response) throws IOException, ServletException {
+
+    XmlDocument xmlDocument = xmlEngine.readXmlTemplate(
+        "org/openbravo/erpCommon/ad_callouts/CallOut").createXmlDocument();
+
+    xmlDocument.setParameter("array", getResponse(vars, request, 
getExpression(vars)));
+    xmlDocument.setParameter("frameName", "appFrame");
+    response.setContentType("text/html; charset=UTF-8");
+    PrintWriter out = response.getWriter();
+    out.println(xmlDocument.print());
+    out.close();
+  }
+
+  protected abstract String getExpression(VariablesSecureApp vars);
+
+  private String getResponse(VariablesSecureApp vars, HttpServletRequest 
request, String expression)
+      throws ServletException {
+
+    StringBuffer sb = new StringBuffer();
+    sb.append("var 
calloutName='").append(this.getClass().getName()).append("';\n");
+    sb.append("var respuesta = [");

------------------------------------------------------------------------------
Lotusphere 2011
Register now for Lotusphere 2011 and learn how
to connect the dots, take your collaborative environment
to the next level, and enter the era of Social Business.
http://p.sf.net/sfu/lotusphere-d2d
_______________________________________________
Openbravo-commits mailing list
Openbravo-commits@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/openbravo-commits

Reply via email to