# Can I use a dynamically populated ComboBox for Gateway Web Field

**URL:** <https://forum.inductiveautomation.com/t/can-i-use-a-dynamically-populated-combobox-for-gateway-web-field/64073>\
**Category:** Module Development\
**Tags:** ignition80, ignition81\
**Created:** [September 14, 2022, 6:36pm UTC](https://forum.inductiveautomation.com/t/can-i-use-a-dynamically-populated-combobox-for-gateway-web-field/64073 "2022-09-14T18:36:06Z")\
**Posts on this page:** 1\
**Showing post:** 5

<div class="post-metadata">

**Author:** ![pturmel](https://sea1.discourse-cdn.com/inductiveautomation/user_avatar/forum.inductiveautomation.com/pturmel/32/3295_2.png) [@pturmel](https://forum.inductiveautomation.com/u/pturmel)\
**Post date:** [September 14, 2022, 7:01pm UTC](https://forum.inductiveautomation.com/t/can-i-use-a-dynamically-populated-combobox-for-gateway-web-field/64073/5 "2022-09-14T19:01:35Z")

</div>

> [@paul-griffith](#):
>
> then you’ll have to move from a Wicket page to a React based config page

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:

```auto
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:

```auto
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<?>`. /:

---

_[View the full topic](https://forum.inductiveautomation.com/t/can-i-use-a-dynamically-populated-combobox-for-gateway-web-field/64073)._
