⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 enclosure.java

📁 Wicket一个开发Java Web应用程序框架。它使得开发web应用程序变得容易而轻松。 Wicket利用一个POJO data beans组件使得它可以与任何持久层技术相结合。
💻 JAVA
字号:
/* * Licensed to the Apache Software Foundation (ASF) under one or more * contributor license agreements.  See the NOTICE file distributed with * this work for additional information regarding copyright ownership. * The ASF licenses this file to You under the Apache License, Version 2.0 * (the "License"); you may not use this file except in compliance with * the License.  You may obtain a copy of the License at * *      http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */package org.apache.wicket.markup.html.internal;import org.apache.wicket.Component;import org.apache.wicket.MarkupContainer;import org.apache.wicket.WicketRuntimeException;import org.apache.wicket.markup.ComponentTag;import org.apache.wicket.markup.MarkupException;import org.apache.wicket.markup.MarkupStream;import org.apache.wicket.markup.html.WebMarkupContainer;import org.apache.wicket.markup.html.border.Border;import org.apache.wicket.markup.html.border.Border.BorderBodyContainer;import org.apache.wicket.markup.parser.filter.EnclosureHandler;import org.apache.wicket.markup.resolver.EnclosureResolver;import org.slf4j.Logger;import org.slf4j.LoggerFactory;/** * An Enclosure are automatically created by Wicket. Do not create it yourself. An Enclosure * container is created if &lt;wicket:enclosure&gt; is found in the markup. It is meant to solve the * following situation. Instead of *  * <pre> *    &lt;table wicket:id=&quot;label-container&quot; class=&quot;notify&quot;&gt;&lt;tr&gt;&lt;td&gt;&lt;span wicket:id=&quot;label&quot;&gt;[[notification]]&lt;/span&gt;&lt;/td&gt;&lt;/tr&gt;&lt;/table&gt;  *   *    WebMarkupContainer container=new WebMarkupContainer(&quot;label-container&quot;)  *    { *       public boolean isVisible()  *       { *           return hasNotification(); *       } *    }; *    add(container); *     container.add(new Label(&quot;label&quot;, notificationModel));  * </pre> *  * with Enclosure you are able to do the following: *  * <pre> *    &lt;wicket:enclosure&gt;  *      &lt;table class=&quot;notify&quot;&gt;&lt;tr&gt;&lt;td&gt;&lt;span wicket:id=&quot;label&quot;&gt;[[notification]]&lt;/span&gt;&lt;/td&gt;&lt;/tr&gt;&lt;/table&gt; *    &lt;/wicket:enclosure&gt; *  *    add(new Label(&quot;label&quot;, notificationModel))  *    { *       public boolean isVisible()  *       { *           return hasNotification(); *       } *    } * </pre> *  * @see EnclosureResolver * @see EnclosureHandler *  * @author Juergen Donnerstag * @since 1.3 */public class Enclosure extends WebMarkupContainer{	private static final long serialVersionUID = 1L;	private static final Logger log = LoggerFactory.getLogger(Enclosure.class);	/** The child component to delegate the isVisible() call to */	private Component childComponent;	/** Id of the child component that will control visibility of the enclosure */	private final CharSequence childId;	/**	 * Construct.	 * 	 * @param id	 * @param childId	 */	public Enclosure(final String id, final CharSequence childId)	{		super(id);		this.childId = childId;	}	/**	 * 	 * @see org.apache.wicket.MarkupContainer#isTransparentResolver()	 */	public boolean isTransparentResolver()	{		return true;	}	/**	 * 	 * @param childId	 * @return Child Component	 */	private Component getChildComponent(final CharSequence childId)	{		MarkupContainer parent = getParent();		while (parent != null)		{			if (parent.isTransparentResolver())			{				parent = parent.getParent();			}			else if (parent instanceof BorderBodyContainer)			{				parent = ((BorderBodyContainer)parent).findParent(Border.class);			}			else			{				break;			}		}		if (parent == null)		{			throw new WicketRuntimeException(				"Unable to find parent component which is not a transparent resolver");		}		if (childId == null)		{			throw new MarkupException(				"You most likely forgot to register the EnclosureHandler with the MarkupParserFactory");		}		final Component child = parent.get(childId.toString());		if (child == null)		{			throw new MarkupException(				"Didn't find child component of <wicket:enclosure> with id='" + childId +					"'. Component: " + this.toString());		}		return child;	}	/**	 * 	 * @see org.apache.wicket.MarkupContainer#onComponentTagBody(org.apache.wicket.markup.MarkupStream,	 *      org.apache.wicket.markup.ComponentTag)	 */	protected void onComponentTagBody(MarkupStream markupStream, ComponentTag openTag)	{		if (childComponent == null)		{			childComponent = getChildComponent(childId);		}		if (childComponent == this)		{			throw new WicketRuntimeException(				"Programming error: childComponent == enclose component; endless loop");		}		else if (childComponent != null)		{			// Delegate to child component			setVisible(childComponent.isVisible() && childComponent.isRenderAllowed());		}		if (isVisible() == true)		{			super.onComponentTagBody(markupStream, openTag);		}		else		{			markupStream.skipToMatchingCloseTag(openTag);		}	}}

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -