    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
    015/**
    016 * Due to how control names and client ids are allocated inside during an Ajax request, it is difficult to
    017 * to connect input data and field validation errors to the fields, since the control name and client id are different
    018 * during the processing of the submitted form data and during the subsequent render. Starting in 5.4, the
    019 * key used to identify a field inside the {@link org.apache.tapestry5.ValidationTracker is this new validation id,
    020 * which is assigned on first read.
    021 * <p/>
    022 * If a field inplements {@link org.apache.tapestry5.Field} but not Field2, then the control name is used as the
    023 * validation id (which will work correctly during non-Ajax requests).
    024 * <p/>
    025 * This assumes a "flat" field structure, where a given component renders only once (not multiple times, inside
    026 * a {@link org.apache.tapestry5.corelib.components.Loop}.
    027 *
    028 * @since 5.4
    029 */
    030public interface Field2 extends Field
    031{
    032    /**
    033     * Returns a request-scoped unique validation id for the field. This returns the same value regardless of how
    034     * many times the field is rendered, which means that the behavior will be incorrect when the
    035     * field component is placed inside a loop.
    036     */
    037    String getValidationId();
    038}