0
votes

I want to pass a string to a "form" page template and then post the form and redirect to the previous page by using the string that I have sent. The reason that I want to do it is to prevent the POST form issue of staying in the page after POST.

I created this get :

GET    /form/:page                               controllers.Pages.form(page)

and the controller look like that

public static Result form(String page) {          
    return ok(form.render(userForm),page);
}

and I'm trying to route like that :

<a href="@routes.Pages.form(page)" class="btn btn-info">send </a>

What is your preferred way to pass parameters between views?

2
@i.am.michiel thanks for edit the question - MIkCode

2 Answers

0
votes

I too am new to play but I see a few issues

Firstly, your routes file should be

GET    /form/:page                        controllers.Pages.form(page: String)

and in the controller Pages,

public static Result form(String page) {          
    return ok(form.render(userForm,page)); //Not ok(form.render(userForm),page)
}

finally in the view,

@(page :String)

<a href="@routes.Pages.form(page)" class="btn btn-info">send </a>
0
votes

In your example just call:

<a href="@controllers.routes.Pages.form(page)" class="btn btn-info">send </a>

or

<a href="/form/@page" class="btn btn-info">send </a>

And this a should not be inside html form tag.

To be sure check with firebug, that your browser sends GET