1

I am facing a wierd issue regarding in URL generation in Playframework.

Here is my code snippet in template:

@{Rooms.list(customerId?:customerId, location?:location, roomId?:roomId)}

Obviousely I wanna to generate a the URL like this:

/rooms/list?customer=1&location=asdf&roomId=1

But finally I got this:

/rooms/list?customer=1&location=asdf&roomId=1

I traced down the play source code and found this in "GroovyTemplate":

if (template.template.name.endsWith(".html") || template.template.name.endsWith(".xml")) {
    def.url = def.url.replace("&", "&");
}

Could anybody tell what's the purpose of this replacement? How can I get my URL correctly?

Thanks

4

1 Answer 1

2

not sure if this answers your question, but you could try the following:

@{Rooms.list().add("customerId", customerId).add("location", location).add("roomId", roomId)}
3
  • Thanks, your solution works perfectly. But I still have concern about the URL generation mechanism.
    – Hank
    Feb 17, 2011 at 8:27
  • well, don't hesitate to ask at play's google groups groups.google.com/group/play-framework, or even better, have a look at the source code... use the source, luke!
    – opensas
    Feb 24, 2011 at 2:51
  • yes, probably you should ask what you are doing before was correct or not. Aug 8, 2011 at 6:37

Your Answer

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

Not the answer you're looking for? Browse other questions tagged or ask your own question.