Bill F
Bill F

Reputation: 2087

xpages combobox control where user can enter values not in list

I need to create a comboBox control that displays a list of values but allowas the user to enter a value not in the list. I saw where you can do this with dijit.form.comboBox but I understand that no longer works after 8.5 something. So that route is out. This should be pretty basic and I'm guessing that I'm just missing a property somewhere. Any pointers?

Thanks in advance

Upvotes: 0

Views: 1762

Answers (2)

Knut Herrmann
Knut Herrmann

Reputation: 30970

Here is a working example for core control xp:comboBox where users can enter values not in list without using Extension Library:

<?xml version="1.0" encoding="UTF-8"?>
<xp:view
    xmlns:xp="http://www.ibm.com/xsp/core">
    <xp:this.resources>
        <xp:dojoModule
            name="dijit.form.ComboBox"
            rendered="true">
        </xp:dojoModule>
    </xp:this.resources>

    <xp:comboBox
        id="comboBox1"
        value="#{sessionScope.Test}"
        dojoType="dijit.form.ComboBox"
        disableValidators="true">
        <xp:selectItem itemLabel="abc"></xp:selectItem>
        <xp:selectItem itemLabel="def"></xp:selectItem>
        <xp:selectItem itemLabel="xyz"></xp:selectItem>
    </xp:comboBox>

    <xp:button
        value="Submit"
        id="button1">
        <xp:eventHandler
            event="onclick"
            submit="true"
            refreshMode="complete"
            immediate="false"
            save="true">
        </xp:eventHandler>
    </xp:button>
</xp:view>

Three things are important here:

  1. Add dojoModule ressource dijit.form.ComboBox
  2. Add dojoType="dijit.form.ComboBox"
  3. Add disableValidators="true" otherwise new values not in list won't get submitted.

If you are allowed to use Extension Library in your project then you would use Dojo Form control "Dojo Combo Box" xe:djComboBox of course instead.

Upvotes: 2

Bill F
Bill F

Reputation: 2087

Got it with a djComboBox wish it were property of the core control.

Upvotes: 0

Related Questions