1 61 62 package org.objectweb.jonas.webapp.jonasadmin; 63 64 import java.io.IOException ; 65 import java.net.URLEncoder ; 66 67 import javax.servlet.ServletException ; 68 import javax.servlet.http.HttpServletRequest ; 69 import javax.servlet.http.HttpServletResponse ; 70 import javax.servlet.http.HttpSession ; 71 72 import org.apache.struts.action.Action; 73 import org.apache.struts.action.ActionForm; 74 import org.apache.struts.action.ActionForward; 75 import org.apache.struts.action.ActionMapping; 76 import org.objectweb.jonas.common.Log; 77 import org.objectweb.jonas.webapp.taglib.TreeControl; 78 import org.objectweb.jonas.webapp.taglib.TreeControlNode; 79 import org.objectweb.util.monolog.api.BasicLevel; 80 import org.objectweb.util.monolog.api.Logger; 81 82 89 90 public class TreeAction extends Action { 91 92 private static Logger logger = Log.getLogger(Log.JONAS_ADMIN_PREFIX); 93 94 96 111 public ActionForward execute(ActionMapping mapping, ActionForm form, HttpServletRequest request 112 , HttpServletResponse response) 113 throws IOException , ServletException { 114 115 String name = null; 116 HttpSession session = request.getSession(); 117 WhereAreYou oWhere = (WhereAreYou) session.getAttribute(WhereAreYou.SESSION_NAME); 118 if (oWhere == null) { 120 if (logger.isLoggable(BasicLevel.DEBUG)) { 123 logger.log(BasicLevel.DEBUG, "Instance WhereAreYou not found in session : re-init"); 124 } 125 return (mapping.findForward("Main Index")); 126 } 127 TreeControl control = oWhere.getTreeControl(); 129 name = request.getParameter("tree"); 131 if (name != null) { 132 if (logger.isLoggable(BasicLevel.DEBUG)) { 134 logger.log(BasicLevel.DEBUG, "Tree expand/contract on " + name); 135 } 136 TreeControlNode node = control.findNode(name); 137 if (node != null) { 138 if (logger.isLoggable(BasicLevel.DEBUG)) { 140 logger.log(BasicLevel.DEBUG, "Found Node: " + name + "[" + node.getLabel() + "]"); 141 } 142 node.setExpanded(!node.isExpanded()); 143 request.setAttribute("anchorToGo", URLEncoder.encode(name, "UTF-8")); 145 } 146 } 147 else { 148 if (logger.isLoggable(BasicLevel.DEBUG)) { 150 logger.log(BasicLevel.DEBUG, "tree param is null"); 151 } 152 } 153 154 name = request.getParameter("select"); 156 if (name != null) { 157 if (logger.isLoggable(BasicLevel.DEBUG)) { 159 logger.log(BasicLevel.DEBUG, "Select event on " + name); 160 } 161 control.selectNode(name); 162 request.setAttribute("anchorToGo", URLEncoder.encode(name, "UTF-8")); 164 } 165 166 return (mapping.findForward("Tree")); 168 } 169 } 170 | Popular Tags |