4 Replies Latest reply on Apr 3, 2009 12:25 PM by Maciek Pazur

    noSelectionLabel in selectManyListbox

    Maciek Pazur Newbie


      I would like to know when user selected noSelectionLabel in a selectManyListBox control.
      In selectOneListBox null is returned, but in selectMany I get a following error:

      Exception during request processing:
      Caused by javax.servlet.ServletException with message: ""
      Caused by java.lang.NullPointerException with message: ""

      The control code is:

      <h:selectManyListbox value="#{searchPattern.selectedModules}" size="5">
           <s:selectItems value="#{searchPattern.availableModules}" var="module"
                label="#{module.name}" noSelectionLabel="#{messages['search.any']}" />
           <s:convertEntity />

      I'd be grateful for any help.

        • 1. Re: noSelectionLabel in selectManyListbox
          Maciek Pazur Newbie
          I've also tried replacing noSelectionLabel with <f:selectItem>

          I need a functionality like this: http://jira.atlassian.com/secure/IssueNavigator.jspa (I mean Project and IssueType selectManyListbox). And sadly, I don't have any other ideas how I could implement it.

          Does anybody have any ideas or suggestions?

          • 2. Re: noSelectionLabel in selectManyListbox
            Arbi Sookazian Master

            If you need to know when a particular value in a JSF UI control (in this case it's a HtmlSelectManyListBox), you can add <a4j:support event="onchange" action="#{fooBean.barAction}">.

            In the barAction() method, you can check the value of the selection.

            If your exception is only occurring when you select the value that corresponds to noSelectionLabel, then you can hard-code a test String like noSelectionLabel="Please select a value." to eliminate the messages resource bundle lookup being the root cause of the problem.

            Also, for testing, you may try a h:selectOneMenu, but the two JSF UI components are very similar...

            Try it w/o the <s:convertEntity> tag as well (simplify the scenario as much as possible to isolate the root cause).

            • 3. Re: noSelectionLabel in selectManyListbox
              Arbi Sookazian Master

              setSelectedModules() will be called before barAction() is called.  Thus, selectedModules instance will be available in barAction() method.

              • 4. Re: noSelectionLabel in selectManyListbox
                Maciek Pazur Newbie

                Thanks for your help. I followed your advice, but my application still doesn't work.

                I eliminated the messages resource bundle lookup.
                I eliminated <s:convertEntity> by trying how list of Strings (instead of list of Objects) would behave.
                I added a4j:support but the action method is called only if noSelectionLabel is not selected. Selecting it gives the above-mentioned exception immediately.

                Does anybody have an idea how to fix it?