package fr.openwide.maven.artifact.notifier.web.application.artifact.component;

import org.apache.wicket.markup.html.form.IChoiceRenderer;
import org.apache.wicket.model.IModel;
import org.retzlaff.select2.ISelect2AjaxAdapter;
import org.retzlaff.select2.Select2Settings;

import fr.openwide.core.wicket.more.markup.html.select2.GenericSelect2AjaxDropDownSingleChoice;
import fr.openwide.core.wicket.more.markup.html.select2.util.DropDownChoiceWidth;
import fr.openwide.core.wicket.more.markup.html.select2.util.Select2Utils;
import fr.openwide.maven.artifact.notifier.core.business.artifact.model.Artifact;

public class ArtifactDropDownChoice extends GenericSelect2AjaxDropDownSingleChoice<Artifact> {

	private static final long serialVersionUID = -6782229493391720861L;

	public static final IChoiceRenderer<Artifact> CHOICE_RENDERER = new ArtifactChoiceRenderer();

	public ArtifactDropDownChoice(String id, IModel<Artifact> model) {
		this(id, model, new ArtifactSelect2AjaxAdapter(CHOICE_RENDERER));
	}
	
	public ArtifactDropDownChoice(String id, IModel<Artifact> model, ISelect2AjaxAdapter<Artifact> adapter) {
		super(id, model, adapter);
		setWidth(DropDownChoiceWidth.XLARGE);
	}
	
	@Override
	protected void fillSelect2Settings(Select2Settings settings) {
		super.fillSelect2Settings(settings);
		settings.setDropdownCssClass(Select2Utils.CSS_DROP_XLARGE);
	}

	private static class ArtifactChoiceRenderer implements IChoiceRenderer<Artifact> {
		private static final long serialVersionUID = -4610661508328127491L;

		@Override
		public Object getDisplayValue(Artifact object) {
			if (object != null) {
				StringBuilder builder = new StringBuilder()
					.append(object.getGroup().getGroupId())
					.append(":")
					.append(object.getArtifactId());
				return builder.toString();
			}
			return null;
		}

		@Override
		public String getIdValue(Artifact object, int index) {
			if (object != null) {
				return String.valueOf(object.getId());
			}
			return null;
		}
	}
}
@@ -1575,20 +1575,22 @@
 rtifact 
-obje
+artifa
 ct) %7B%0A%09%09
@@ -1594,224 +1594,70 @@
 %0A%09%09%09
-if (object != null) %7B%0A%09%09%09%09StringBuilder builder = new StringBuilder()%0A%09%09%09%09%09.append(object.getGroup().getGroupId())%0A%09%09%09%09%09.append(%22:%22)%0A%09%09%09%09%09.append(object.getArtifactId());%0A%09%09%09%09return builder.toString();%0A%09%09%09%7D%0A%09%09%09return
+return artifact != null ? artifact.getArtifactKey().getKey() :
  nul

Use of ArtifactKey instead of a StringBuilder for consistency