Routes with multiple parameters in Play 2.0

Showing 1-5 of 5 messages
Routes with multiple parameters in Play 2.0 edmondo1984 3/30/12 7:47 AM
Dear all,
I don't find in the documentation how to have routes with multiple
parameters which are automatically passed to the controller in Play
2.0

What is the right syntax to add a route in routes in play 2.0?


Best Regards
Edmondo

Re: Routes with multiple parameters in Play 2.0 biesior 3/30/12 7:53 AM
GET     /something/:id/:name       controllers.Controller.action(id:Long, name:String)

W dniu piątek, 30 marca 2012, 16:47:16 UTC+2 użytkownik edmondo1984 napisał:
Re: [play-framework] Re: Routes with multiple parameters in Play 2.0 edmondo1984 3/30/12 8:57 AM
I am confused, will that match
/something?id=10&name="James" ?
or
/something/10/james

I am trying to match the first of the two...

Best Regards


2012/3/30 biesior <bie...@gmail.com>:> --
> You received this message because you are subscribed to the Google Groups
> "play-framework" group.
> To view this discussion on the web visit
> https://groups.google.com/d/msg/play-framework/-/qjmBU5G1PFYJ.
> To post to this group, send email to play-fr...@googlegroups.com.
> To unsubscribe from this group, send email to
> play-framewor...@googlegroups.com.
> For more options, visit this group at
> http://groups.google.com/group/play-framework?hl=en.

Re: [play-framework] Re: Routes with multiple parameters in Play 2.0 biesior 3/30/12 10:14 AM

it will match second case

Other case:

GET     /nice-test/:id/:name   controllers.Application.test(id:Long, name:String)
will match /nice-test/10/james

and

GET     /ugly-test             controllers.Application.test(id:Long ?= 0, name:String ?= "")
will match /ugly-test?id=10&name=james


they both will be passed correctly to the same action, but ugly case is just ... ugly:

    public static Result test(Long id, String name){
        return ok("The "+name+" has id "+id);
    }


What's more in your view you should build url for both cases in the same way:

<a href="@routes.Application.delete(user.id, user.name)">Show me user</a>

W dniu piątek, 30 marca 2012, 17:57:56 UTC+2 użytkownik edmondo1984 napisał:
I am confused, will that match
/something?id=10&name="James" ?
or
/something/10/james

I am trying to match the first of the two...


2012/3/30 biesior


> GET     /something/:id/:name       controllers.Controller.action(id:Long, name:String)

Re: [play-framework] Re: Routes with multiple parameters in Play 2.0 biesior 3/30/12 10:17 AM
arrggghhhh sorry! that shoul be this link of course

<a href="@routes.Application.test(user.id, user.name)">Show me user</a>