FreeMarker Plugin
  1. FreeMarker Plugin
  2. GPFREEMARKER-5

Grails JSP TagLib should be usable from/with Freemarker

    Details

    • Type: New Feature New Feature
    • Status: Closed
    • Priority: Major Major
    • Resolution: Fixed
    • Affects Version/s: None
    • Fix Version/s: None
    • Labels:
      None

      Description

      Hi. First of all i apologize for my poor writing skills in English.

      I really don't know if this should be fixed in Grails or in Freemarker.

      The symptoms and a probable cause are described here: http://grails.1312388.n4.nabble.com/Using-freemarker-tp2311110p2312689.html

      It seems that JspInvokeGrailsTagLibTag stores TAG_LIBS_ATTRIBUTE in the page scope as a HashMap and FreeMarkerPageScope wraps this HashMap in a SimpleHash. So the second execution of the jsp tag (in a freemarker template) fails.

      Maybe the solution could be to store this attribute in the request scope or wrap it in a different type of object/collection, but i'm not sure if it will work.

      Please let me know if there is any workaround for this situation.

      Thanks.

      1. JspInvokeGrailsTagLibTag.java.patch
        3 kB
        Daniel Henrique Alves Lima
      2. StackTrace.txt
        12 kB
        Lim Chee Kin
      3. test_freemarker.tar.bz2
        153 kB
        Daniel Henrique Alves Lima

        Activity

        Hide
        Lim Chee Kin added a comment -

        Hi,

        I run the test_freemarker2 sample app with following steps:
        1. Extract the downloaded test_freemarker2.tar.bz2
        2. Install freemarker-tags 0.3 into the test_freemarker2 project
        3. Rename the test2.ftl in grails-app/views/test1 directory to edit.ftl
        4. Run the application with grails run-app

        After I create a test record and edit it, I face the following exception in the edit screen:
        Expression test1 is undefined on line 27, column 40 in test1/edit.ftl.

        The problematic instruction:

        ----------
        ==> user-directive g.textField [on line 27, column 7 in test1/edit.ftl]
        in user-directive g.form [on line 26, column 5 in test1/edit.ftl]
        ----------

        Java backtrace for programmers:

        ----------

        freemarker.core.InvalidReferenceException: Expression test1 is undefined on line 27, column 40 in test1/edit.ftl.
        at freemarker.core.TemplateObject.assertNonNull(TemplateObject.java:124)

        Please see the attached file for complete stack trace.

        Fyi, I am new to Freemarker. Did I missed any step to run the sample app?

        Thanks.

        Show
        Lim Chee Kin added a comment - Hi, I run the test_freemarker2 sample app with following steps: 1. Extract the downloaded test_freemarker2.tar.bz2 2. Install freemarker-tags 0.3 into the test_freemarker2 project 3. Rename the test2.ftl in grails-app/views/test1 directory to edit.ftl 4. Run the application with grails run-app After I create a test record and edit it, I face the following exception in the edit screen: Expression test1 is undefined on line 27, column 40 in test1/edit.ftl. The problematic instruction: ---------- ==> user-directive g.textField [on line 27, column 7 in test1/edit.ftl] in user-directive g.form [on line 26, column 5 in test1/edit.ftl] ---------- Java backtrace for programmers: ---------- freemarker.core.InvalidReferenceException: Expression test1 is undefined on line 27, column 40 in test1/edit.ftl. at freemarker.core.TemplateObject.assertNonNull(TemplateObject.java:124) Please see the attached file for complete stack trace. Fyi, I am new to Freemarker. Did I missed any step to run the sample app? Thanks.
        Hide
        Daniel Henrique Alves Lima added a comment -

        1. Extract the .tar.bz2
        2. Install freemarker-tags 0.5
        3. Run the application
        4. Try to access http://localhost:8080/test_freemarker2/test1/create2

        E-mail me or the Grails user mailing list if you need help.

        There are still some issues, mainly because i know little about Grails Tag Libs (for instance, some tags don't "output" their result, but return a value instead).

        Show
        Daniel Henrique Alves Lima added a comment - 1. Extract the .tar.bz2 2. Install freemarker-tags 0.5 3. Run the application 4. Try to access http://localhost:8080/test_freemarker2/test1/create2 E-mail me or the Grails user mailing list if you need help. There are still some issues, mainly because i know little about Grails Tag Libs (for instance, some tags don't "output" their result, but return a value instead).
        Hide
        Lim Chee Kin added a comment -

        As conclusion, this issue was fixed by plugin at http://www.grails.org/plugin/freemarker-tags.

        Show
        Lim Chee Kin added a comment - As conclusion, this issue was fixed by plugin at http://www.grails.org/plugin/freemarker-tags .
        Hide
        Daniel Henrique Alves Lima added a comment -

        This is great. Even in the early stages of development, i believe it is easier try to fix/improve freemarker-tags plugin than handle this freemarker + jsp + grails puzzle (http://grails.1312388.n4.nabble.com/GSP-Tags-and-Freemarker-td3093668.html). I also believe that the performance of this plugin is better than the alternative (i'm just guessing).
        The plugin still lacks of documentation and unit/integration tests. I good starting point to learn how it can be used is the sample application "test_freemarker2".

        Show
        Daniel Henrique Alves Lima added a comment - This is great. Even in the early stages of development, i believe it is easier try to fix/improve freemarker-tags plugin than handle this freemarker + jsp + grails puzzle ( http://grails.1312388.n4.nabble.com/GSP-Tags-and-Freemarker-td3093668.html ). I also believe that the performance of this plugin is better than the alternative (i'm just guessing). The plugin still lacks of documentation and unit/integration tests. I good starting point to learn how it can be used is the sample application "test_freemarker2".
        Hide
        Jeff Scott Brown added a comment -

        See freemarker-tags

        Show
        Jeff Scott Brown added a comment - See freemarker-tags

          People

          • Assignee:
            Unassigned
            Reporter:
            Daniel Henrique Alves Lima
          • Votes:
            1 Vote for this issue
            Watchers:
            1 Start watching this issue

            Dates

            • Created:
              Updated:
              Resolved: