📄 repeatingview.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 org.apache.wicket.Component;import org.apache.wicket.model.IModel;/** * <p> * A repeater view that renders all of its children, using its body markup, in the order they were * added. * * </p> * Example: * <p> * <u>Java:</u> * * <pre> * RepeatingView view = new RepeatingView("repeater"); * view.add(new Label("1", "hello")); * view.add(new Label("2", "goodbye")); * view.add(new Label("3", "good morning")); * </pre> * * </p> * <p> * <u>Markup:</u> * * <pre> * <ul><li wicket:id="repeater"></li></ul> * </pre> * * </p> * <p> * <u>Yields:</u> * * <pre> * <ul><li>hello</li><li>goodbye</li><li>good morning</li></ul> * </pre> * * To expand a bit: the repeater itself produces no markup, instead every direct child inherits the * entire markup of the repeater. In the example above reeaters's markup is: * * <pre> * <li wicket:id="repeater"></li> * </pre> * * and so this is the markup that is available to the direct children - the Label components. So as * each label renders it produces a line of the output that has the <code>li</code>tag. * * * @author Igor Vaynberg ( ivaynberg ) * */public class RepeatingView extends AbstractRepeater{ /** * */ private static final long serialVersionUID = 1L; /** Counter used for generating unique child component ids. */ private long childIdCounter = 0; /** @see Component#Component(String) */ public RepeatingView(String id) { super(id); } /** @see Component#Component(String, IModel) */ public RepeatingView(String id, IModel model) { super(id, model); } /** * Generates a unique id string. This makes it easy to add items to be rendered w/out having to * worry about generating unique id strings in your code. * * @return unique child id */ public String newChildId() { childIdCounter++; if (childIdCounter == Long.MAX_VALUE) { // mmm yeah...like this will ever happen throw new RuntimeException("generateChildId() out of space."); } // We prepend the id's with the text 'id' so they will generate valid // markup id's if needed. return String.valueOf(childIdCounter); } /** * @see org.apache.wicket.markup.repeater.AbstractRepeater#renderIterator() */ protected Iterator renderIterator() { return iterator(); } /** * @see org.apache.wicket.markup.repeater.AbstractRepeater#onPopulate() */ protected void onPopulate() { // noop - population of this repeater is manual }}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -