Include uri-reference when calling controller methods

Bug #501658 reported by gimenete
6
This bug affects 1 person
Affects Status Importance Assigned to Milestone
play framework
Status tracked in 1.0
1.0
Fix Released
Undecided
Unassigned
1.1
Fix Committed
Undecided
Unassigned

Bug Description

Sometimes when you want to redirect to other controller usually you
just call the controller method. Example:

public static void someMethod() {
// code...
// redirect
OtherController.otherMethod(params); // this redirects
}

Ok. That's fantastic. However sometimes I would like to be able to
redirect to a URL with a uri-reference. Example: http://xxxx#my-uri-reference
The only way to do that is to use Router.reverse directly and concatenate the url with "#my-uri-reference".

Map<String....> paramsMap ....
paramsMap.put(....);
redirect(Router.reverse("controllers.OtherController", paramsMap).url+ "#my-uri-reference");

So that's a pain. And you miss the compile-time check for the class, method and params. I suggest some way of setting a uri-reference. For example:

uriReference = "my-uri-reference";
OtherController.otherMethod(params); // this redirects to http://xxxx#my-uri-reference

Where "uriReference" is a static field of the Controller class.

Revision history for this message
Guillaume Bort (guillaume-bort) wrote :

Try with:

package controllers;

import play.mvc.*;
import play.mvc.Router.*;

public class Application extends Controller {

    public static void index() {
        Long id = 9L;
        ActionDefinition action = reverse(); {
            show(id);
        }
        renderText("Redirecting to %s", action.addRef("boo"));
    }

    public static void show(Long id) {
        //
    }

}

Changed in play:
status: New → Fix Committed
To post a comment you must log in.
This report contains Public information  
Everyone can see this information.

Other bug subscribers

Remote bug watches

Bug watches keep track of this bug in other bug trackers.