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