Grails
  1. Grails
  2. GRAILS-8228

Multi-select inconsistently passes values either as list or as integers/longv

    Details

    • Type: Bug Bug
    • Status: Open
    • Priority: Major Major
    • Resolution: Unresolved
    • Affects Version/s: 2.0-RC1
    • Fix Version/s: None
    • Component/s: TagLib, View technologies
    • Labels:

      Description

      Given a multi-select element like so:

      <g:select	name="someName" from="${some.list()}" value="${someOther.list()}" optionKey="id" multiple="true" />

      If the user selects only one item from such a select-box, then params.someName holds a single value (let's say '12').
      Now, if the user selects more than one item from that list, then params.someName holds a list of values (let's say '[12, 20, 45]' ).

      This makes additional boilerplate code necessary in order to cope with both situations. Even if such code is in place, it's still error prone, as the contents of the params-Map are Strings which will cause something like the following to fail:

      (params.someName instanceof List) ? params.someName : [ params.someName ]
      

      A better solution would be to always pass a list, even if there was only one value in it. With the above example in mind, the content of params.someName would then be '[12]' in case only one item was selected.

        Activity

        There are no comments yet on this issue.

          People

          • Assignee:
            Unassigned
            Reporter:
            Bernhard Areich
          • Votes:
            0 Vote for this issue
            Watchers:
            0 Start watching this issue

            Dates

            • Created:
              Updated:
              Last Reviewed:

              Development