001    // Copyright 2005 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.tapestry.form;
016    
017    import org.apache.tapestry.FormBehavior;
018    import org.apache.tapestry.IForm;
019    import org.apache.tapestry.IRender;
020    import org.apache.tapestry.engine.ILink;
021    
022    /**
023     * Interface for a utility object that encapsulates the majority of the
024     * {@link org.apache.tapestry.form.Form}'s behavior.
025     * 
026     * @author Howard M. Lewis Ship
027     * @since 4.0
028     */
029    public interface FormSupport extends FormBehavior
030    {
031    
032        /**
033         * Invoked when the form is rendering. This should only be invoked by the {@link Form}
034         * component.
035         * 
036         * @param method
037         *            the HTTP method ("get" or "post")
038         * @param informalParametersRenderer
039         *            object that will render informal parameters
040         * @param link
041         *            The link to which the form will submit (encapsulating the URL and the query
042         *            parameters)
043         * @param scheme
044         *            the desired scheme for the generated URL, typically "http" or "https". If
045         *            non-null, and the scheme does not match the current request's scheme, then an
046         *            absolute URL with the specified scheme will be generated, rather than a URI.
047         * @param port
048         *            the desired port for the generated URL, typically "80", "443". If
049         *            non-null, and the port does not match the current request's port, then an
050         *            absolute URL with the specified port will be generated, rather than a URI.
051         */
052        void render(String method, IRender informalParametersRenderer, ILink link, String scheme, Integer port);
053    
054        /**
055         * Invoked to rewind the form, which renders the body of the form, allowing form element
056         * components to pull data from the request and update page properties. This should only be
057         * invoked by the {@link Form} component.
058         * 
059         * @return a code indicating why the form was submitted: {@link FormConstants#SUBMIT_NORMAL},
060         *         {@link FormConstants#SUBMIT_CANCEL} or {@link FormConstants#SUBMIT_REFRESH}.
061         */
062        String rewind();
063        
064        /**
065         * Gets a reference to the previously stored {@link IForm}.
066         * @return The form this object is managing/supporting.
067         * @since 4.1
068         */
069        IForm getForm();
070    }