svn commit: r1634812 - in /ofbiz/branches/json-integration-refactoring/applications/humanres: src/org/ofbiz/humanres/HumanResEvents.java webapp/humanres/WEB-INF/controller.xml webapp/humanres/humanres/category/CategoryTree.ftl

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

svn commit: r1634812 - in /ofbiz/branches/json-integration-refactoring/applications/humanres: src/org/ofbiz/humanres/HumanResEvents.java webapp/humanres/WEB-INF/controller.xml webapp/humanres/humanres/category/CategoryTree.ftl

jacopoc
Author: jacopoc
Date: Tue Oct 28 08:23:51 2014
New Revision: 1634812

URL: http://svn.apache.org/r1634812
Log:
Refactored Ajax hr tree to use the common request json response rather than a custom method.
This change removes the dependency on a specific JSON library.


Modified:
    ofbiz/branches/json-integration-refactoring/applications/humanres/src/org/ofbiz/humanres/HumanResEvents.java
    ofbiz/branches/json-integration-refactoring/applications/humanres/webapp/humanres/WEB-INF/controller.xml
    ofbiz/branches/json-integration-refactoring/applications/humanres/webapp/humanres/humanres/category/CategoryTree.ftl

Modified: ofbiz/branches/json-integration-refactoring/applications/humanres/src/org/ofbiz/humanres/HumanResEvents.java
URL: http://svn.apache.org/viewvc/ofbiz/branches/json-integration-refactoring/applications/humanres/src/org/ofbiz/humanres/HumanResEvents.java?rev=1634812&r1=1634811&r2=1634812&view=diff
==============================================================================
--- ofbiz/branches/json-integration-refactoring/applications/humanres/src/org/ofbiz/humanres/HumanResEvents.java (original)
+++ ofbiz/branches/json-integration-refactoring/applications/humanres/src/org/ofbiz/humanres/HumanResEvents.java Tue Oct 28 08:23:51 2014
@@ -21,13 +21,13 @@ package org.ofbiz.humanres;
 import java.io.IOException;
 import java.io.UnsupportedEncodingException;
 import java.io.Writer;
+import java.util.ArrayList;
 import java.util.List;
 import java.util.Map;
 
 import javax.servlet.http.HttpServletRequest;
 import javax.servlet.http.HttpServletResponse;
 
-import javolution.util.FastList;
 import javolution.util.FastMap;
 import net.sf.json.JSONObject;
 
@@ -46,7 +46,7 @@ public class HumanResEvents {
     
     // Please note : the structure of map in this function is according to the JSON data map of the jsTree
     @SuppressWarnings("unchecked")
-    public static void getChildHRCategoryTree(HttpServletRequest request, HttpServletResponse response){
+    public static String getChildHRCategoryTree(HttpServletRequest request, HttpServletResponse response){
         Delegator delegator = (Delegator) request.getAttribute("delegator");
         String partyId = request.getParameter("partyId");
         String onclickFunction = request.getParameter("onclickFunction");
@@ -54,7 +54,7 @@ public class HumanResEvents {
         String hrefString = request.getParameter("hrefString");
         String hrefString2 = request.getParameter("hrefString2");
         
-        List categoryList = FastList.newInstance();
+        List categoryList = new ArrayList();
         List<GenericValue> childOfComs;
         //check employee position
         try {
@@ -107,11 +107,11 @@ public class HumanResEvents {
                         
                         categoryList.add(josonMap);
                     }
-                    toJsonObjectList(categoryList,response);
                 }
             }
         } catch (Exception e) {
             e.printStackTrace();
+            return "error";
         }
         
         try {
@@ -235,12 +235,13 @@ public class HumanResEvents {
                         categoryList.add(emplMap);
                     }
                 }
-                
-                toJsonObjectList(categoryList,response);
             }
         } catch (Exception e) {
             e.printStackTrace();
+            return "error";
         }
+        request.setAttribute("hrTree", categoryList);
+        return "success";
     }
     
     @SuppressWarnings("unchecked")

Modified: ofbiz/branches/json-integration-refactoring/applications/humanres/webapp/humanres/WEB-INF/controller.xml
URL: http://svn.apache.org/viewvc/ofbiz/branches/json-integration-refactoring/applications/humanres/webapp/humanres/WEB-INF/controller.xml?rev=1634812&r1=1634811&r2=1634812&view=diff
==============================================================================
--- ofbiz/branches/json-integration-refactoring/applications/humanres/webapp/humanres/WEB-INF/controller.xml (original)
+++ ofbiz/branches/json-integration-refactoring/applications/humanres/webapp/humanres/WEB-INF/controller.xml Tue Oct 28 08:23:51 2014
@@ -1051,7 +1051,8 @@ under the License.
     <request-map uri="getHRChild">
         <security auth="false" https="true"/>
         <event type="java" path="org.ofbiz.humanres.HumanResEvents" invoke="getChildHRCategoryTree"/>
-        <response name="success" type="none"/>
+        <response name="success" type="request" value="json"/>
+        <response name="error" type="request" value="json"/>
     </request-map>
     <request-map uri="createInternalOrg">
         <security https="true" auth="true"/>

Modified: ofbiz/branches/json-integration-refactoring/applications/humanres/webapp/humanres/humanres/category/CategoryTree.ftl
URL: http://svn.apache.org/viewvc/ofbiz/branches/json-integration-refactoring/applications/humanres/webapp/humanres/humanres/category/CategoryTree.ftl?rev=1634812&r1=1634811&r2=1634812&view=diff
==============================================================================
--- ofbiz/branches/json-integration-refactoring/applications/humanres/webapp/humanres/humanres/category/CategoryTree.ftl (original)
+++ ofbiz/branches/json-integration-refactoring/applications/humanres/webapp/humanres/humanres/category/CategoryTree.ftl Tue Oct 28 08:23:51 2014
@@ -69,7 +69,10 @@ var rawdata = [
                                 "hrefString" : "viewprofile?partyId=" ,
                                 "onclickFunction" : "callDocument"
                         };
-                    }
+                    },
+                              success : function(data) {
+                                  return data.hrTree;
+                              }
                 }
             },
             "types" : {