01: /**********************************************************************************
02: * $URL: https://source.sakaiproject.org/svn/msgcntr/trunk/messageforums-app/src/java/org/sakaiproject/tool/messageforums/jsf/MessageForumsNavigationHandler.java $
03: * $Id: MessageForumsNavigationHandler.java 9227 2006-05-15 15:02:42Z cwen@iupui.edu $
04: ***********************************************************************************
05: *
06: * Copyright (c) 2003, 2004, 2005, 2006 The Sakai Foundation.
07: *
08: * Licensed under the Educational Community License, Version 1.0 (the "License");
09: * you may not use this file except in compliance with the License.
10: * You may obtain a copy of the License at
11: *
12: * http://www.opensource.org/licenses/ecl1.php
13: *
14: * Unless required by applicable law or agreed to in writing, software
15: * distributed under the License is distributed on an "AS IS" BASIS,
16: * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
17: * See the License for the specific language governing permissions and
18: * limitations under the License.
19: *
20: **********************************************************************************/package org.sakaiproject.tool.messageforums.jsf;
21:
22: import javax.faces.application.NavigationHandler;
23: import javax.faces.context.ExternalContext;
24: import javax.faces.context.FacesContext;
25: import javax.servlet.http.HttpSession;
26:
27: /**
28: * <p>
29: * SakaiNavigationHandler catches the response that is being redirected to preserve the faces messages for the return request.
30: * </p>
31: *
32: */
33: public class MessageForumsNavigationHandler extends NavigationHandler {
34: /** The other navigation handler. */
35: protected NavigationHandler m_chain = null;
36:
37: /**
38: * Construct.
39: */
40: public MessageForumsNavigationHandler() {
41: }
42:
43: /**
44: * Construct.
45: */
46: public MessageForumsNavigationHandler(NavigationHandler chain) {
47: m_chain = chain;
48: }
49:
50: /**
51: * Handle the navigation
52: *
53: * @param context
54: * The Faces context.
55: * @param fromAction
56: * The action string that triggered the action.
57: * @param outcome
58: * The logical outcome string, which is the new tool mode, or if null, the mode does not change.
59: */
60: public void handleNavigation(FacesContext context,
61: String fromAction, String outcome) {
62: m_chain.handleNavigation(context, fromAction, outcome);
63:
64: ExternalContext exContext = context.getExternalContext();
65: HttpSession session = (HttpSession) exContext.getSession(false);
66:
67: if (session == null) {
68: return;
69: }
70:
71: // add previous navigationString (outcome) to session
72: session.setAttribute("MC_PREVIOUS_NAV", outcome);
73: }
74: }
|