Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Adding Messages as request attribute to enforce flash scope when redirect #799

Merged
merged 2 commits into from
Sep 17, 2014

Conversation

garcia-jj
Copy link
Member

Closes #795

@Turini
Copy link
Member

Turini commented Sep 16, 2014

sounds ok to me 👍

@Turini Turini added the bug label Sep 16, 2014
@garcia-jj
Copy link
Member Author

I need to change the code because using the own Messages class is only the way to guarantee that vmessages attribute will put into request attributes.

@Turini
Copy link
Member

Turini commented Sep 17, 2014

kinda ugly, but if its working... :) I'm merging here to do a release, if
someone provides a better alternative we can update it later. thanks!

Turini added a commit that referenced this pull request Sep 17, 2014
Adding Messages as request attribute to enforce flash scope when redirect
@Turini Turini merged commit 1dd7e4e into master Sep 17, 2014
@Turini Turini deleted the ot-vmessageswithreqattr branch September 17, 2014 12:44
@garcia-jj
Copy link
Member Author

Sorry. I didn't answer before your merge. But this code not working too. My
bad, because I forgot to change forward to redirect in my test code.

We need to think in another way to use flash scope for Messages.

Ideas?

@Turini
Copy link
Member

Turini commented Sep 17, 2014

ops... sorry. I thought it was solved. I'll take a look on it before releasing.

@garcia-jj
Copy link
Member Author

Thank you, @Turini.

To create the scenario is very simple. You must create a controller with 2 methods:

public class MyFunnyController {
    @Inject private Result result;
    @Inject private Messages messages;

    public void page0() {
        messages.add(new SimpleMessage("category", "my funny message", Severity.SUCCESS));
        result.redirectTo(this).page1();
    } 

    public void page1() {
        String str = messages.get(Severity.SUCCESS).toString();
        System.out.println(str);
        result.use(http()).body(str);
        // you can see the message representation here
    } 
}

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Messages instance is not surviving after a redirect
2 participants