KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > apache > beehive > netui > tags > divpanel > DivPanelCRI


1 /*
2  * Copyright 2005 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  * $Header:$
17  */

18 package org.apache.beehive.netui.tags.divpanel;
19
20 import org.apache.beehive.netui.pageflow.interceptor.InterceptorChain;
21 import org.apache.beehive.netui.pageflow.interceptor.InterceptorException;
22 import org.apache.beehive.netui.pageflow.interceptor.request.RequestInterceptorContext;
23 import org.apache.beehive.netui.pageflow.requeststate.INameable;
24 import org.apache.beehive.netui.pageflow.requeststate.NameService;
25 import org.apache.beehive.netui.tags.AbstractClientRequestInterceptor;
26
27 import javax.servlet.http.HttpServletRequest JavaDoc;
28
29 public class DivPanelCRI extends AbstractClientRequestInterceptor
30 {
31     private static final String JavaDoc SWITCH_PAGE = "switchPage";
32
33     public void preRequest(RequestInterceptorContext ctxt, InterceptorChain chain)
34     {
35         HttpServletRequest JavaDoc request = ctxt.getRequest();
36
37         // Create the command by striping off the context path and the extension
38
String JavaDoc uri = request.getRequestURI();
39         String JavaDoc ctxtPath = request.getContextPath();
40
41         String JavaDoc cmd = getCommand(uri, ctxtPath);
42
43
44         // check to see if we handle this command
45
if (SWITCH_PAGE.equals(cmd)) {
46             handlePageSwitch(request);
47         }
48
49     }
50
51     private void handlePageSwitch(HttpServletRequest JavaDoc req)
52     {
53         String JavaDoc dp = req.getParameter("divPanel");
54         String JavaDoc fp = req.getParameter("firstPage");
55         //System.err.println("DivPanel Command: switch, DivPanel:" + dp + " Node:" + fp);
56

57         NameService ns = NameService.instance(req.getSession());
58         assert(ns != null);
59
60         // get the tree from the name service
61
INameable n = ns.get(dp);
62         if (n == null) {
63             System.err.println("DivPanel '" + dp + "' was not found in the NameService");
64             return;
65         }
66         if (!(n instanceof DivPanelState)) {
67             System.err.println("Named dp was not an instance of a DivPanelState");
68             return;
69         }
70
71         DivPanelState state = (DivPanelState) n;
72         state.setFirstPage(fp);
73     }
74
75     public void postRequest(RequestInterceptorContext context, InterceptorChain chain) throws InterceptorException
76     {
77         chain.continueChain();
78     }
79 }
80
Popular Tags