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