whitenexx
whitenexx

Reputation: 1360

How to create link in grails webflow without execution state in url?

I want to display an image in my webflow wich comes from my domain object.

The domain object has an byte[] Array holding an image. The "image" method in my controller delivers the image to browser. This works fine.

In my webflow I'm doing this:

<img src="${createLink(controller:'shop', action:'image', id:shopInstance.id)}">

I can see the image in my frontend (in browser) but it reloads each time i click "next" or change my state in webflow because the image url contains a param that changes each event in webflow.

The created image url (example above) looks like this:

http://localhost:8080/project/shop/image/2?execution=e2s5

I don't want that the execution param is delivered into my image url. How can i fix this?

Upvotes: 1

Views: 1199

Answers (3)

user2077186
user2077186

Reputation: 21

My guess is that this is a bug. A work around I used is the following

${createLink(controller: 'controller', action: 'action').replaceAll(/\?.*$/, "")}

This will use a regex to remove the execution parameter.

Upvotes: 2

Shaoxuan
Shaoxuan

Reputation: 33

As of Grails 2.0.4, look at ApplicationTagLib.groovy, you can see

if (request['flowExecutionKey']) {
    params."execution" = request['flowExecutionKey']
    urlAttrs.params = params
    if (attrs.controller == null && attrs.action == null && attrs.url == null && attrs.uri == null) {
        urlAttrs[LinkGenerator.ATTRIBUTE_ACTION] = GrailsWebRequest.lookup().actionName
    }
}

So Grails is forcing every link rendered within webflow to include that execution params. It looks like bug to me.

Upvotes: 1

Josh Diehl
Josh Diehl

Reputation: 3079

Not sure why you're getting that execution param but you could try: <img src="${resource(dir: 'shop/image', file: shopInstance.id)}"> and make sure the UrlMappings.groovy file has a mapping for 'ship/image' to the proper controller.

Upvotes: 1

Related Questions