I have used rich ui's date chooser. I get the value of date correct. But if I want to set the value of richui's datechooser how is that done?
Asked
Active
Viewed 3,302 times
1 Answers
1
You'll have to parse the date manually in your controller because your format/pattern is unknown to grails.
def date = Date().parse("MM-dd-yyyy", params.date); //<-- consider using a constant for the date format
or reset the params value to the java.util.Date class.
params.date = Date().parse("MM-dd-yyyy", params.date); //<-- re-assigns date string as date class
You might also want test the inbound format to make sure someone doesn't manually enter an invalid format...
def date = (parmas.date.matches("\\d{2}-\\d{2}-\\d{4}"))? Date().parse("MM-dd-yyyy", params.date) : null; //<-- safely return null if doesn't match a date regex.
see also:

Community
- 1
- 1

Michael J. Lee
- 12,278
- 3
- 23
- 39
-
Yeah that works Thanks. but it seems I have problem in setting the date in richui's datechooser box. – zade Apr 24 '12 at 12:17
-
You'll most likely have to format the string back into a date in your GSP if the RichUi requires a date and not a string. – Michael J. Lee Apr 24 '12 at 12:48