svn commit: r1300469 - in /ofbiz/trunk/framework/common: script/org/ofbiz/common/JavaScriptTest.js servicedef/services_test.xml

Previous Topic Next Topic
 
classic Classic list List threaded Threaded
1 message Options
Reply | Threaded
Open this post in threaded view
|

svn commit: r1300469 - in /ofbiz/trunk/framework/common: script/org/ofbiz/common/JavaScriptTest.js servicedef/services_test.xml

adrianc
Author: adrianc
Date: Wed Mar 14 06:40:55 2012
New Revision: 1300469

URL: http://svn.apache.org/viewvc?rev=1300469&view=rev
Log:
Improved JavaScriptTest.js file:

1. Fixed reference to application-level entity.
2. Made the behavior of the test function different from the behavior of global code - so the distinctions are clear in the service results.

Modified:
    ofbiz/trunk/framework/common/script/org/ofbiz/common/JavaScriptTest.js
    ofbiz/trunk/framework/common/servicedef/services_test.xml

Modified: ofbiz/trunk/framework/common/script/org/ofbiz/common/JavaScriptTest.js
URL: http://svn.apache.org/viewvc/ofbiz/trunk/framework/common/script/org/ofbiz/common/JavaScriptTest.js?rev=1300469&r1=1300468&r2=1300469&view=diff
==============================================================================
--- ofbiz/trunk/framework/common/script/org/ofbiz/common/JavaScriptTest.js (original)
+++ ofbiz/trunk/framework/common/script/org/ofbiz/common/JavaScriptTest.js Wed Mar 14 06:40:55 2012
@@ -26,23 +26,27 @@ if (message) {
 }
 
 if (ofbiz) {
-    var partyValue = ofbiz.findOne("PartyNameView");
-    if (partyValue) {
-        var foundMessage = ofbiz.evalString(" Found Party ${partyValue.groupName}${partyValue.firstName} ${partyValue.lastName}");
+    var exampleValue = ofbiz.findOne("Example");
+    if (exampleValue) {
+        var foundMessage = ofbiz.evalString(" Found Example ${exampleValue.exampleName}");
         successMessage = successMessage + foundMessage;
         ofbiz.logInfo(successMessage);
     } else {
-        ofbiz.logInfo("Party not found with partyId ${parameters.partyId}");
+        var notFoundMessage = ofbiz.evalString(" Example not found with exampleId ${parameters.exampleId}");
+        successMessage = successMessage + notFoundMessage;
+        ofbiz.logInfo(successMessage);
     }
 }
 
 function testFunction(context) {
-    if (message) {
-        var successMessage = "Got message [" + message + "] and finished fine";
-        var result = message;
+    var messageArg = context.get("message");
+    if (messageArg) {
+        context.put("successMessage", "Function 'testFunction' got message [" + messageArg + "] and finished fine");
+        var functionResult = "testFunction: " + messageArg;
     } else {
-        var successMessage = "Got no message but finished fine anyway";
-        var result = "[no message received]";
+        context.put("successMessage", "Function 'testFunction' got no message but finished fine anyway");
+        var functionResult = "testFunction: no message received";
     }
-    return result;
+    // The function's result must be set explicitly in the context Map
+    context.put("result", functionResult);
 }

Modified: ofbiz/trunk/framework/common/servicedef/services_test.xml
URL: http://svn.apache.org/viewvc/ofbiz/trunk/framework/common/servicedef/services_test.xml?rev=1300469&r1=1300468&r2=1300469&view=diff
==============================================================================
--- ofbiz/trunk/framework/common/servicedef/services_test.xml (original)
+++ ofbiz/trunk/framework/common/servicedef/services_test.xml Wed Mar 14 06:40:55 2012
@@ -199,7 +199,7 @@ under the License.
     <service name="testScriptEngineJavaScript" engine="script" location="component://common/script/org/ofbiz/common/JavaScriptTest.js" invoke="">
         <description>Test Script Engine With JavaScript</description>
         <attribute name="message" type="String" mode="IN" optional="true"/>
-        <attribute name="partyId" type="String" mode="IN" optional="true"/>
+        <attribute name="exampleId" type="String" mode="IN" optional="true"/>
         <attribute name="result" type="String" mode="OUT"/>
     </service>