5

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.

4
  • 3
    Why don't you just use <rich:suggestionbox>?
    – BalusC
    Aug 23, 2012 at 11:28
  • I want the ability to have a drop-down-box to select groups from, only with the shortcut of being able to search and prefilter. Using a textfield and a suggestionbox doesn't yield that automatically ( i could attach a button; okay.) But also the suggestionbox is using ajax instead of a prerendered list, i think i don't want the lag in this case.
    – DThought
    Aug 24, 2012 at 6:22
  • @user1442158 could you provide comment towards whether or not the answer I gave was useful?
    – ZnArK
    Aug 30, 2012 at 20:51
  • Of course, i was off for the weekend.
    – DThought
    Sep 3, 2012 at 10:44

2 Answers 2

3

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.

0
2
+50

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.

1
  • its easy to access the combobox (which is in fact a <input type="text">) from javascript. but i need access to the list that is held by the rich component which renderes the suggestions/selection list, and i haven't found access to it yet. So yes, you're right about accessing the input element, but i asked how to access the list held behing it ( technically the javascript side of <f:selectItems> )
    – DThought
    Sep 3, 2012 at 10:50

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

Not the answer you're looking for? Browse other questions tagged or ask your own question.