01: // Copyright 2006, 2007 The Apache Software Foundation
02: //
03: // Licensed under the Apache License, Version 2.0 (the "License");
04: // you may not use this file except in compliance with the License.
05: // You may obtain a copy of the License at
06: //
07: // http://www.apache.org/licenses/LICENSE-2.0
08: //
09: // 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.internal.services;
16:
17: import org.apache.tapestry.Link;
18: import org.apache.tapestry.internal.structure.ComponentPageElement;
19: import org.apache.tapestry.internal.structure.Page;
20:
21: /**
22: * A source for {@link Link} objects.
23: *
24: * @see LinkFactoryListener
25: */
26: public interface LinkFactory {
27: /**
28: * Creates a stateful action link. Action links are built for components. Action links are
29: * encoded by the current request (that is, bound to the current request's session, if any).
30: *
31: * @param component
32: * the component for which an action link is to be generated
33: * @param action
34: * a name associated with the action
35: * @param forForm
36: * true if the link is for a form, false otherwise
37: * @param context
38: * Additional path data, each value will be converted to a string and appended to the
39: * URI
40: * @return a link
41: */
42: Link createActionLink(ComponentPageElement component,
43: String action, boolean forForm, Object... context);
44:
45: /**
46: * Creates a render link for the page. If an activation context is supplied then that context is
47: * built into the URI. If no activation context is supplied, then the activation context is
48: * obtained from the page itself, by triggering a passivate event on its root component.
49: * <p>
50: * When the activationContext is an empty array, the targetted page is checked to see if it can
51: * provide an activation context. This is accomplished by triggering a "passivate" event on the
52: * targetted page. If the override parameter is true, this will not occur (even when the
53: * activation context is empty).
54: *
55: * @param page
56: * the page to which a link should be created
57: * @param override
58: * if true, then the provided activation context is always used even if empty
59: * @param activationContext
60: * the activation context for the page
61: * @return
62: */
63: Link createPageLink(Page page, boolean override,
64: Object... activationContext);
65:
66: /**
67: * As with {@link #createPageLink(Page, boolean, Object[])}, but the page is specified by
68: * logical name, rather than as an instance.
69: *
70: * @param page
71: * the logical name of the page to generate a link to
72: * @param override
73: * if true, then the provided activation context is always used even if empty
74: * @param context
75: * activation context for the page
76: * @return
77: */
78: Link createPageLink(String page, boolean override,
79: Object... context);
80:
81: /**
82: * Adds a listener, to be notified any time an action or render link is created; this allows the
83: * listener to modify the link (by adding additional query parameters to the link).
84: *
85: * @param listener
86: */
87: void addListener(LinkFactoryListener listener);
88: }
|