@@ -0,0 +1,2132 @@
+/*%0A * Databinder: a simple bridge from Wicket to Hibernate%0A * Copyright (C) 2006  Nathan Hamblen nathan@technically.us%0A %0A * This library is free software; you can redistribute it and/or%0A * modify it under the terms of the GNU Lesser General Public%0A * License as published by the Free Software Foundation; either%0A * version 2.1 of the License, or (at your option) any later version.%0A * %0A * This library is distributed in the hope that it will be useful,%0A * but WITHOUT ANY WARRANTY; without even the implied warranty of%0A * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU%0A * Lesser General Public License for more details.%0A * %0A * You should have received a copy of the GNU Lesser General Public%0A * License along with this library; if not, write to the Free Software%0A * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA%0A */%0Apackage net.databinder.components;%0A%0Aimport java.util.Arrays;%0Aimport java.util.Collection;%0Aimport java.util.HashSet;%0A%0Aimport org.apache.wicket.markup.html.form.TextField;%0Aimport org.apache.wicket.markup.html.panel.Panel;%0Aimport org.apache.wicket.model.IModel;%0Aimport org.apache.wicket.util.string.Strings;%0A%0A/**%0A * Panel for a comma-separated list of tag strings displayed in a text field. The backing model %0A * for this component must be a Set of String tags. Tags are converted to lower case before%0A * insertion to the set.%0A */%0Apublic class TagField extends Panel %7B%0A%09%0A%09public TagField(String id) %7B%0A%09%09this(id, null);%0A%09%7D%0A%09public TagField(String id, IModel model) %7B%0A%09%09super(id, model);%0A%09%09%0A%09%09add(new TextField(%22field%22, new IModel() %7B%0A%09%09%09public void detach() %7B%7D%0A%09%09%09@SuppressWarnings(%22unchecked%22)%0A%09%09%09public Object getObject() %7B%0A%09%09%09%09Collection%3CString%3E tags = (Collection%3CString%3E) TagField.this.getModelObject();%0A%09%09%09%09return Strings.join(%22, %22,  tags.toArray(new String%5Btags.size()%5D));%0A%09%09%09%7D%0A%09%09%09public void setObject(Object object) %7B%0A%09%09%09%09String value = ((String) object).toLowerCase();%0A%09%09%09%09if (Strings.isEmpty(value ))%0A%09%09%09%09%09TagField.this.setModelObject(null);%0A%09%09%09%09else%0A%09%09%09%09%09TagField.this.setModelObject(new HashSet%3CString%3E(Arrays.asList(value.split(%22 *, *%22))));%0A%09%09%09%7D%0A%09%09%7D));%0A%09%7D%0A%7D%0A

tag component