Uploaded image for project: 'Click'
  1. Click
  2. CLK-239

form.copyTo() does not handle Map's

    Details

    • Type: Bug
    • Status: Closed
    • Priority: Major
    • Resolution: Fixed
    • Affects Version/s: None
    • Fix Version/s: None
    • Component/s: core
    • Labels:
      None
    • Environment:
      1.4RC1

      Description

      When using a Map with form.copyTo(map) does not work hence form.copyFrom(map) works well. The problem
      is in ensureObjectPathNotNull which tries to do a getInvoice() on a map.

      Example:
      Map map = new HashMap();
      map.put("invoice", invoice);
      ....
      form.copyFrom(map)
      Form <- HashMap.invoice.invoiceNumber: 1234
      ....
      form.copyTo(map)
      java.lang.RuntimeException: java.lang.RuntimeException: Getter method not found for path value : invoice
      at net.sf.click.util.ClickUtils.ensureObjectPathNotNull(ClickUtils.java:1763)
      at net.sf.click.util.ClickUtils.copyFormToObject(ClickUtils.java:641)

        Activity

        Hide
        sabob Bob Schellink added a comment -

        Hi

        The copyTo method is really for JavaBeans, not maps.

        However if it is decided to support maps, how to deal with the following:

        1) If an empty map is passed into form.copyTo(map) should all the form values just be copied into the map or none? (If all values should be copied, it might be easier to just use HttpServletRequest, which already provides a map with key/value pairs)

        2) A map with keys should only copy those fields matching the keys?

        3) If more than one field maps to the same key, should the map value be replaced or a list of value be built?

        Show
        sabob Bob Schellink added a comment - Hi The copyTo method is really for JavaBeans, not maps. However if it is decided to support maps, how to deal with the following: 1) If an empty map is passed into form.copyTo(map) should all the form values just be copied into the map or none? (If all values should be copied, it might be easier to just use HttpServletRequest, which already provides a map with key/value pairs) 2) A map with keys should only copy those fields matching the keys? 3) If more than one field maps to the same key, should the map value be replaced or a list of value be built?
        Hide
        sabob Bob Schellink added a comment -

        Attached is a possible patch to support maps.

        Show
        sabob Bob Schellink added a comment - Attached is a possible patch to support maps.
        Hide
        medgar Malcolm Edgar added a comment -

        Hi Bob,

        I am assigning this one to you. The patch looks good, I have not tested it however.

        regards Malcolm Edgar

        Show
        medgar Malcolm Edgar added a comment - Hi Bob, I am assigning this one to you. The patch looks good, I have not tested it however. regards Malcolm Edgar
        Hide
        medgar Malcolm Edgar added a comment -

        Patch applied and checked in. Will be available in release 1.4RC2

        thanks Malcolm Edgar

        Show
        medgar Malcolm Edgar added a comment - Patch applied and checked in. Will be available in release 1.4RC2 thanks Malcolm Edgar

          People

          • Assignee:
            sabob Bob Schellink
            Reporter:
            harry.wissiak@audatex.ch harryw
          • Votes:
            0 Vote for this issue
            Watchers:
            0 Start watching this issue

            Dates

            • Created:
              Updated:
              Resolved:

              Development