1

Is there a way to pass the value from a Scala parameter to Java on the view using the Play Framework?

Something like:

<strong>Title: </strong> @addtitle              

<a href="@routes.Application.shopping()" value="Add to Cart"
   class="btn btn-primary btn-xs">@Messages("playauthenticate.results.shopping")
</a>

But I wanna put the @addtitle as a parameter to the @routes.Application.shopping(@addtitle)

I'm using Play Framework 2.2.0.

1
  • @LimbSoup I believe you should post that as the answer. Commented Jul 11, 2014 at 18:42

1 Answer 1

1

Yes there is.

Let's say your Application controller in the controllers package had a function with this signature:

public static Result index(String name) { ... }

or (in Scala)

def index(name: String) = Action { ... }

And you wanted the reverse router to produce the URL to this controller function from within the view:

@routes.Application.shopping(addtitle)

Notice how we don't need the @ symbol within the arguments of the function. It's already understood by the template compiler that it's reading scala, and not raw text. This is of course, not limited to the reverse router, but any function.

Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.