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.corelib.mixins; 014 015import org.apache.tapestry5.ClientElement; 016import org.apache.tapestry5.annotations.AfterRender; 017import org.apache.tapestry5.annotations.InjectContainer; 018 019/** 020 * Forces a client element to render its client id by ensuring that 021 * {@link org.apache.tapestry5.ClientElement#getClientId() ClientElement#getClientId()} 022 * is called. This is sometimes needed because, by design, most components (those that 023 * implement {@link ClientElement}) only render a client-side ID if their getClientId 024 * method is called sometime during the server-side DOM render. 025 * 026 * See the {@link org.apache.tapestry5.corelib.components.Any Any} component 027 * for an example of use. 028 * 029 * @tapestrydoc 030 */ 031public class RenderClientId 032{ 033 @InjectContainer 034 private ClientElement element; 035 036 @AfterRender 037 void ensureId() 038 { 039 element.getClientId(); 040 } 041}