joergrech / KickstartWithBootstrap

Kickstart is an extension for Grails in order to start your project with a good looking frontend. It is intended to be used in rapid application scenarios such as a Startup Weekend or a prototyping session with a customer. This plugin provides adapted scaffolding templates for standard CRUD pages using Twitter's CSS Framework Bootstrap and offers some basic pages for a web site.
65 stars 52 forks source link

_DemoPage does not save in [Grails v. 2.3.5 / KickstartWithBootstrap v. 1.0.0] #70

Open bronoman opened 10 years ago

bronoman commented 10 years ago

Hi, I just tried v. 1.0.0. of the PlugIn with the new Grails v. 2.3.5 and ran into a http 404 and the following stacktrace when trying to save a new item in the demo page:

Method on class [kickstart._DemoPage] was used outside of a Grails application. If running in the context of a test using the mocking API or bootstrap Grails correctly.. Stacktrace follows:
Message: Method on class [kickstart._DemoPage] was used outside of a Grails application. If running in the context of a test using the mocking API or bootstrap Grails correctly.
Line | Method
->>  22 | save     in kickstart._DemoPageController
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
|   200 | doFilter in grails.plugin.cache.web.filter.PageFragmentCachingFilter
|    63 | doFilter in grails.plugin.cache.web.filter.AbstractFilter
|   886 | runTask  in java.util.concurrent.ThreadPoolExecutor$Worker
|   908 | run . .  in     ''
^   662 | run      in java.lang.Thread

Any ideas? Thanks a lot!

my Infrastructure: Windows 8.1 64Bit JDK 1.6.0_25 Grails 2.3.5 Kickstart with Bootstrap 1.0.0 Chrome Version 32.0.1700.76 m

joergrech commented 10 years ago

Yes, I have the same problem but I couldn't identify the cause yet. Must be some change from Grails 2.3.x. However, the demopage is not that important and I tested with newly generated Domain Classes in a project and they are working fine (with the exception of the date binding problem)

bronoman commented 10 years ago

Servus Jörg, seems like I found a workaround for the date binding problem. Here is what I did: 1) installed the jquery-UI plugin 2) added the necessary js so my create.gsp looks as follows:

    <head>
    ...
    <g:javascript library="jquery" />
    <g:javascript>
    $(document).ready(function()
      {
      $("#datepicker").datepicker({dateFormat: 'mm/dd/yyyy'});
       })
    </g:javascript>
    </head>

    <body>
    ...
         <g:textField name="someDate" value="${testInstance?.someDate}" id="datepicker" />
    ...
    </body>

3) in the controller, I added basically one line in the beginning:

    def save() {
            params.someDate = params.date( 'someDate', 'mm/dd/yyyy' )
            def testInstance = new Test(params)
            //println "someDate: ${testInstance.someDate}"
            if (!testInstance.save(flush: true)) {
                render(view: "create", model: [testInstance: testInstance])
                return
            }
        flash.message = message(code: 'default.created.message', args: [message(code: 'test.label', default: 'Test'), testInstance.id])
            redirect(action: "show", id: testInstance.id)
        }

I'm sure there is a more elegant way to do this, but this one works for me so far... best regards!