001/*
002 * Licensed to the Apache Software Foundation (ASF) under one or more
003 * contributor license agreements.  See the NOTICE file distributed with
004 * this work for additional information regarding copyright ownership.
005 * The ASF licenses this file to You under the Apache License, Version 2.0
006 * (the "License"); you may not use this file except in compliance with
007 * the License.  You may obtain a copy of the License at
008 *
009 *      http://www.apache.org/licenses/LICENSE-2.0
010 *
011 * Unless required by applicable law or agreed to in writing, software
012 * distributed under the License is distributed on an "AS IS" BASIS,
013 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
014 * See the License for the specific language governing permissions and
015 * limitations under the License.
016 */
017package org.apache.wicket.markup.html.internal;
018
019import org.apache.wicket.markup.ComponentTag;
020import org.apache.wicket.markup.parser.filter.InlineEnclosureHandler;
021
022
023/**
024 * An InlineEnclosure are automatically created by Wicket. Do not create it yourself. An
025 * InlineEnclosure container is created when <tr wicket:enclosure="controllingChildId"> (any
026 * html tag which can contain other html tags can be used in place of <tr>) is found in the
027 * markup. The child component (it's id defined as the value of the attribute, in the example,
028 * 'controllingChildId') controls the visibility of the whole enclosure and it's children. This also
029 * works in Ajax calls without extra markup or java code.
030 * 
031 * @see InlineEnclosureHandler
032 * 
033 * @author Joonas Hamalainen
034 * @author Juergen Donnerstag
035 */
036public class InlineEnclosure extends Enclosure
037{
038        private static final long serialVersionUID = 1L;
039
040        /**
041         * Construct.
042         * 
043         * @param id The component id
044         * @param childId The id of the child component that controls the visibility
045         */
046        public InlineEnclosure(final String id, final String childId)
047        {
048                super(id, childId);
049
050                // ensure that the Enclosure is ready for ajax updates
051                setOutputMarkupPlaceholderTag(true);
052        }
053
054        @Override
055        protected void onComponentTag(final ComponentTag tag)
056        {
057                // remove the wicket:enclosure attribute
058                tag.remove(InlineEnclosureHandler.INLINE_ENCLOSURE_ATTRIBUTE_NAME);
059
060                super.onComponentTag(tag);
061        }
062}