001: /*
002: * Licensed to the Apache Software Foundation (ASF) under one or more
003: * contributor license agreements. See the NOTICE file distributed with
004: * this work for additional information regarding copyright ownership.
005: * The ASF licenses this file to You under the Apache License, Version 2.0
006: * (the "License"); you may not use this file except in compliance with
007: * the License. You may obtain a copy of the License at
008: *
009: * http://www.apache.org/licenses/LICENSE-2.0
010: *
011: * Unless required by applicable law or agreed to in writing, software
012: * distributed under the License is distributed on an "AS IS" BASIS,
013: * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
014: * See the License for the specific language governing permissions and
015: * limitations under the License.
016: *
017: * $Header:$
018: */
019: package org.apache.beehive.netui.pageflow;
020:
021: import org.apache.struts.action.ActionMapping;
022: import org.apache.struts.action.ActionForm;
023: import org.apache.struts.action.ActionForward;
024: import org.apache.struts.config.ModuleConfig;
025:
026: import java.io.Serializable;
027:
028: /**
029: * Stores information about a previously-displayed page, as well as its initialization data.
030: * Used with
031: * <code>navigateTo={@link org.apache.beehive.netui.pageflow.annotations.Jpf.NavigateTo#currentPage Jpf.NavigateTo.currentPage}</code>
032: * or <code>navigateTo={@link org.apache.beehive.netui.pageflow.annotations.Jpf.NavigateTo#previousPage Jpf.NavigateTo.previousPage}</code>
033: * on {@link org.apache.beehive.netui.pageflow.annotations.Jpf.Forward Jpf.Forward},
034: * {@link org.apache.beehive.netui.pageflow.annotations.Jpf.SimpleAction Jpf.SimpleAction}, or
035: * {@link org.apache.beehive.netui.pageflow.annotations.Jpf.ConditionalForward Jpf.ConditionalForward}.
036: */
037: public class PreviousPageInfo extends PreviousInfo implements
038: Serializable {
039: private ActionForward _forward;
040: private String _mappingPath;
041: private transient ActionMapping _mapping;
042: private Object _clientState;
043:
044: /**
045: * Constructor which accepts the ActionForward used to display the page, the ActionForm
046: * used to initialize the page, and the associated ActionMapping, which represents the
047: * action that forwarded to the page.
048: *
049: * @param forward the ActionForward that contains the path to the page.
050: * @param form the form that was present for the page when it was rendered initially.
051: * @param mapping the ActionMapping associated with the action that forwarded to the page, or <code>null</code>
052: * if the page was requested directly.
053: * @param queryString the query string from the request URI.
054: */
055: public PreviousPageInfo(ActionForward forward, ActionForm form,
056: ActionMapping mapping, String queryString) {
057: super (form, queryString);
058: _mapping = mapping;
059: _mappingPath = mapping != null ? mapping.getPath() : null;
060: _forward = forward;
061: }
062:
063: /**
064: * Get information about the action that forwarded to the page.
065: * <br>
066: * <br>
067: * Note that this information is transient. If you place this object in the session, and then retrieve it after
068: * a session failover has occurred (i.e., after this object has been serialized and deserialized), then this method
069: * will return <code>null</code> unless you first call {@link #reinitialize}.
070: *
071: * @return an ActionMapping that contains information about the action that forwarded to this page, or
072: * <code>null</code> if the page was requested directly.
073: */
074: public ActionMapping getMapping() {
075: return _mapping;
076: }
077:
078: /**
079: * Set information about the action that forwarded to the page.
080: *
081: * @param mapping an ActionMapping that contains information about the action that forwarded to this page.
082: */
083: public void setMapping(ActionMapping mapping) {
084: _mapping = mapping;
085: }
086:
087: /**
088: * Reinitialize the stored ActionMapping and PageFlowController objects. These are transient, and will be lost if
089: * you place this object in the session, and then retrieve it after a session failover has occurred (i.e., after
090: * this object has been serialized and deserialized).
091: */
092: public void reinitialize(PageFlowController pfc) {
093: if (_mapping == null && _mappingPath != null) {
094: ModuleConfig mc = pfc.getModuleConfig();
095: assert mc != null : "no ModuleConfig found for "
096: + pfc.getClass().getName();
097: _mapping = (ActionMapping) mc
098: .findActionConfig(_mappingPath);
099: }
100:
101: if (_forward != null && _forward instanceof Forward) {
102: ((Forward) _forward).reinitialize(pfc);
103: }
104: }
105:
106: /**
107: * Get the object that was used to forward to the page.
108: *
109: * @return the ActionForward returned by the action that forwarded to this page.
110: */
111: public ActionForward getForward() {
112: return _forward;
113: }
114:
115: /**
116: * Set the object that was used to forward to the page.
117: *
118: * @param forward the ActionForward returned by the action that forwarded to this page.
119: */
120: public void setForward(ActionForward forward) {
121: _forward = forward;
122: }
123:
124: /**
125: * Get client state associated with the page (e.g., component tree state for a JSF page).
126: */
127: public Object getClientState() {
128: return _clientState;
129: }
130:
131: /**
132: * Set client state associated with the page (e.g., component tree state for a JSF page).
133: */
134: public void setClientState(Object clientState) {
135: _clientState = clientState;
136: }
137: }
|