01: package org.apache.turbine.modules.screens.error;
02:
03: /*
04: * Licensed to the Apache Software Foundation (ASF) under one
05: * or more contributor license agreements. See the NOTICE file
06: * distributed with this work for additional information
07: * regarding copyright ownership. The ASF licenses this file
08: * to you under the Apache License, Version 2.0 (the
09: * "License"); you may not use this file except in compliance
10: * with the License. You may obtain a copy of the License at
11: *
12: * http://www.apache.org/licenses/LICENSE-2.0
13: *
14: * Unless required by applicable law or agreed to in writing,
15: * software distributed under the License is distributed on an
16: * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
17: * KIND, either express or implied. See the License for the
18: * specific language governing permissions and limitations
19: * under the License.
20: */
21:
22: import org.apache.ecs.ConcreteElement;
23: import org.apache.ecs.ElementContainer;
24:
25: import org.apache.ecs.html.A;
26:
27: import org.apache.turbine.modules.Screen;
28: import org.apache.turbine.util.RunData;
29: import org.apache.turbine.util.parser.ParameterParser;
30: import org.apache.turbine.util.uri.TurbineURI;
31:
32: /**
33: * Users will get this screen if the screen on their browser is in an
34: * invalid state. For example, if they hit "Back" or "Reload" and
35: * then try to submit old form data.
36: *
37: * If you want one of your screens to check for invalid state
38: * then add a hidden form field called "_session_access_counter"
39: * with the value currently stored in the session. The
40: * SessionValidator action will check to see if it is an old
41: * value and redirect you to this screen.
42: *
43: * @author <a href="mailto:mbryson@mont.mindspring.com">Dave Bryson</a>
44: * @author <a href="mailto:hps@intermeta.de">Henning P. Schmiedehausen</a>
45: * @version $Id: InvalidState.java 534527 2007-05-02 16:10:59Z tv $
46: */
47: public class InvalidState extends Screen {
48: /**
49: * Build the Screen.
50: *
51: * @param data Turbine information.
52: * @exception Exception, a generic exception.
53: */
54: public ConcreteElement doBuild(RunData data) throws Exception {
55: ElementContainer body = new ElementContainer();
56: ElementContainer message = new ElementContainer();
57:
58: StringBuffer sb = new StringBuffer();
59: sb
60: .append("<b>There has been an error.</b>")
61: .append("<p>")
62: .append(
63: "- If you used the browser \"Back\" or \"Reload\"")
64: .append(
65: " buttons please use the navigation buttons we provide")
66: .append(" within the screen.").append("<p>").append(
67: "Please click ");
68:
69: message.addElement(sb.toString());
70: ParameterParser pp;
71: pp = (ParameterParser) data.getUser()
72: .getTemp("prev_parameters");
73: pp.remove("_session_access_counter");
74:
75: TurbineURI back = new TurbineURI(data, (String) data.getUser()
76: .getTemp("prev_screen"));
77: back.addPathInfo(pp);
78: message.addElement(new A().setHref(back.getRelativeLink())
79: .addElement("here"));
80:
81: message
82: .addElement(" to return the the screen you were working on.");
83:
84: body.addElement(message);
85: return body;
86: }
87: }
|