KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > apache > webapp > admin > TreeControlTestAction


1 /*
2  * Copyright 2001,2004 The Apache Software Foundation.
3  *
4  * Licensed under the Apache License, Version 2.0 (the "License");
5  * you may not use this file except in compliance with the License.
6  * You may obtain a copy of the License at
7  *
8  * http://www.apache.org/licenses/LICENSE-2.0
9  *
10  * Unless required by applicable law or agreed to in writing, software
11  * distributed under the License is distributed on an "AS IS" BASIS,
12  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13  * See the License for the specific language governing permissions and
14  * limitations under the License.
15  */

16
17
18 package org.apache.webapp.admin;
19
20
21 import java.io.IOException JavaDoc;
22 import java.util.Iterator JavaDoc;
23 import java.util.List JavaDoc;
24 import java.util.Locale JavaDoc;
25 import java.net.URLDecoder JavaDoc;
26 import javax.servlet.ServletException JavaDoc;
27 import javax.servlet.http.HttpServletRequest JavaDoc;
28 import javax.servlet.http.HttpServletResponse JavaDoc;
29 import javax.servlet.http.HttpSession JavaDoc;
30 import org.apache.struts.action.Action;
31 import org.apache.struts.action.ActionErrors;
32 import org.apache.struts.action.ActionForm;
33 import org.apache.struts.action.ActionForward;
34 import org.apache.struts.action.ActionMapping;
35
36
37 /**
38  * Test <code>Action</code> that handles events from the tree control test
39  * page.
40  *
41  * @author Craig R. McClanahan
42  * @version $Revision: 1.3 $ $Date: 2004/10/18 06:37:53 $
43  */

44
45 public class TreeControlTestAction extends Action {
46
47
48     // --------------------------------------------------------- Public Methods
49

50
51     /**
52      * Process the specified HTTP request, and create the corresponding HTTP
53      * response (or forward to another web component that will create it).
54      * Return an <code>ActionForward</code> instance describing where and how
55      * control should be forwarded, or <code>null</code> if the response has
56      * already been completed.
57      *
58      * @param mapping The ActionMapping used to select this instance
59      * @param actionForm The optional ActionForm bean for this request (if any)
60      * @param request The HTTP request we are processing
61      * @param response The HTTP response we are creating
62      *
63      * @exception IOException if an input/output error occurs
64      * @exception ServletException if a servlet exception occurs
65      */

66     public ActionForward execute(ActionMapping mapping,
67                                  ActionForm form,
68                                  HttpServletRequest JavaDoc request,
69                                  HttpServletResponse JavaDoc response)
70         throws IOException JavaDoc, ServletException JavaDoc {
71
72         getServlet().log("Entered TreeControlTestAction:perform()");
73
74         String JavaDoc name = null;
75         HttpSession JavaDoc session = request.getSession();
76         TreeControl control =
77             (TreeControl) session.getAttribute("treeControlTest");
78
79         // Handle a tree expand/contract event
80
name = request.getParameter("tree");
81
82         if (name != null) {
83             getServlet().log("Tree expand/contract on " + name);
84
85             TreeControlNode node = control.findNode(name);
86
87             if (node != null){
88                 getServlet().log("Found Node: " + name);
89                 node.setExpanded(!node.isExpanded());
90             }
91         }else{
92             getServlet().log("tree param is null");
93         }
94
95         // Handle a select item event
96
name = request.getParameter("select");
97         if (name != null) {
98             getServlet().log("Select event on " + name);
99             control.selectNode(name);
100         }
101
102         // Forward back to the test page
103
return (mapping.findForward("Tree Control Test"));
104
105     }
106
107
108 }
109
Popular Tags