KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > apache > beehive > netui > pageflow > PreviousPageInfo


1 /*
2  * Copyright 2004 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.pageflow;
19
20 import org.apache.struts.action.ActionMapping;
21 import org.apache.struts.action.ActionForm;
22 import org.apache.struts.action.ActionForward;
23 import org.apache.struts.config.ModuleConfig;
24
25 import java.io.Serializable JavaDoc;
26
27 /**
28  * Stores information about a previously-displayed page, as well as its initialization data.
29  * Used with
30  * <code>navigateTo={@link org.apache.beehive.netui.pageflow.annotations.Jpf.NavigateTo#currentPage Jpf.NavigateTo.currentPage}</code>
31  * or <code>navigateTo={@link org.apache.beehive.netui.pageflow.annotations.Jpf.NavigateTo#previousPage Jpf.NavigateTo.previousPage}</code>
32  * on {@link org.apache.beehive.netui.pageflow.annotations.Jpf.Forward Jpf.Forward},
33  * {@link org.apache.beehive.netui.pageflow.annotations.Jpf.SimpleAction Jpf.SimpleAction}, or
34  * {@link org.apache.beehive.netui.pageflow.annotations.Jpf.ConditionalForward Jpf.ConditionalForward}.
35  */

36 public class PreviousPageInfo
37         extends PreviousInfo
38         implements Serializable JavaDoc
39 {
40     private ActionForward _forward;
41     private String JavaDoc _mappingPath;
42     private transient ActionMapping _mapping;
43     private Object JavaDoc _clientState;
44
45     
46     /**
47      * Constructor which accepts the ActionForward used to display the page, the ActionForm
48      * used to initialize the page, and the associated ActionMapping, which represents the
49      * action that forwarded to the page.
50      *
51      * @param forward the ActionForward that contains the path to the page.
52      * @param form the form that was present for the page when it was rendered initially.
53      * @param mapping the ActionMapping associated with the action that forwarded to the page, or <code>null</code>
54      * if the page was requested directly.
55      * @param queryString the query string from the request URI.
56      */

57     public PreviousPageInfo( ActionForward forward, ActionForm form, ActionMapping mapping, String JavaDoc queryString )
58     {
59         super( form, queryString );
60         _mapping = mapping;
61         _mappingPath = mapping != null ? mapping.getPath() : null;
62         _forward = forward;
63     }
64
65     /**
66      * Get information about the action that forwarded to the page.
67      * <br>
68      * <br>
69      * Note that this information is transient. If you place this object in the session, and then retrieve it after
70      * a session failover has occurred (i.e., after this object has been serialized and deserialized), then this method
71      * will return <code>null</code> unless you first call {@link #reinitialize}.
72      *
73      * @return an ActionMapping that contains information about the action that forwarded to this page, or
74      * <code>null</code> if the page was requested directly.
75      */

76     public ActionMapping getMapping()
77     {
78         return _mapping;
79     }
80
81     /**
82      * Set information about the action that forwarded to the page.
83      *
84      * @param mapping an ActionMapping that contains information about the action that forwarded to this page.
85      */

86     public void setMapping( ActionMapping mapping )
87     {
88         _mapping = mapping;
89     }
90
91     /**
92      * Reinitialize the stored ActionMapping and PageFlowController objects. These are transient, and will be lost if
93      * you place this object in the session, and then retrieve it after a session failover has occurred (i.e., after
94      * this object has been serialized and deserialized).
95      */

96     public void reinitialize( PageFlowController pfc )
97     {
98         if ( _mapping == null && _mappingPath != null )
99         {
100             ModuleConfig mc = pfc.getModuleConfig();
101             assert mc != null : "no ModuleConfig found for " + pfc.getClass().getName();
102             _mapping = ( ActionMapping ) mc.findActionConfig( _mappingPath );
103         }
104         
105         if ( _forward != null && _forward instanceof Forward )
106         {
107             ( ( Forward ) _forward ).reinitialize( pfc );
108         }
109     }
110     
111     /**
112      * Get the object that was used to forward to the page.
113      *
114      * @return the ActionForward returned by the action that forwarded to this page.
115      */

116     public ActionForward getForward()
117     {
118         return _forward;
119     }
120
121     /**
122      * Set the object that was used to forward to the page.
123      *
124      * @param forward the ActionForward returned by the action that forwarded to this page.
125      */

126     public void setForward( ActionForward forward )
127     {
128         _forward = forward;
129     }
130
131     /**
132      * Get client state associated with the page (e.g., component tree state for a JSF page).
133      */

134     public Object JavaDoc getClientState()
135     {
136         return _clientState;
137     }
138
139     /**
140      * Set client state associated with the page (e.g., component tree state for a JSF page).
141      */

142     public void setClientState( Object JavaDoc clientState )
143     {
144         _clientState = clientState;
145     }
146 }
147
Popular Tags