Can I use a dynamically populated ComboBox for Gateway Web Field

Nah. Wicket works just fine. It's just that everything IA does with it uses the PersistentRecord models. I implemented my own. The abstract base:

public abstract class AbstractModelEditor<T> extends Panel {
	private static final long serialVersionUID = 1L;
	protected final WebMarkupContainer body;
	protected final FormComponent<T> editor;

	/**
	 * Mimic's Ignition's Field style in the RecordEditForm, but not dependent on
	 * any PersistentRecord instance.  Instead, the appropriate wicket model is
	 * supplied to the fields.
	 * 
	 * Subclasses must have html with wicket:extend surrounding a suitable form
	 * component snippet having wicket:id="editor".  The subclass should pass a
	 * bound CompoundPropertyModel to the wicket form component.  Ideally, the
	 * CompoundPropertyModel is attached to the form itself.
	 *
	 * @param id          Typically an auto-generated child ID of a RepeatingView.
	 * @param fieldModel  Model to supply/receive the HTML field value
	 * @param baseKey     Required bundle key prefix for .Name, optional .Desc, and
	 *                    optional .Default static text.
	 */
	public AbstractModelEditor(String id, IModel<T> fieldModel, String baseKey) {
		super(id);
		TransparentWebMarkupContainer row = new TransparentWebMarkupContainer("editorRow");
		Label title = new Label("fieldTitle", new LenientResourceModel(baseKey+".Name", ""));
		row.add(title);
		body = new WebMarkupContainer("editorBody");

		/* Subclass markup injected by wicket:child for editor component. */
		editor = createEditor(fieldModel);
		body.add(editor);

		LenientResourceModel descModel = new LenientResourceModel(baseKey+".Desc", "");
		MultiLineLabel desc = new MultiLineLabel("descriptionLabel", descModel);
        desc.setEscapeModelStrings(false);
        desc.setVisible(!TypeUtilities.isNullOrEmpty(descModel.getObject()));
        body.add(desc);
		LenientResourceModel defModel = new LenientResourceModel(baseKey+".Default", "");
        Label defValue = new Label("defaultLabel", defModel);
        defValue.setVisible(!TypeUtilities.isNullOrEmpty(defModel.getObject()));
        body.add(defValue);

        row.add(body);
        add(row);
	}

	protected abstract FormComponent<T> createEditor(IModel<T> fieldModel);

	public FormComponent<T> getEditor() {
		return editor;
	}
}

Then concrete implementations like this:

public class ModelChoiceEditor<T> extends AbstractModelEditor<T> {
	private static final long serialVersionUID = 1L;

	public ModelChoiceEditor(String id, IModel<T> fieldModel, String baseKey, IModel<? extends List<? extends T>> choicesModel, IChoiceRenderer<T> renderer) {
		super(id, fieldModel, baseKey);
		DropDownChoice<T> f = (DropDownChoice<T>) editor;
		if (choicesModel != null)
			f.setChoices(choicesModel);
		if (renderer != null)
			f.setChoiceRenderer(renderer);
	}

	protected FormComponent<T> createEditor(IModel<T> fieldModel) {
		DropDownChoice<T> f = new DropDownChoice<T>("editor");
		f.setDefaultModel(fieldModel);
		return f;
	}
}

Sorry, Eric, that's all you get. Just plucking out what else I could share would be rather time-consuming. Wicket isn't very friendly until you wrap your head around the IModel<?>. /:

1 Like