    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.services.javascript.JavaScriptSupport;
    016
    017/**
    018 * Interface for any kind of object (typically, a component) that can provide a {@linkplain #getClientId() client-side
    019 * id}, typically used in the generation of client-side (JavaScript) logic. For components, the client id will be null
    020 * or inaccurate until after the component has rendered itself. Inside of any kind of loop, the clientId property is
    021 * only accurate just after the component has rendered, and before it renders again.
    022 *
    023 * Some components must be configured to provide a client id. In many cases, the client id matches the component's
    024 * {@linkplain ComponentResourcesCommon#getId() component id}, typically passed through
    025 * {@link JavaScriptSupport#allocateClientId(String)} to ensure uniqueness.
    026 */
    027public interface ClientElement
    028{
    029    /**
    030     * Returns a unique id for the element. This value will be unique for any given rendering of a page. This value is
    031     * intended for use as the id attribute of the client-side element, and will be used with any DHTML/Ajax related
    032     * JavaScript.
    033     */
    034    String getClientId();
    035}