Brad Mace
Brad Mace

Reputation: 27886

play framework routing error

Apparently I don't understand Play's routing as well as I thought. I was trying to get the url for a form looking the way I want, and I'm getting StackOverflowError from Groups.view's call to render caused by infinite recursion in play.data.binding.Unbinder.unBind(Unbinder.java:62).

This was all working fine when I had the default catch-all route. What I have now is:

GET  /groups/{<[\d\w]+=.*>rdn}      ldapauth.Groups.view
POST /groups/{<[\d\w]+=.*>rdn}  ldapauth.Groups.save

Groups.view works fine until I add a reference to Groups.save:

#{form @ldapauth.Groups.save(rdn: 'cn=test')}`
#{/form}

on the view page, then I get the error above. Anybody know what the actual problem is here?

Upvotes: 1

Views: 602

Answers (1)

Pere Villega
Pere Villega

Reputation: 16439

UnBind is the class that converts the parameters to the proper Java/Scala object.

I believe your error comes from adding rdn: 'cn=test' to the method. Define a hidden input with the name rdn and the value you want, and let Play do the unbinding.

I warn you this may not solve your issue though, there are many known issues related to the routing, Play doesn't behave nicely in some scenarios. I would recommend you to change the definition of post to something like:

POST /groups/save/{<[\d\w]+=.*>rdn}  ldapauth.Groups.save

and in the last line of save you call

view(<params>)

so you are redirected back to the get view (or another method if you want to go somewhere else).

Upvotes: 1

Related Questions