Announcement Announcement Module
Collapse
No announcement yet.
No flash.message in try...catch? Page Title Module
Move Remove Collapse
X
Conversation Detail Module
Collapse
  • Filter
  • Time
  • Show
Clear All
new posts

  • No flash.message in try...catch?

    hi,

    i'm using grails 2.0.3 with java 1.6.0_45-b06 and groovy-compiler 1.8.6.
    in my controllers/services i'm using try...catch blocks when doing database stuff. i'd like to show a confirm-message, if an operation was successful or an error message if not. here's my code:

    controllers/services:
    Code:
    SomeDomainObject.withTransaction { status ->
                            try {
                                    //doing db-stuff...
                                    //....
                                    log.info("Log something")
                                    flash.confirm = message(code: 'some.message.code')
                            } catch(e) {
                                    status.setRollbackOnly()
                                    log.error("Log the error" + e)
                                    flash.error = message(code: 'some.other.code')
                            }
                    }
    redirect action: 'anAction'
    view:
    Code:
    <g:if test='${flash.confirm}'>
        <div class='confirmDiv'>${flash.confirm}</div>
    </g:if>
    <g:if test='${flash.error}'>
        <div class='errorDiv'>${flash.error}</div> 
    </g:if>
    the logging does work perfectly, but no flash-message is shown...?! Neither the flash.confirm, nor the flash.error when provoking database operation to fail...
    i really have no idea at the moment, why no flash message is shown... and would be very thankful if someone has a clue!

    thanks a lot!

  • #2
    hi again,
    i have to specify this phenomenon a little bit more:

    code snippets above are inside a registered user area. when i clean my browser cache, cookies, ... and log in with a user, everything works as it should!
    if i log out and do a log in again, flash messages are not shown anymore. it doesn't matter if it's the same user or another user, they do not show up as long as i clean my browser's cache, cookies, ... again.

    any hints would be very appreciated!!!!

    Comment

    Working...
    X