Question

I've got a webflow view where I want to render a model. The model is from a third-party jar file and can't be serialized. Here is what I want to do (below). This gives me a grails webflow error about not being able to pass in a LinkedHashMap into a model. I thought I can pass whatever I want in a render model.

    basicPlanList {
        PlanCollection plans = Plan.all(new HashMap<String, Object>());
        render(view: "basicPlanList", model: [plans: plans.data])
        on("continue") {
            bindData(flow.order, params)
        }.to("addOnsList")
    }

The Plan and PlanCollection are from a third-party and are not serialized. I've tried setting up an action to load the Plan model into the flow, but grails complains with a serialization error:

    first {
        action {
            PlanCollection plans = Plan.all(new HashMap<String, Object>());
            [plans: plans.data]
        }
        on("success").to "basicPlanList"
        on("error").to "handleError"
    }

My workaround so far is to just load the model in the gsp and bypass the web flow crap:

<g:each in="${Plan.all(new HashMap<String, Object>()).data}" status="i" var="plan">

It works, but I'd rather pass the model to the gsp, not have the gsp calling a remote third-party server to load data without any error checking/capture.

The grails api has an example for Action States:

listBooks {
   action {
      [bookList: Book.list()]
   }
   on("success").to "showCatalogue"
   on(Exception).to "handleError"
}

Works great if you have a serialized domain class, which I do not.

Was it helpful?

Solution

The best answer is to not use web flows, because of the serialization issue. I read up on many other posts that had the same problem with serialization in one form or another. I was using the stripe e-commerce library and passing the stripe classes into almost every view for the webflow. I tried the 'evict' suggestion but as soon as I got around one problem another one would crop up due to the third party stripe jar.

Stripe is great, using it in a webflow is not. Avoid it.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top