Reputation: 1314
I've got the following simple comboBox in my page.
<rich:comboBox value="#{groupConfig.group}"
styleClass="userCombo"
filterNewValues="false"
directInputSuggestions="true">
<f:selectItems value="#{
workflowConfigCtrl.groupsFor(groupConfig,appNode.approvalTier)
}" />
</rich:comboBox>
It works marvellously, but sadly it allows input of values that are not part of the suggestionList (which makes sense, as I enabled direct text input.
I want direct text input enabled, so that the user can use the suggestion list to quick filter (from a huge group list which can comprise several 100 groups).
At the same time i don't want the user to enter a value that is not in the list. The current approach checks when the user saves the whole form. Is there any way to limit it earlier?
I tried to do it using a javascript onblur= handler, but i can't find the place where the selectItem list is saved in the dom.
Upvotes: 5
Views: 2579
Reputation: 46
You can access the comboBox list in javascript by using
#{rich:component('myComboBoxId')}.comboList.itemsText
and/or
#{rich:component('myComboBoxId')}.comboList.itemsValue
and then use jQuery.inArray()
to verify if the item is in the list.
Upvotes: 3
Reputation: 1541
You should be able to access this combo box in the DOM by specifying its ID like in the following example.
<rich:comboBox value="#{groupConfig.group}"
id="UniqueID"
styleClass="userCombo"
filterNewValues="false"
directInputSuggestions="true">
<f:selectItems value="#{
workflowConfigCtrl.groupsFor(groupConfig,appNode.approvalTier)
}" />
</rich:comboBox>
You could then use document.getElementById("UniqueID")
to access it in the DOM.
Upvotes: 2