KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > tutorial > pagetypes > Home


1 // Copyright 2004 The Apache Software Foundation
2
//
3
// Licensed under the Apache License, Version 2.0 (the "License");
4
// you may not use this file except in compliance with the License.
5
// You may obtain a copy of the License at
6
//
7
// http://www.apache.org/licenses/LICENSE-2.0
8
//
9
// Unless required by applicable law or agreed to in writing, software
10
// distributed under the License is distributed on an "AS IS" BASIS,
11
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12
// See the License for the specific language governing permissions and
13
// limitations under the License.
14

15 package tutorial.pagetypes;
16
17 import net.sf.tapestry.html.BasePage;
18 import net.sf.tapestry.IRequestCycle;
19 import net.sf.tapestry.RequestCycleException;
20 import net.sf.tapestry.StaleSessionException;
21 import net.sf.tapestry.StaleLinkException;
22 import org.apache.log4j.Logger;
23
24 import javax.swing.*;
25
26 /**
27  * @version $Id: Home.java,v 1.3 2003/01/13 03:33:40 hlship Exp $
28  * @author Neil Clayton
29  *
30  **/

31 public class Home extends BasePage {
32     public void niceExceptionPage(IRequestCycle cycle) throws RequestCycleException {
33         // This will cause the NewException page to be shown, due to the overrides
34
// we have placed in the Engine used in this example
35
throw new RequestCycleException("This exception is intentionally thrown by the link handler",
36                 this,
37                 new MyException("this is an intentional runtime exception"));
38     }
39
40     public void forceStaleSession(IRequestCycle cycle) throws RequestCycleException {
41         log.warn("throwing stale session exception");
42         throw new StaleSessionException("The session has expired", getPage());
43     }
44
45     public void forceStaleLink(IRequestCycle cycle) throws RequestCycleException {
46         log.warn("throwing stale link exception");
47         throw new StaleLinkException("This link is STALE!", this);
48     }
49
50     public void forceException(IRequestCycle cycle) throws RequestCycleException {
51         log.warn("throwing some other exception");
52         throw new RequestCycleException("This exception is intentionally thrown by the link handler",
53                 this,
54                 new RuntimeException JavaDoc("this is an intentional runtime exception"));
55     }
56
57     private static final Logger log = Logger.getLogger(Home.class);
58 }
Popular Tags