Results 1 to 7 of 7

Thread: Working with Webflows - Best practice

  1. #1
    Join Date
    Jul 2010
    Posts
    23

    Default Working with Webflows - Best practice

    Hi All
    I have been trying to get webflows to work for me on Grails 1.3.3 [latest stable build of webflow plugin as well: 1.3.4] but this requirement that all objects be serializable is a real drag. Necessary but a drag perhaps is what I should say.

    I need to modify my domain objects inside my webflows but even when mark every single domain object as serializable.. i still get NotSerializableException errors.

    Any best practice ideas out there for working with webflows .. or gotchas that you guys can share ?

    thanks

  2. #2
    Join Date
    Sep 2010
    Location
    Norway
    Posts
    5

    Default

    This is very annoying indeed! I don't like that everything you touch seem to find its way into the flow scope (I think this one of these creatures: http://hunch.se/stuff/bug-feature.jpg).

    Apart from keeping as much logic as possible inside services and components I haven't really found anything that's working.

  3. #3
    Join Date
    Jun 2010
    Location
    London
    Posts
    304

    Default

    One thing you have to bear in mind is that WebFlow manages its own Hibernate session. Unfortunately, this typically means the session is not available within Grails filters. It may not be available inside GSP layouts either.

    I wonder whether you can store the object IDs in the flow scope, rather than the objects themselves? You should be able to call MyDomain.get(objectId) and get the object with whatever changes you have already made, since the session remains "open" for the life of the flow/conversation.

    Kimble, not sure why you thing everything finds its way into flow scope. Local variables certainly shouldn't! Or do you have something more specific in mind?

  4. #4
    Join Date
    Sep 2010
    Location
    Norway
    Posts
    5

    Default

    Quote Originally Posted by pledbrook View Post
    Kimble, not sure why you thing everything finds its way into flow scope. Local variables certainly shouldn't! Or do you have something more specific in mind?
    It's fairly straight forward to recreate this scenario. A flow like the example below will throw a NotSerializableException. I've read somewhere that manually clearing the session might help. I haven't tried that, but this sounds like something the framework should take care of. Richer domain classes with references to services are particular painful to work with in web flows.

    def testFlow = {
    firstStep {
    on("next").to "actionStep"
    }

    actionStep {
    action {
    new Book(title: 'test').save() // Book is obviously a plain domain class not implementing Serializable
    }
    on("success").to "secondStep"
    }

    secondStep {
    on("previous").to "firstStep"
    }
    }

  5. #5
    Join Date
    Jun 2010
    Location
    London
    Posts
    304

    Default

    Apparently that's a bug caused by Hibernate. Could you raise a JIRA issue and attach a reproducible example? Thanks. Make sure you set the component to "WebFlow" for the issue.

  6. #6
    Join Date
    Sep 2010
    Location
    Norway
    Posts
    5

    Default

    Quote Originally Posted by pledbrook View Post
    Apparently that's a bug caused by Hibernate. Could you raise a JIRA issue and attach a reproducible example? Thanks. Make sure you set the component to "WebFlow" for the issue.
    http://jira.codehaus.org/browse/GRAILS-6683

    Found a mistake in the documentation while I tired to replicate the issue with an integration test.
    http://jira.codehaus.org/browse/GRAILS-6684

  7. #7
    Join Date
    Jul 2010
    Posts
    23

    Default

    I just gave up working with webflows. The idea is really tempting but they are still too hard to implement and debug. I have also experienced the same NotSerializable exceptions mentioned above. ..

Tags for this Thread

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •