I am creating a web application with PLAY framework 2.2.1 and trying to display all the available http get query parameters for the requested site in the address bar, even those that are not specified in the request. In cases where not all http get parameters are available, I want to add uninstalled parameters with default values ββand redirect.
I have a website that can be requested using GET:
GET /test controllers.Application.test(q:String, w:String ?= null, f:String ?= null, o:String ?= null)
Here is the method I would like to have in controllers.Application :
public static Result test(String q, String w, String f, String o){ ... // In case not all parameters where set if (reload == 1){ return redirect(controllers.Application.test(qDefault, wDefault, fDefault, oDefault)); } else { ok(...); } }
The problem is that redirect () accepts a String object, not a Result object.
My first decision is to write
return controllers.Application.test(qDefault, wDefault, fDefault, oDefault);
But, unfortunately, the address bar is not updated.
My second solution is to create a string manually:
return redirect("/test?q=" + query + "&f=" + f + "&w=" + w + "&o=" + showOptions);
This works great, but is there no other way to a more elegant way to do this?