Announcement Announcement Module
Collapse
No announcement yet.
Working with Webflows - Best practice Page Title Module
Move Remove Collapse
X
Conversation Detail Module
Collapse
  • Filter
  • Time
  • Show
Clear All
new posts

  • 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
    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.

    Comment


    • #3
      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?

      Comment


      • #4
        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"
        }
        }

        Comment


        • #5
          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.

          Comment


          • #6
            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

            Comment


            • #7
              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. ..

              Comment

              Working...
              X