1
22
23 package com.liferay.portal.action;
24
25 import com.liferay.portal.kernel.util.Constants;
26 import com.liferay.portal.kernel.util.ParamUtil;
27 import com.liferay.portal.kernel.util.StringUtil;
28 import com.liferay.portal.struts.ActionConstants;
29 import com.liferay.portal.util.SessionTreeJSClicks;
30
31 import javax.servlet.http.HttpServletRequest;
32 import javax.servlet.http.HttpServletResponse;
33 import javax.servlet.jsp.PageContext;
34
35 import org.apache.struts.action.Action;
36 import org.apache.struts.action.ActionForm;
37 import org.apache.struts.action.ActionForward;
38 import org.apache.struts.action.ActionMapping;
39
40
46 public class SessionTreeJSClickAction extends Action {
47
48 public ActionForward execute(
49 ActionMapping mapping, ActionForm form, HttpServletRequest req,
50 HttpServletResponse res)
51 throws Exception {
52
53 try {
54 String cmd = ParamUtil.getString(req, Constants.CMD);
55
56 String treeId = ParamUtil.getString(req, "treeId");
57
58 if (cmd.equals("expand")) {
59 String[] nodeIds = StringUtil.split(
60 ParamUtil.getString(req, "nodeIds"));
61
62 SessionTreeJSClicks.openNodes(req, treeId, nodeIds);
63 }
64 else if (cmd.equals("collapse")) {
65 SessionTreeJSClicks.closeNodes(req, treeId);
66 }
67 else {
68 String nodeId = ParamUtil.getString(req, "nodeId");
69 boolean openNode = ParamUtil.getBoolean(req, "openNode");
70
71 if (openNode) {
72 SessionTreeJSClicks.openNode(req, treeId, nodeId);
73 }
74 else {
75 SessionTreeJSClicks.closeNode(req, treeId, nodeId);
76 }
77 }
78
79 return null;
80 }
81 catch (Exception e) {
82 req.setAttribute(PageContext.EXCEPTION, e);
83
84 return mapping.findForward(ActionConstants.COMMON_ERROR);
85 }
86 }
87
88 }