Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Grails 3.2.4: The 'raw' method does not work in controllers. #10434

Closed
3 of 4 tasks
atasc opened this issue Jan 26, 2017 · 4 comments
Closed
3 of 4 tasks

Grails 3.2.4: The 'raw' method does not work in controllers. #10434

atasc opened this issue Jan 26, 2017 · 4 comments

Comments

@atasc
Copy link

atasc commented Jan 26, 2017

  • Steps to reproduce provided
  • Stacktrace (if present) provided
  • Example that reproduces the problem uploaded to Github
  • Full description of the issue provided (see below)

###Full Description
The 'raw' method does not work in controllers.

Steps to Reproduce

  1. create an empty 3.2.4 app
  2. create a controller with an index action:
  def index() {
    String src = 'Bla bla bla'

    src = raw(src)

    render src
  }
  1. run-app
  2. Open http://localhost:8080/test/index

Expected Behaviour

Output: Bla bla bla

Actual Behaviour

Exception:


2017-01-26 10:25:36.932 ERROR --- [nio-8080-exec-4] o.g.web.errors.GrailsExceptionResolver   : MissingMethodException occurred when processing request: [GET] /test/index
No signature of method: include.TestController.raw() is applicable for argument types: (java.lang.String) values: [Bla bla bla]
Possible solutions: wait(), any(), grep(), wait(long), use([Ljava.lang.Object;), any(groovy.lang.Closure). Stacktrace follows:

java.lang.reflect.InvocationTargetException: null
        at org.grails.core.DefaultGrailsControllerClass$ReflectionInvoker.invoke(DefaultGrailsControllerClass.java:210)
        at org.grails.core.DefaultGrailsControllerClass.invoke(DefaultGrailsControllerClass.java:187)
        at org.grails.web.mapping.mvc.UrlMappingsInfoHandlerAdapter.handle(UrlMappingsInfoHandlerAdapter.groovy:90)
        at org.springframework.web.servlet.DispatcherServlet.doDispatch(DispatcherServlet.java:963)
        at org.springframework.web.servlet.DispatcherServlet.doService(DispatcherServlet.java:897)
        at org.springframework.web.servlet.FrameworkServlet.processRequest(FrameworkServlet.java:970)
        at org.springframework.web.servlet.FrameworkServlet.doGet(FrameworkServlet.java:861)
        at org.springframework.web.servlet.FrameworkServlet.service(FrameworkServlet.java:846)
        at org.springframework.boot.web.filter.ApplicationContextHeaderFilter.doFilterInternal(ApplicationContextHeaderFilter.java:55)
        at org.grails.web.servlet.mvc.GrailsWebRequestFilter.doFilterInternal(GrailsWebRequestFilter.java:77)
        at org.grails.web.filters.HiddenHttpMethodFilter.doFilterInternal(HiddenHttpMethodFilter.java:67)
        at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1142)
        at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:617)
        at java.lang.Thread.run(Thread.java:745)
Caused by: groovy.lang.MissingMethodException: No signature of method: include.TestController.raw() is applicable for argument types: (java.lang.String) values: [Bla bla bla]
Possible solutions: wait(), any(), grep(), wait(long), use([Ljava.lang.Object;), any(groovy.lang.Closure)
        at grails.artefact.gsp.TagLibraryInvoker$Trait$Helper.methodMissing(TagLibraryInvoker.groovy:92)
        at include.TestController.index(TestController.groovy:8)
        ... 14 common frames omitted


Environment Information

  • **Operating System: Linux 64 bit
  • **Grails Version: 3.2.4
  • **JDK Version: 1.8.0_111

Example Application

@graemerocher
Copy link
Member

There is no raw method for controllers as far as Im aware

@atasc
Copy link
Author

atasc commented Jan 26, 2017

From Grails documentation http://docs.grails.org/latest/guide/single.html

##############################
Raw Output
If you are 100% sure that the value you wish to present on the page has not been received from user input, and you do not wish the value to be encoded then you can use the raw method:

${raw(book.title)}
The 'raw' method is available in tag libraries, controllers and GSP pages.
##############################

In Grails 2.5.4 it works.

@graemerocher
Copy link
Member

So it looks like it was optimised to be a method for tag libraries only and not a tag in all versions of 3.x so that documentation is incorrect for all versions of 3.x right now.

I don't know why you would even need it in controllers since there is no automatic escaping in the render method so just using the string without raw would do it.

@jameskleeh
Copy link
Contributor

Fixed in the docs

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

3 participants