KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > apache > tapestry > StaleLinkException


1 // Copyright 2004, 2005 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 org.apache.tapestry;
16
17 import org.apache.hivemind.ApplicationRuntimeException;
18
19 /**
20  * Exception thrown by an {@link org.apache.tapestry.engine.IEngineService} when it discovers that
21  * the an action link was for an out-of-date version of the page.
22  *
23  * <p>The application should redirect to the StaleLink page.
24  *
25  *
26  * @author Howard Lewis Ship
27  *
28  **/

29
30 public class StaleLinkException extends ApplicationRuntimeException
31 {
32     private transient IPage _page;
33     private String JavaDoc _pageName;
34     private String JavaDoc _targetIdPath;
35     private String JavaDoc _targetActionId;
36
37     public StaleLinkException()
38     {
39         super(null, null, null, null);
40     }
41
42     /**
43      * Constructor used when the action id is found, but the target id path
44      * did not match the actual id path.
45      *
46      **/

47
48     public StaleLinkException(IComponent component, String JavaDoc targetActionId, String JavaDoc targetIdPath)
49     {
50         super(
51             Tapestry.format(
52                 "StaleLinkException.action-mismatch",
53                 new String JavaDoc[] { targetActionId, component.getIdPath(), targetIdPath }),
54             component,
55             null,
56             null);
57
58         _page = component.getPage();
59         _pageName = _page.getPageName();
60
61         _targetActionId = targetActionId;
62         _targetIdPath = targetIdPath;
63     }
64
65     /**
66      * Constructor used when the target action id is not found.
67      *
68      **/

69
70     public StaleLinkException(IPage page, String JavaDoc targetActionId, String JavaDoc targetIdPath)
71     {
72         this(
73             Tapestry.format(
74                 "StaleLinkException.component-mismatch",
75                 targetActionId,
76                 targetIdPath),
77             page);
78
79         _targetActionId = targetActionId;
80         _targetIdPath = targetIdPath;
81     }
82
83     public StaleLinkException(String JavaDoc message, IComponent component)
84     {
85         super(message, component, null, null);
86     }
87
88
89
90     public String JavaDoc getPageName()
91     {
92         return _pageName;
93     }
94
95     /**
96      * Returns the page referenced by the service URL, if known,
97      * or null otherwise.
98      *
99      **/

100
101     public IPage getPage()
102     {
103         return _page;
104     }
105     
106     public String JavaDoc getTargetActionId()
107     {
108         return _targetActionId;
109     }
110
111     public String JavaDoc getTargetIdPath()
112     {
113         return _targetIdPath;
114     }
115
116 }
Popular Tags