# Wicket Database Dropdown Editor

**URL:** <https://forum.inductiveautomation.com/t/wicket-database-dropdown-editor/40967>\
**Category:** Module Development\
**Tags:** database, ignition80\
**Created:** [November 25, 2020, 8:41pm UTC](https://forum.inductiveautomation.com/t/wicket-database-dropdown-editor/40967 "2020-11-25T20:41:41Z")\
**Posts on this page:** 6\
**Page:** 1

<div class="post-metadata">

**Author:** ![cody.tamaki](https://avatars.discourse-cdn.com/v4/letter/c/b487fb/32.png) [@cody.tamaki](https://forum.inductiveautomation.com/u/cody.tamaki)\
**Post date:** [November 25, 2020, 8:41pm UTC](https://forum.inductiveautomation.com/t/wicket-database-dropdown-editor/40967/1 "2020-11-25T20:41:41Z")

</div>

Hello,

Is there an existing class in the SDK for a Wicket database dropdown editor? I wasn’t finding anything in the Javadoc but it’s a component I see that’s commonly used in the gateway config pages…

---

<div class="post-metadata">

**Author:** ![paul-griffith](https://sea1.discourse-cdn.com/inductiveautomation/user_avatar/forum.inductiveautomation.com/paul-griffith/32/37249_2.png) [@paul-griffith](https://forum.inductiveautomation.com/u/paul-griffith)\
**Post date:** [November 25, 2020, 9:27pm UTC](https://forum.inductiveautomation.com/t/wicket-database-dropdown-editor/40967/2 "2020-11-25T21:27:38Z")

</div>

You don’t configure the dropdown, you just add a `ReferenceField` to your `PersistentRecord` and include it on the page - the RecordEditForm will automatically create the dropdown.

```java
    public static final LongField DatasourceId = new LongField(META, "DatasourceId", SFieldFlags.SMANDATORY);
    public static final ReferenceField<DatasourceRecord> Datasource =
        new ReferenceField<>(META, DatasourceRecord.META, "Datasource", DatasourceId);

```

```java
    public static final Category Main = new Category("AlarmJournalRecord.Category.Main", 50).include(
        Datasource,
        MinPriority,
        Store_ShelvedEvents,
        UseStoreAndForward
    );

```

Take a look at `com.inductiveautomation.ignition.gateway.web.components.editors.ReferenceEditorSource` if you’re curious how it works.

---

<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:** [November 25, 2020, 10:01pm UTC](https://forum.inductiveautomation.com/t/wicket-database-dropdown-editor/40967/3 "2020-11-25T22:01:00Z")

</div>

There’s also the EnumField. For `Enum`s, naturally.

---

<div class="post-metadata">

**Author:** ![cody.tamaki](https://avatars.discourse-cdn.com/v4/letter/c/b487fb/32.png) [@cody.tamaki](https://forum.inductiveautomation.com/u/cody.tamaki)\
**Post date:** [November 25, 2020, 10:53pm UTC](https://forum.inductiveautomation.com/t/wicket-database-dropdown-editor/40967/4 "2020-11-25T22:53:57Z")

</div>

Perfect thank you Paul/Phil. For those ReferenceFields, how would I setup the getter/setter to access that field directly from my Persistent Record? Do I need to specifically query that reference if I want to use it?

---

<div class="post-metadata">

**Author:** ![paul-griffith](https://sea1.discourse-cdn.com/inductiveautomation/user_avatar/forum.inductiveautomation.com/paul-griffith/32/37249_2.png) [@paul-griffith](https://forum.inductiveautomation.com/u/paul-griffith)\
**Post date:** [November 25, 2020, 11:50pm UTC](https://forum.inductiveautomation.com/t/wicket-database-dropdown-editor/40967/5 "2020-11-25T23:50:38Z")

</div>

Yeah - just look up the relevant record using the ID record paired with the ReferenceField:

```auto
                DatasourceRecord dsr = context.getPersistenceInterface()
                    .find(DatasourceRecord.META, dbSettings.getLong(DatabaseJournalRecord.DatasourceId));

```

---

<div class="post-metadata">

**Author:** ![cody.tamaki](https://avatars.discourse-cdn.com/v4/letter/c/b487fb/32.png) [@cody.tamaki](https://forum.inductiveautomation.com/u/cody.tamaki)\
**Post date:** [November 26, 2020, 6:45pm UTC](https://forum.inductiveautomation.com/t/wicket-database-dropdown-editor/40967/6 "2020-11-26T18:45:17Z")

</div>

Sweet, what I ended up doing (because I won’t want to have to pass my gateway context around with my settings everywhere) was overriding the onQueryRecord() method:

```
/**
 * Eagerly load references while SimpleORM session is still active.
 */
@Override
protected void onQueryRecord() {
    super.onQueryRecord();
    findReference(Datasource);
    getDatasource().getDriver();
    getDatasource().getTranslator();
    findReference(BasicAuthSource);
}
```
