4 Replies Latest reply on Oct 14, 2008 5:46 PM by Monkey Den

    filterMethod and selectOneListbox

    Monkey Den Master

      How do I get the value binding (#{donationManager.selectedCategory}) to work before the filterMethod is invoked? Here is the code I am using. It's pretty much a hybrid between the two methods used in "External Filtering" tab of the demo:

      <rich:column filterMethod="#{donationManager.filterDonations}">
       <f:facet name="header">
       <h:selectOneListbox value="#{donationManager.selectedCategory}" size="1">
       <s:selectItems value="#{categories}" var="category" label="#{category.name}" noSelectionLabel="All Categories"/>
       <s:convertEntity />
       <a4j:support ajaxSingle="true" event="onchange"/>
       </h:selectOneListbox>
       </f:facet>
       <ul class="nostyle">
       <ui:repeat value="#{bh:asList(donation.categories)}" var="category">
       <li>#{category.name}</li>
       </ui:repeat>
       </ul>
      </rich:column>


        • 1. Re: filterMethod and selectOneListbox
          Monkey Den Master

          Can anyone answer why this example would not work? It's nearly identical to the example. The value binding method, setSelectedCategory(), is never called. Expected behavior would be:

          1. Change select box
          2. Call value binding mutator
          3. Call filter method for each item in the data list

          The filterMethod method is called for each item in the list, but the category is always null because the mutator is never called.

          Thanks

          • 2. Re: filterMethod and selectOneListbox
            Ilya Shaikovsky Master

            add rich:messages to the page.

            • 3. Re: filterMethod and selectOneListbox
              Monkey Den Master

              Thanks for that, but I already had one. There are no errors.

              • 4. Re: filterMethod and selectOneListbox
                Monkey Den Master

                Turns out it was failing as a result of the seam tags:

                <s:selectItems value="#{categories}" var="category" label="#{category.name}" noSelectionLabel="All Categories"/>
                <s:convertEntity />



                It must be using a different mechanism when it appears in the facet tag. To provide some perspective, the Seam tags resolve the selected item to the relevant entity and allow me to call this value binding method:

                public void setSelectedCategory(Category selectedCategory)


                It works in the traditional case (simple in a form) but for some reason this value binding does not happen for filtering. The solution in my case was the use "JSF proper" SelectItems:

                <f:selectItem itemLabel="All Categories" itemValue=""/>
                <f:selectItems value="#{categorySelectItems}"/>


                If I am right, any insight from the omniscient among us is much appreciated.

                P.S.
                Ilya, you were correct. I had a h:messages instead of rich:messages. The latter revealed the issue. Thanks