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

CayenneForm.getDataObject() handling of new objects problem

    XMLWordPrintableJSON

Details

    • Bug
    • Status: Closed
    • Major
    • Resolution: Fixed
    • None
    • None
    • core
    • None
    • Click 0.18 (but I believe it is the same in current CVS version)

    Description

      Calling CayenneForm.getDataObject() more than once for the NEW object results in duplicate insert. I have a case when I need to manipulate a DataObject before saving it, so the action method code looks like this:

      // 'getDataObject() - call #1
      JobPost post = (JobPost) form.getDataObject();
      // do something to POST
      ...
      // 'getDataObject() - call #2
      form.saveChanges()

      here two records are inserted instead of one.

      So maybe we should store DataObject in a transient field of the form for the duration of request, so that consecutive calls to getDataObject do not instantiate it again?

      Attachments

        Activity

          People

            medgar Malcolm Edgar
            andrus Andrus Adamchik
            Votes:
            0 Vote for this issue
            Watchers:
            0 Start watching this issue

            Dates

              Created:
              Updated:
              Resolved: