View Javadoc

1   // 
2   // Copyright (c) 2003, Caltha - Gajda, Krzewski, Mach, Potempski Sp.J. 
3   // All rights reserved. 
4   // 
5   // Redistribution and use in source and binary forms, with or without modification,  
6   // are permitted provided that the following conditions are met: 
7   //  
8   // * Redistributions of source code must retain the above copyright notice,  
9   //   this list of conditions and the following disclaimer. 
10  // * Redistributions in binary form must reproduce the above copyright notice,  
11  //   this list of conditions and the following disclaimer in the documentation  
12  //   and/or other materials provided with the distribution. 
13  // * Neither the name of the Caltha - Gajda, Krzewski, Mach, Potempski Sp.J.  
14  //   nor the names of its contributors may be used to endorse or promote products  
15  //   derived from this software without specific prior written permission. 
16  // 
17  // THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"  
18  // AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED  
19  // WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. 
20  // IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT,  
21  // INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,  
22  // BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, 
23  // OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,  
24  // WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)  
25  // ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE  
26  // POSSIBILITY OF SUCH DAMAGE. 
27  // 
28  
29  package org.objectledge.web.mvc;
30  
31  import org.objectledge.context.Context;
32  
33  /***
34   * The web context contains all needed information about mvc processing parameters.
35   *
36   * @author <a href="mailto:pablo@caltha.pl">Pawel Potempski</a>
37   * @author <a href="mailto:dgajda@caltha.pl">Damian Gajda</a>
38   * @version $Id: MVCContext.java,v 1.12 2005/05/06 09:31:13 rafal Exp $
39   */
40  public class MVCContext
41  {
42  	/***
43  	 *  Usefull method to retrieve http context from context.
44  	 *
45  	 * @param context the context.
46  	 * @return the http context.
47  	 */
48  	public static MVCContext getMVCContext(Context context)
49  	{
50  		return (MVCContext)context.getAttribute(MVCContext.class);
51  	}
52  
53      /*** request parameters used to override params. */ 
54      //private RequestParameters requestParameters;
55      
56  	/*** the action parameter. */
57  	private String action;
58  
59  	/*** the view parameter. */
60  	private String view;
61  
62  	/*** the view build result */
63  	private String buildResult;
64  
65      /*** the current processing stage. */
66      private ProcessingStage stage = ProcessingStage.PROCESSING;
67  
68  	/***
69  	 * Construct new pipeline context.
70  	 */
71  	public MVCContext()
72  	{
73          // TODO: Decide whether the parameters should be overriden setView/setAction ???
74          //RequestParameters requestParameters
75  	    //this.requestParameters = requestParameters;
76          // This would be nice to have setAction method removed
77  	}
78  	
79      /***
80       * Returns the action paremeter.
81       * 
82       * @return the value of action parameter.
83       */
84  	public String getAction()
85  	{
86  		return action;
87  	}
88  
89      /***
90       * Sets the action parameter.
91       *
92       * @param action the action parameter.
93       */
94  	public void setAction(String action)
95  	{
96  		this.action = action;
97  	}
98  
99      /***
100      * Returns the view paremeter.
101      *
102      * @return the value of view parameter.
103      */
104 	public String getView()
105 	{
106 		return view;
107 	}
108 
109     /***
110      * Sets the view parameter.
111      *
112      * @param view the view parameter.
113      */
114 	public void setView(String view)
115 	{
116 		this.view = view;
117 	}
118 	
119     /***
120      * Gets the result of building the view part of MVC pipeline.
121      * 
122      * @return the result of building the MVC view
123      */
124     public String getBuildResult()
125     {
126         return buildResult;
127     }
128 
129     /***
130      * Sets the result of building the view part of MVC pipeline.
131      * 
132      * @param buildResult a string representing built view which should be sent to the browser
133      */
134     public void setBuildResult(String buildResult)
135     {
136     	this.buildResult = buildResult;
137     }
138 
139     /***
140      * Returns the processing stage.
141      *
142      * @return the stage.
143      */
144     public ProcessingStage getStage()
145     {
146         return stage;
147     }
148 
149     /***
150      * Sets the processing stage.
151      *
152      * @param stage The stage to set.
153      */
154     public void setStage(ProcessingStage stage)
155     {
156         this.stage = stage;
157     }
158 }