01: /*
02: * Licensed to the Apache Software Foundation (ASF) under one or more
03: * contributor license agreements. See the NOTICE file distributed with
04: * this work for additional information regarding copyright ownership.
05: * The ASF licenses this file to You under the Apache License, Version 2.0
06: * (the "License"); you may not use this file except in compliance with
07: * the License. You may obtain a copy of the License at
08: *
09: * http://www.apache.org/licenses/LICENSE-2.0
10: *
11: * Unless required by applicable law or agreed to in writing, software
12: * distributed under the License is distributed on an "AS IS" BASIS,
13: * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14: * See the License for the specific language governing permissions and
15: * limitations under the License.
16: */
17: package org.apache.jetspeed.container.state.impl;
18:
19: import org.apache.jetspeed.cache.JetspeedContentCache;
20: import org.apache.jetspeed.container.PageHistoryValve;
21: import org.apache.jetspeed.request.RequestContext;
22:
23: /**
24: * SessionFullClearOnChangePageNavigationalState, stores all nav parameters in the session, including render parameters
25: *
26: * @author <a href="mailto:kmoh.raj@gmail.com">Mohan Kannapareddy</a>
27: * @version $Id$
28: */
29:
30: public class SessionFullExtendedNavigationalState extends
31: SessionFullNavigationalState {
32: private boolean clearStateOnPageChangeEnabled = false;
33:
34: public SessionFullExtendedNavigationalState(
35: NavigationalStateCodec codec, JetspeedContentCache cache) {
36: super (codec, cache);
37: }
38:
39: public SessionFullExtendedNavigationalState(
40: NavigationalStateCodec codec, JetspeedContentCache cache,
41: JetspeedContentCache decorationCache) {
42: super (codec, cache, decorationCache);
43: }
44:
45: public SessionFullExtendedNavigationalState(
46: NavigationalStateCodec codec, JetspeedContentCache cache,
47: JetspeedContentCache decorationCache,
48: boolean clearStateOnPageChangeEnabled) {
49: super (codec, cache, decorationCache);
50: this .clearStateOnPageChangeEnabled = clearStateOnPageChangeEnabled;
51: }
52:
53: protected boolean clearPagePortletsModeAndWindowState(
54: RequestContext context) {
55: String contextKey = PageHistoryValve.REQUEST_CLEAR_PORTLETS_MODE_AND_WINDOWSTATE_KEY;
56: boolean result = false;
57: if (clearStateOnPageChangeEnabled) {
58: Boolean pageNavigationEvent = (Boolean) context
59: .getAttribute(contextKey);
60: if ((pageNavigationEvent != null)) {
61: result = pageNavigationEvent.booleanValue();
62: }
63: }
64: //Just to be safe make it false
65: context.setAttribute(contextKey, Boolean.FALSE);
66:
67: return result;
68: }
69:
70: public synchronized void sync(RequestContext context) {
71: // JS2-806, check the session for a psuedo inter page navigation.
72: boolean resetPagePortlets = false;
73: if (clearStateOnPageChangeEnabled) {
74: resetPagePortlets = clearPagePortletsModeAndWindowState(context);
75: if (log.isDebugEnabled()) {
76: log.debug("resetPagePortlets:" + resetPagePortlets);
77: }
78: }
79:
80: // push the informaion up to SessionNavigationalState, so that we can handle it appropriately there
81: setClearPortletsModeAndWindowStateEnabled(resetPagePortlets);
82: //Inform the super
83: super.sync(context);
84: }
85: }
|