    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;
    014
    015import org.apache.tapestry5.http.Link;
    016import org.apache.tapestry5.internal.InternalConstants;
    017import org.apache.tapestry5.ioc.util.IdAllocator;
    018import org.apache.tapestry5.services.ComponentEventRequestParameters;
    019import org.apache.tapestry5.services.ComponentSource;
    020import org.apache.tapestry5.services.PageRenderRequestParameters;
    021
    022/**
    023 * Constant values for common event names fired by Tapestry components.
    024 */
    025public class EventConstants
    026{
    027    /**
    028     * Default client event name, "action", used in most situations.
    029     */
    030    public static final String ACTION = "action";
    031
    032    /**
    033     * Event triggered when a page is activated (for rendering). The component event handler will be
    034     * passed the context
    035     * provided by the passivate event.
    036     */
    037    public static final String ACTIVATE = "activate";
    038
    039    /**
    040     * Event triggered when a link for a page is generated. The event handler for the page may
    041     * provide an object, or an
    042     * array of objects, as the context for the page. These values will become part of the page's
    043     * context, and will be
    044     * provided back when the page is activated.
    045     */
    046    public static final String PASSIVATE = "passivate";
    047
    048    /**
    049     * Invoked before {@link #PREPARE} when rendering out the form.
    050     *
    051     * @see org.apache.tapestry5.corelib.components.Form
    052     */
    053    public static final String PREPARE_FOR_RENDER = "prepareForRender";
    054
    055    /**
    056     * Invoked before {@link #PREPARE} when the form is submitted.
    057     *
    058     * @see org.apache.tapestry5.corelib.components.Form
    059     */
    060    public static final String PREPARE_FOR_SUBMIT = "prepareForSubmit";
    061
    062    /**
    063     * Invoked to let the containing component(s) prepare for the form rendering or the form
    064     * submission.
    065     *
    066     * @see org.apache.tapestry5.corelib.components.Form
    067     */
    068    public static final String PREPARE = "prepare";
    069
    070    /**
    071     * Event type for a notification after the form has submitted. This event notification occurs on
    072     * any form submit,
    073     * without respect to "success" or "failure".
    074     *
    075     * @see org.apache.tapestry5.corelib.components.Form
    076     */
    077    public static final String SUBMIT = "submit";
    078
    079    /**
    080     * Event triggered when a client-side form is canceled. This occurs after page activation, and after
    081     * the prepare events for the form, but before any stored {@link ComponentAction}s for the form are triggered.
    082     *
    083     * @see org.apache.tapestry5.corelib.SubmitMode#CANCEL
    084     *
    085     * @since 5.2.0
    086     */
    087    public static final String CANCELED = "canceled";
    088
    089    /**
    090     * Event type for a notification after the form has submitted, when there are no errors in the
    091     * validation tracker.
    092     * This occurs before the {@link #SUBMIT} event.
    093     *
    094     * @see org.apache.tapestry5.corelib.components.Form
    095     */
    096    public static final String SUCCESS = "success";
    097
    098    /**
    099     * Event type for a notification after the form has been submitted, when there are errors in the
    100     * validation tracker.
    101     * This occurs before the {@link #SUBMIT} event.
    102     */
    103    public static final String FAILURE = "failure";
    104
    105    /**
    106     * Event type triggered by the {@link org.apache.tapestry5.corelib.components.Submit} component
    107     * when it is the cause
    108     * of the form submission.
    109     */
    110    public static final String SELECTED = "selected";
    111
    112    /**
    113     * Event triggered by some form-related components to parse a value provided by the client. This
    114     * takes the place of a {@link org.apache.tapestry5.Translator}.
    115     */
    116    public static final String PARSE_CLIENT = "parseClient";
    117
    118    /**
    119     * Event triggered by some form-related components to convert a server-side value to a
    120     * client-side string, as an
    121     * alternative to a {@link org.apache.tapestry5.Translator}.
    122     */
    123    public static final String TO_CLIENT = "toClient";
    124
    125    /**
    126     * Event triggered by form-related components to validate user input. In addition, the Form component
    127     * fires a validate event just before it fires {@link #SUCCESS} or {@link #FAILURE} as a chance
    128     * to perform cross-form validations.
    129     */
    130    public static final String VALIDATE = "validate";
    131
    132    /**
    133     * Event triggered by {@link org.apache.tapestry5.corelib.components.AjaxFormLoop} to inform the
    134     * container about the
    135     * row removed on the client side. The event context is the object that was removed.
    136     */
    137    public static final String REMOVE_ROW = "removeRow";
    138
    139    /**
    140     * Event triggered by {@link org.apache.tapestry5.corelib.components.AjaxFormLoop} to inform the
    141     * container that a new row has been requested. The return value from the event handler must be the newly created
    142     * object, which must
    143     * also be visible in the {@link org.apache.tapestry5.corelib.components.AjaxFormLoop#encoder} parameter.
    144     */
    145    public static final String ADD_ROW = "addRow";
    146
    147    /**
    148     * Event triggered by the {@link org.apache.tapestry5.corelib.components.Loop} component to
    149     * inform its container of
    150     * all the values that were supplied from the client during a form submission. The event handler
    151     * method should have
    152     * a single parameter, of type Object[] or type List, to receive the values.
    153     *
    154     * @since 5.1.0.0
    155     */
    156    public static final String SYNCHRONIZE_VALUES = "synchronizeValues";
    157
    158    /**
    159     * Event triggered by {@link org.apache.tapestry5.corelib.components.ProgressiveDisplay} component to inform its
    160     * container of what context (if any) is available. The event handler may return a renderable
    161     * object or null. If
    162     * null is returned, the component renders its own body as the partial markup response.
    163     *
    164     * @since 5.1.0.1
    165     */
    166    public static final String PROGRESSIVE_DISPLAY = "progressiveDisplay";
    167
    168    /**
    169     * Event triggered by an {@link org.apache.tapestry5.corelib.mixins.Autocomplete} mixin to
    170     * request completions of
    171     * the current input. The first value in the context is the input string; additional values
    172     * in the context parameter of the {@link org.apache.tapestry5.corelib.mixins.Autocomplete}
    173     * component.
    174     *
    175     * @since 5.1.0.4
    176     */
    177    public static final String PROVIDE_COMPLETIONS = "provideCompletions";
    178
    179    /**
    180     * Event triggered by {@link org.apache.tapestry5.corelib.components.Select} component to inform
    181     * its
    182     * container that Select's value has changed.
    183     *
    184     * @since 5.2.0
    185     */
    186    public static final String VALUE_CHANGED = "valueChanged";
    187
    188    /**
    189     * Event triggered during page render link generation. The first context parameter is the {@link Link} object, the
    190     * second is the {@link PageRenderRequestParameters} from which the Link
    191     * was created. The event is triggered on the actively rendering page.
    192     *
    193     * @since 5.2.0
    194     */
    195    public static final String DECORATE_PAGE_RENDER_LINK = "decoratePageRenderLink";
    196
    197    /**
    198     * Event triggered during component event link generation. The first context parameter is the {@link Link} object,
    199     * the second is the {@link ComponentEventRequestParameters} from which the Link
    200     * was created. The event is triggered on the actively rendering page, not necessarily the page
    201     * containing the component.
    202     *
    203     * @since 5.2.0
    204     */
    205    public static final String DECORATE_COMPONENT_EVENT_LINK = "decorateComponentEventLink";
    206
    207    /**
    208     * Name of a event triggered by the form component on the {@linkplain ComponentSource#getActivePage() active page}
    209     * to allow it to pre-allocate the names of any query parameters that might be used by the page for its own purposes
    210     * and should not be allocated to components. An {@link IdAllocator} is passed as the event context.
    211     *
    212     * @since 5.2.0
    213     */
    214    public static final String PREALLOCATE_FORM_CONTROL_NAMES = "preallocateFormControlNames";
    215
    216    /**
    217     * Event triggered by the {@link org.apache.tapestry5.corelib.components.Tree}
    218     * component when a leaf node is selected.
    219     *
    220     * @since 5.3
    221     */
    222    public static final String NODE_SELECTED = "nodeSelected";
    223
    224    /**
    225     * Event triggered by the {@link org.apache.tapestry5.corelib.components.Tree}
    226     * component when a leaf node is unselected.
    227     *
    228     * @since 5.3
    229     */
    230    public static final String NODE_UNSELECTED = "nodeUnselected";
    231
    232    /**
    233     * Event triggered by {@link org.apache.tapestry5.corelib.mixins.ZoneRefresh ZoneRefresh} to refresh the
    234     * {@link org.apache.tapestry5.corelib.components.Zone Zone}
    235     *
    236     * @since 5.3
    237     */
    238    public static final String REFRESH = "refresh";
    239
    240    /**
    241     * Event triggered when a page receives an HTTP GET request.
    242     * Handling this event creates a REST endpoint.
    243     * @since 5.8.0
    244     */
    245    public static final String HTTP_GET = InternalConstants.HTTP_METHOD_EVENT_PREFIX + "Get";
    246
    247    /**
    248     * Event triggered when a page receives an HTTP POST request.
    249     * Handling this event creates a REST endpoint.
    250     * @since 5.8.0
    251     */
    252    public static final String HTTP_POST = InternalConstants.HTTP_METHOD_EVENT_PREFIX + "Post";
    253
    254    /**
    255     * Event triggered when a page receives an HTTP DELETE request.
    256     * Handling this event creates a REST endpoint.
    257     * @since 5.8.0
    258     */
    259    public static final String HTTP_DELETE = InternalConstants.HTTP_METHOD_EVENT_PREFIX + "Delete";
    260
    261    /**
    262     * Event triggered when a page receives an HTTP PUT request.
    263     * Handling this event creates a REST endpoint.
    264     * @since 5.8.0
    265     */
    266    public static final String HTTP_PUT = InternalConstants.HTTP_METHOD_EVENT_PREFIX + "Put";
    267
    268    /**
    269     * Event triggered when a page receives an HTTP HEAD request.
    270     * Handling this event creates a REST endpoint.
    271     * @since 5.8.0
    272     */
    273    public static final String HTTP_HEAD = InternalConstants.HTTP_METHOD_EVENT_PREFIX + "Head";
    274
    275    /**
    276     * Event triggered when a page receives an HTTP PATCH request.
    277     * Handling this event creates a REST endpoint.
    278     * @since 5.8.0
    279     */
    280    public static final String HTTP_PATCH = InternalConstants.HTTP_METHOD_EVENT_PREFIX + "Patch";
    281
    282}