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

📄 radiogroup.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.form;import org.apache.wicket.Component;import org.apache.wicket.WicketRuntimeException;import org.apache.wicket.markup.ComponentTag;import org.apache.wicket.markup.html.WebMarkupContainer;import org.apache.wicket.model.IModel;import org.apache.wicket.util.convert.ConversionException;/** * Component used to connect instances of Radio components into a group. Instances of Radio have to * be in the component hierarchy somewhere below the group component. The model object of the group * is set to the model object of the selected radio component or null if none selected. *  * ie *  * <pre> *    &lt;span wicket:id=&quot;radiochoicegroup&quot;&gt; *      ... *      &lt;input type=&quot;radio&quot; wicket:id=&quot;singleradiochoice1&quot;&gt;choice 1&lt;/input&gt; *      ... *      &lt;input type=&quot;radio&quot; wicket:id=&quot;singleradiochoice2&quot;&gt;choice 2&lt;/input&gt; *      ... *    &lt;/span&gt; * </pre> *  * @author Igor Vaynberg * @author Sven Meier (svenmeier) *  */public class RadioGroup extends FormComponent implements IOnChangeListener{	private static final long serialVersionUID = 1L;	/**	 * @see WebMarkupContainer#WebMarkupContainer(String)	 */	public RadioGroup(String id)	{		super(id);		setRenderBodyOnly(true);	}	/**	 * @see WebMarkupContainer#WebMarkupContainer(String, IModel)	 */	public RadioGroup(String id, IModel model)	{		super(id, model);		setRenderBodyOnly(true);	}	protected boolean wantOnSelectionChangedNotifications()	{		return false;	}	/**	 * @see org.apache.wicket.MarkupContainer#getStatelessHint()	 */	protected boolean getStatelessHint()	{		if (wantOnSelectionChangedNotifications())		{			return false;		}		return super.getStatelessHint();	}	/**	 * @see org.apache.wicket.markup.html.form.FormComponent#convertValue(String[])	 */	protected Object convertValue(String[] input) throws ConversionException	{		if (input != null && input.length > 0)		{			final String value = input[0];			// retrieve the selected single radio choice component			Radio choice = (Radio)visitChildren(new Component.IVisitor()			{				public Object component(Component component)				{					if (component instanceof Radio)					{						final Radio radio = (Radio)component;						if (radio.getValue().equals(value))						{							return radio;						}					}					return CONTINUE_TRAVERSAL;				}			});			if (choice == null)			{				throw new WicketRuntimeException(						"submitted http post value [" +								value +								"] for RadioGroup component [" +								getPath() +								"] is illegal because it does not contain relative path to a Radio componnet. " +								"Due to this the RadioGroup component cannot resolve the selected Radio component pointed to by the illegal value. A possible reason is that componment hierarchy changed between rendering and form submission.");			}			// assign the value of the group's model			return choice.getModelObject();		}		return null;	}	/**	 * @see org.apache.wicket.markup.html.form.FormComponent#onComponentTag(org.apache.wicket.markup.ComponentTag)	 */	protected void onComponentTag(ComponentTag tag)	{		super.onComponentTag(tag);		// No longer applicable, breaks XHTML validation.		tag.remove("disabled");		tag.remove("name");	}	/**	 * Called when a selection changes.	 */	public final void onSelectionChanged()	{		convertInput();		updateModel();		onSelectionChanged(getModelObject());	}	/**	 * Template method that can be overridsen by clients that implement IOnChangeListener to be	 * notified by onChange events of a select element. This method does nothing by default.	 * <p>	 * Called when a option is selected of a dropdown list that wants to be notified of this event.	 * This method is to be implemented by clients that want to be notified of selection events.	 * 	 * @param newSelection	 *            The newly selected object of the backing model NOTE this is the same as you would	 *            get by calling getModelObject() if the new selection were current	 */	protected void onSelectionChanged(final Object newSelection)	{	}	/**	 * Radio group does not support persistence through cookies	 * 	 * @see org.apache.wicket.markup.html.form.FormComponent#supportsPersistence()	 */	protected final boolean supportsPersistence()	{		return false;	}}

⌨️ 快捷键说明

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