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

📄 abstractrepeater.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.repeater;import java.util.Iterator;import java.util.regex.Matcher;import java.util.regex.Pattern;import org.apache.wicket.Application;import org.apache.wicket.Component;import org.apache.wicket.markup.MarkupStream;import org.apache.wicket.markup.html.WebMarkupContainer;import org.apache.wicket.model.IModel;import org.slf4j.Logger;import org.slf4j.LoggerFactory;/** * Base class for repeaters. This container renders each of its children using its own markup. *  * The children are collected using {@link #renderIterator()} method. This class will take care of * properly positioning and rewinding its markup stream so before each child renders it points to * the beginning of this component. Each child is rendered by a call to * {@link #renderChild(Component)}. A typical implementation simply does * <code>child.render(getMarkupStream());</code>. *  * @author Igor Vaynberg (ivaynberg) */public abstract class AbstractRepeater extends WebMarkupContainer{	private static final long serialVersionUID = 1L;	private static final Logger log = LoggerFactory.getLogger(AbstractRepeater.class);	private static Pattern SAFE_CHILD_ID_PATTERN = Pattern.compile("^\\d+$");	/**	 * Constructor	 * 	 * @param id	 */	public AbstractRepeater(String id)	{		super(id);	}	/**	 * Constructor	 * 	 * @param id	 * @param model	 */	public AbstractRepeater(String id, IModel model)	{		super(id, model);	}	/**	 * Returns an iterator for the collection of child components to be rendered. Users can override	 * this to change order of rendered children.	 * 	 * @return iterator over child components to be rendered	 */	protected abstract Iterator renderIterator();	/**	 * Renders all child items in no specified order	 * 	 * @param markupStream	 *            The markup stream	 */	protected final void onRender(final MarkupStream markupStream)	{		final int markupStart = markupStream.getCurrentIndex();		Iterator it = renderIterator();		if (it.hasNext())		{			do			{				Component child = (Component)it.next();				if (child == null)				{					throw new IllegalStateException("the render iterator returned null for a child");				}				markupStream.setCurrentIndex(markupStart);				renderChild(child);			}			while (it.hasNext());		}		else		{			markupStream.skipComponent();		}	}	/**	 * Render a single child. This method can be overridden to modify how a single child component	 * is rendered.	 * 	 * @param child	 *            Child component to be rendered	 */	protected void renderChild(final Component child)	{		child.render(getMarkupStream());	}	/**	 * @see org.apache.wicket.Component#onBeforeRender()	 */	protected void onBeforeRender()	{		onPopulate();		if (Application.get().getConfigurationType().equals(Application.DEVELOPMENT))		{			Iterator i = iterator();			while (i.hasNext())			{				Component c = (Component)i.next();				Matcher matcher = SAFE_CHILD_ID_PATTERN.matcher(c.getId());				if (!matcher.matches())				{					log.warn("Child component of repeater " + getClass().getName() + ":" + getId() +							" has a non-safe child id of " + c.getId() +							". Safe child ids must be composed of digits only.");					// do not flood the log					break;				}			}		}		super.onBeforeRender();	}	/**	 * Callback to let the repeater know it should populate itself with its items.	 */	protected abstract void onPopulate();}

⌨️ 快捷键说明

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