<commit_before>/*
 * 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 wicket.threadtest.apps.app1;

import java.net.MalformedURLException;
import java.net.URL;
import java.util.Arrays;
import java.util.Date;
import java.util.List;
import java.util.Locale;

import wicket.AttributeModifier;
import wicket.markup.html.WebMarkupContainer;
import wicket.markup.html.WebPage;
import wicket.markup.html.basic.Label;
import wicket.markup.html.form.Check;
import wicket.markup.html.form.CheckBox;
import wicket.markup.html.form.CheckGroup;
import wicket.markup.html.form.ChoiceRenderer;
import wicket.markup.html.form.DropDownChoice;
import wicket.markup.html.form.Form;
import wicket.markup.html.form.ImageButton;
import wicket.markup.html.form.ListMultipleChoice;
import wicket.markup.html.form.Radio;
import wicket.markup.html.form.RadioChoice;
import wicket.markup.html.form.RadioGroup;
import wicket.markup.html.form.TextField;
import wicket.markup.html.image.Image;
import wicket.markup.html.link.Link;
import wicket.markup.html.list.ListItem;
import wicket.markup.html.list.ListView;
import wicket.markup.html.panel.FeedbackPanel;
import wicket.markup.html.panel.Panel;
import wicket.markup.repeater.Item;
import wicket.markup.repeater.data.DataView;
import wicket.model.AbstractReadOnlyModel;
import wicket.model.CompoundPropertyModel;
import wicket.model.IModel;
import wicket.model.Model;
import wicket.model.PropertyModel;
import wicket.protocol.http.WebRequest;
import wicket.util.convert.ConversionException;
import wicket.util.convert.IConverter;
import wicket.util.convert.MaskConverter;
import wicket.util.convert.SimpleConverterAdapter;
import wicket.validation.validator.NumberValidator;

public class Home extends WebPage {

	private class ActionPanel extends Panel {
		/**
		 * @param id
		 *            component id
		 * @param model
		 *            model for contact
		 */
		public ActionPanel(String id, IModel model) {
			super(id, model);
			add(new Link("select") {
				public void onClick() {
					Home.this.selected = (Contact) getParent().getModelObject();
				}
			});
		}
	}

	/**
	 * Form for collecting input.
	 */
	private class InputForm extends Form {
		/**
		 * Construct.
		 * 
		 * @param name
		 *            Component name
		 */
		public InputForm(String name) {
			super(name, new CompoundPropertyModel(new FormInputModel()));
			add(new LocaleDropDownChoice("localeSelect"));
			add(new Link("defaultLocaleLink") {
				public void onClick() {
					WebRequest request = (WebRequest) getRequest();
					setLocale(request.getLocale());
				}
			});
			TextField stringTextField = new TextField("stringProperty");
			stringTextField.setLabel(new Model("String"));
			add(stringTextField);
			TextField integerTextField = new TextField("integerProperty", Integer.class);
			add(integerTextField.add(NumberValidator.POSITIVE));
			add(new TextField("doubleProperty", Double.class));
			WebMarkupContainer dateLabel = new WebMarkupContainer("dateLabel");
			add(dateLabel);
			TextField datePropertyTextField = new TextField("dateProperty", Date.class);
			add(datePropertyTextField);
			add(new TextField("integerInRangeProperty", Integer.class).add(NumberValidator.range(0, 100)));
			add(new CheckBox("booleanProperty"));
			RadioChoice rc = new RadioChoice("numberRadioChoice", NUMBERS).setSuffix("");
			rc.setLabel(new Model("number"));
			add(rc);

			RadioGroup group = new RadioGroup("numbersGroup");
			add(group);
			ListView persons = new ListView("numbers", NUMBERS) {
				protected void populateItem(ListItem item) {
					item.add(new Radio("radio", item.getModel()));
					item.add(new Label("number", item.getModelObjectAsString()));
				};
			};
			group.add(persons);

			CheckGroup checks = new CheckGroup("numbersCheckGroup");
			add(checks);
			ListView checksList = new ListView("numbers", NUMBERS) {
				protected void populateItem(ListItem item) {
					item.add(new Check("check", item.getModel()));
					item.add(new Label("number", item.getModelObjectAsString()));
				};
			};
			checks.add(checksList);

			add(new ListMultipleChoice("siteSelection", SITES));

			add(new TextField("urlProperty", URL.class) {
				public IConverter getConverter(Class clazz) {
					return new SimpleConverterAdapter() {
						public Object toObject(String value) {
							try {
								return new URL(value.toString());
							} catch (MalformedURLException e) {
								throw new ConversionException("'" + value + "' is not a valid URL");
							}
						}

						public String toString(Object value) {
							return value != null ? value.toString() : null;
						}
					};
				}
			});

			add(new TextField("phoneNumberUS", UsPhoneNumber.class) {
				public IConverter getConverter(Class clazz) {<commit_msg>added bind() to CompoundPropertyModel so that components that do have a id that is not a property can bind to this compound with an alternate property<commit_after>/*
 * 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 wicket.threadtest.apps.app1;

import java.net.MalformedURLException;
import java.net.URL;
import java.util.Arrays;
import java.util.Date;
import java.util.List;
import java.util.Locale;

import wicket.AttributeModifier;
import wicket.markup.html.WebMarkupContainer;
import wicket.markup.html.WebPage;
import wicket.markup.html.basic.Label;
import wicket.markup.html.form.Check;
import wicket.markup.html.form.CheckBox;
import wicket.markup.html.form.CheckGroup;
import wicket.markup.html.form.ChoiceRenderer;
import wicket.markup.html.form.DropDownChoice;
import wicket.markup.html.form.Form;
import wicket.markup.html.form.ImageButton;
import wicket.markup.html.form.ListMultipleChoice;
import wicket.markup.html.form.Radio;
import wicket.markup.html.form.RadioChoice;
import wicket.markup.html.form.RadioGroup;
import wicket.markup.html.form.TextField;
import wicket.markup.html.image.Image;
import wicket.markup.html.link.Link;
import wicket.markup.html.list.ListItem;
import wicket.markup.html.list.ListView;
import wicket.markup.html.panel.FeedbackPanel;
import wicket.markup.html.panel.Panel;
import wicket.markup.repeater.Item;
import wicket.markup.repeater.data.DataView;
import wicket.model.AbstractReadOnlyModel;
import wicket.model.CompoundPropertyModel;
import wicket.model.IModel;
import wicket.model.Model;
import wicket.model.PropertyModel;
import wicket.protocol.http.WebRequest;
import wicket.util.convert.ConversionException;
import wicket.util.convert.IConverter;
import wicket.util.convert.MaskConverter;
import wicket.validation.validator.NumberValidator;

public class Home extends WebPage {

	private class ActionPanel extends Panel {
		/**
		 * @param id
		 *            component id
		 * @param model
		 *            model for contact
		 */
		public ActionPanel(String id, IModel model) {
			super(id, model);
			add(new Link("select") {
				public void onClick() {
					Home.this.selected = (Contact) getParent().getModelObject();
				}
			});
		}
	}

	/**
	 * Form for collecting input.
	 */
	private class InputForm extends Form {
		/**
		 * Construct.
		 * 
		 * @param name
		 *            Component name
		 */
		public InputForm(String name) {
			super(name, new CompoundPropertyModel(new FormInputModel()));
			add(new LocaleDropDownChoice("localeSelect"));
			add(new Link("defaultLocaleLink") {
				public void onClick() {
					WebRequest request = (WebRequest) getRequest();
					setLocale(request.getLocale());
				}
			});
			TextField stringTextField = new TextField("stringProperty");
			stringTextField.setLabel(new Model("String"));
			add(stringTextField);
			TextField integerTextField = new TextField("integerProperty", Integer.class);
			add(integerTextField.add(NumberValidator.POSITIVE));
			add(new TextField("doubleProperty", Double.class));
			WebMarkupContainer dateLabel = new WebMarkupContainer("dateLabel");
			add(dateLabel);
			TextField datePropertyTextField = new TextField("dateProperty", Date.class);
			add(datePropertyTextField);
			add(new TextField("integerInRangeProperty", Integer.class).add(NumberValidator.range(0, 100)));
			add(new CheckBox("booleanProperty"));
			RadioChoice rc = new RadioChoice("numberRadioChoice", NUMBERS).setSuffix("");
			rc.setLabel(new Model("number"));
			add(rc);

			RadioGroup group = new RadioGroup("numbersGroup");
			add(group);
			ListView persons = new ListView("numbers", NUMBERS) {
				protected void populateItem(ListItem item) {
					item.add(new Radio("radio", item.getModel()));
					item.add(new Label("number", item.getModelObjectAsString()));
				};
			};
			group.add(persons);

			CheckGroup checks = new CheckGroup("numbersCheckGroup");
			add(checks);
			ListView checksList = new ListView("numbers", NUMBERS) {
				protected void populateItem(ListItem item) {
					item.add(new Check("check", item.getModel()));
					item.add(new Label("number", item.getModelObjectAsString()));
				};
			};
			checks.add(checksList);

			add(new ListMultipleChoice("siteSelection", SITES));

			add(new TextField("urlProperty", URL.class) {
				public IConverter getConverter(Class clazz) {
					return new IConverter() {
						/**
						 * @see wicket.util.convert.IConverter#convertToObject(java.lang.String, java.util.Locale)
						 */
						public Object convertToObject(String value, Locale locale) {
							try {
								return new URL(value.toString());
							} catch (MalformedURLException e) {
								throw new ConversionException("'" + value + "' is not a valid URL");
							}
						}

						/**
						 * @see wicket.util.convert.IConverter#convertToString(java.lang.Object, java.util.Locale)
						 */
						public String convertToString(Object value, Locale locale) {
							return value != null ? value.toString() : null;
						}
					};
				}
			});

			add(new TextField("phoneNumberUS", UsPhoneNumber.class) {
				public IConverter getConverter(Class clazz) {
{'fraction_non_alphanumeric': 0.1123041718007393, 'fraction_numerical': 0.0015842281288505544, 'mean_word_length': 4.190954773869347, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 3, 'https://': 0, 'lorem ipsum': 0, 'www.': 2, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '6002717', 'n_tokens_mistral': 3759, 'n_tokens_neox': 3228, 'n_words': 825}