2

I try to restrict (using deadbolt) something in my view (play! framework) and I have to pass a parameter like:

#{deadbolt.restrictedResource resourceKeys:['projectEdit'], resourceParameters:['projectId':'3'}

You notice 3 is harcoded for example (it works). But I need it dynamic, like:

#{deadbolt.restrictedResource resourceKeys:['projectEdit'], resourceParameters:['projectId':${project.alias}]}

Well, now the code no longer works but it throws an exception:

 Exception raised was MissingMethodException : No signature of method: Template_1012.$() is applicable for argument types: (Template_1012$_run_closure1_closure2) values: [Template_1012$_run_closure1_closure2@370c488c] Possible solutions: _(java.lang.String), is(java.lang.Object), run(), run(), any(), get(java.lang.String).

Do you know why this is happening?

Cristian Boariu
  • 9,603
  • 14
  • 91
  • 162

1 Answers1

1

Off the top of my head, try quote it:

#{deadbolt.restrictedResource resourceKeys:['projectEdit'], resourceParameters:['projectId':'${project.alias}']}

Let me know if that works, and we can take it from there if necessary.

Tommi
  • 8,550
  • 5
  • 32
  • 51
Steve Chaloner
  • 8,162
  • 1
  • 22
  • 38
  • Thanks but it does not work, it comes up in the code as a String: `${project.alias}`...the workaround I found is to get my project alias from the current url... – Cristian Boariu Apr 03 '12 at 20:02
  • You're already in an evaluation scope, so you don't need the ${} - so try one of the following: #{deadbolt.restrictedResource resourceKeys:['projectEdit'], resourceParameters:['projectId':project.alias]} or #{deadbolt.restrictedResource resourceKeys:['projectEdit'], resourceParameters:['projectId':'' + project.alias]} – Steve Chaloner Apr 04 '12 at 06:28