Grails

ConcurrentModificationException raised if hidden field from datepicker submitted without other fields

Details

  • Type: Bug Bug
  • Status: Closed Closed
  • Priority: Major Major
  • Resolution: Fixed
  • Affects Version/s: 1.2-RC2
  • Fix Version/s: 1.2.1
  • Component/s: Controllers
  • Labels:
    None

Description

If I have a g:datepicker on my page and disable the select elements using script the form will be submitted with a hidden field with the value "date.struct". This causes a ConcurrentModificationException to get raised in GrailsDispatcherServlet.copyParamsFromPreviousRequest.

The underlying cause is that GrailsParameterMap.get has special handling for any field with that value and will look for the expected accompanying date fields, if they are not found the entry is removed from the map - hence the Map is modified during iteration (see GrailsParameterMap.lazyEvaluateDateParam).

To be honest I'm not sure I consider this a bug as it's possible to disable a hidden field as well as the selects. However, it is a change from earlier versions of Grails where this problem didn't occur.

Example project attached.

Issue Links

Activity

Hide
Jason Lai added a comment -

I also get ConcurrentModificationException if any or all of the date picker fields are left blank.
Is there a workaround before 1.2.1 is released? Thanks!

Show
Jason Lai added a comment - I also get ConcurrentModificationException if any or all of the date picker fields are left blank. Is there a workaround before 1.2.1 is released? Thanks!
Hide
Peter Strotmann added a comment -

Grails-5610 adresses the same problem and should be considered in conjunction with this issue.

peter
from Dortmund, Germany

Show
Peter Strotmann added a comment - Grails-5610 adresses the same problem and should be considered in conjunction with this issue. peter from Dortmund, Germany
Hide
Peter Strotmann added a comment -

Hi Jason,

I just used the following link as a workaround:

http://www.grails.org/plugin/richui#DateChooser

it seems working.

Peter

thanks to Christian on german groovy and grails forum

Show
Peter Strotmann added a comment - Hi Jason, I just used the following link as a workaround: http://www.grails.org/plugin/richui#DateChooser it seems working. Peter thanks to Christian on german groovy and grails forum
Hide
Peter Strotmann added a comment -

sorry I've been somewhat fast, rich ui#DateChooser still forces date entry.
and that is not what is intended.

peter

Show
Peter Strotmann added a comment - sorry I've been somewhat fast, rich ui#DateChooser still forces date entry. and that is not what is intended. peter
Hide
Jason Lai added a comment -

Thanks, Peter.
Hopefully someone already has some sort of patch to the source code.

Show
Jason Lai added a comment - Thanks, Peter. Hopefully someone already has some sort of patch to the source code.
Hide
Peter Strotmann added a comment -

Hi Jason,

after inserting this codeBlock after

def personInstance = Person.get(params.id)

in the save and update closure of my PersonController it worked with the date chooser:

def excludes = []
if (!params.geburtsdatum_day)
excludes << "geburtsdatum"
bindData(personInstance, params, excludes)

peter

Show
Peter Strotmann added a comment - Hi Jason, after inserting this codeBlock after def personInstance = Person.get(params.id) in the save and update closure of my PersonController it worked with the date chooser: def excludes = [] if (!params.geburtsdatum_day) excludes << "geburtsdatum" bindData(personInstance, params, excludes) peter
Hide
Jason Lai added a comment -

Thanks for the help, Peter.
But in my case, the exception occurred before getting to the controller though.
I have something similar to your code block which works before grails 1.2. I'm reverting back to 1.1.2 for now.

Show
Jason Lai added a comment - Thanks for the help, Peter. But in my case, the exception occurred before getting to the controller though. I have something similar to your code block which works before grails 1.2. I'm reverting back to 1.1.2 for now.
Hide
Peter Strotmann added a comment -

Hi Jason,

You get an exception before the controller if you use the standard datePicker as delivered out of the box with grails 1.2

I use the dateChooser of the richUi plugin. I followed these steps:

grails install-plugin richui

Insert
<resource:dateChooser />
in my gsp

replace my datePicker Tag by:
<richui:dateChooser name="geburtsdatum" format="dd.MM.yyyy" />

and insert the codeBlock mentioned above in the resp. controller

after doing all this it worked fine for me.

peter

Show
Peter Strotmann added a comment - Hi Jason, You get an exception before the controller if you use the standard datePicker as delivered out of the box with grails 1.2 I use the dateChooser of the richUi plugin. I followed these steps: grails install-plugin richui Insert <resource:dateChooser /> in my gsp replace my datePicker Tag by: <richui:dateChooser name="geburtsdatum" format="dd.MM.yyyy" /> and insert the codeBlock mentioned above in the resp. controller after doing all this it worked fine for me. peter

People

Vote (7)
Watch (7)

Dates

  • Created:
    Updated:
    Resolved: