001// Licensed under the Apache License, Version 2.0 (the "License");
002// you may not use this file except in compliance with the License.
003// You may obtain a copy of the License at
004//
005// http://www.apache.org/licenses/LICENSE-2.0
006//
007// Unless required by applicable law or agreed to in writing, software
008// distributed under the License is distributed on an "AS IS" BASIS,
009// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
010// See the License for the specific language governing permissions and
011// limitations under the License.
012
013package org.apache.tapestry5.internal.services;
014
015import org.apache.tapestry5.Link;
016import org.apache.tapestry5.internal.structure.Page;
017import org.apache.tapestry5.ioc.annotations.UsesOrderedConfiguration;
018import org.apache.tapestry5.services.LinkCreationHub;
019import org.apache.tapestry5.services.LinkCreationListener2;
020
021/**
022 * A source for {@link org.apache.tapestry5.Link} objects.
023 *
024 * @see org.apache.tapestry5.services.LinkCreationListener2
025 * @since 5.1.0.0
026 */
027@UsesOrderedConfiguration(LinkCreationListener2.class)
028public interface LinkSource
029{
030    /**
031     * Creates a stateful action link. Action links are built for components. Action links are encoded by the current
032     * request (that is, bound to the current request's session, if any).
033     *
034     * @param page
035     *         the page holding the component
036     * @param nestedId
037     *         the component's qualified id (a sequence of simple ids, separated by dots).
038     * @param eventType
039     *         the type of event to trigger
040     * @param forForm
041     *         true if the link is for a form, false otherwise
042     * @param context
043     *         Additional path data, each value will be converted to a string and appended to the URI @return a
044     *         link
045     * @see org.apache.tapestry5.ComponentResources#createEventLink(String, Object...)
046     */
047    Link createComponentEventLink(Page page, String nestedId, String eventType, boolean forForm, Object... context);
048
049    /**
050     * Creates a render link for the page. If an activation context is supplied then that context is built into the URI.
051     * If no activation context is supplied, then the activation context is obtained from the page itself, by triggering
052     * a passivate event on its root component.
053     *
054     * When the activationContext is an empty array, the targeted page is checked to see if it can provide an activation
055     * context. This is accomplished by triggering a "passivate" event on the targeted page. If the override parameter
056     * is true, this will not occur (even when the activation context is empty).
057     *
058     * @param pageName
059     *         name of the page to which a link should be created
060     * @param override
061     *         if true, then the provided activation context is always used even if empty
062     * @param pageActivationContext
063     *         the activation context for the page
064     * @return a link
065     * @see org.apache.tapestry5.services.PageRenderLinkSource#createPageRenderLink(String)
066     * @see org.apache.tapestry5.services.PageRenderLinkSource#createPageRenderLinkWithContext(String, Object[])
067     */
068    Link createPageRenderLink(String pageName, boolean override, Object... pageActivationContext);
069
070    /**
071     * Returns the hub, used to register and de-register {@link org.apache.tapestry5.services.LinkCreationListener2}s.
072     *
073     * @return the hub
074     */
075    LinkCreationHub getLinkCreationHub();
076}