KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > info > jtrac > web > FlowControllerHandlerInterceptor


1 /*
2  * Copyright 2002-2005 the original author or authors.
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 package info.jtrac.web;
18
19 import javax.servlet.http.HttpServletRequest JavaDoc;
20 import javax.servlet.http.HttpServletResponse JavaDoc;
21 import org.apache.commons.logging.Log;
22 import org.apache.commons.logging.LogFactory;
23 import org.springframework.web.servlet.ModelAndView;
24 import org.springframework.web.servlet.handler.HandlerInterceptorAdapter;
25 import org.springframework.webflow.executor.mvc.FlowController;
26
27 /**
28  * custom HandlerInterceptor that is only interested in post processing the
29  * Spring Web Flow "flowController" handling of the request
30  * works in conjunction with the FlowExceptionResolver
31  */

32 public class FlowControllerHandlerInterceptor extends HandlerInterceptorAdapter {
33     
34     protected final Log logger = LogFactory.getLog(getClass());
35     
36     @Override JavaDoc
37     public void postHandle(HttpServletRequest JavaDoc request, HttpServletResponse JavaDoc response, Object JavaDoc handler, ModelAndView modelAndView) {
38         if (handler.getClass().equals(FlowController.class)) {
39             Object JavaDoc flowExecutionKey = modelAndView.getModel().get("flowExecutionKey");
40             request.getSession().setAttribute("lastRequestParameterMap", request.getParameterMap());
41             request.getSession().setAttribute("lastFlowExecutionKey", flowExecutionKey);
42             if (logger.isDebugEnabled()) {
43                 logger.debug("lastFlowExecutionKey session attribute set as: " + flowExecutionKey);
44             }
45         }
46     }
47
48
49 }
50
Popular Tags