0
import org.codehaus.groovy.grails.web.sitemesh.GrailsPageFilter 

enter image description here

This library has imported and worked fine on Grails 2.x.x but when I am trying to Import it on Grails 4.x it is not importing!

How can I import is on Grails 4.x.x? Or need a solution.

Currently using this Dependency :

compile group: 'org.codehaus.groovy', name: 'groovy-dateutil', version: '2.5.0'

Codes:

def buttonDropDown = { attrs, body ->
        def id = attrs.id
        def r = grailsApplication.mainContext.getBean('org.grails.plugin.resource.ResourceTagLib')
        r.require(module: "jquery-ui")


        StringBuilder builder = new StringBuilder();
        builder.append('<button ')
                .append('id="' + id + '">')
                .append(body).append('</button>')
        StringBuilder jsbuilder = new StringBuilder();
        jsbuilder.append(' <script type="text/javascript">')
                .append(' $(document).ready(function(){')
                .append(' $("#' + id + '").button({icons: {primary: "ui-icon-locked"},text: true);')
                .append(' });')
                .append('</script>')

        def headerWriter = getHeaderWriter()
        headerWriter << jsbuilder
        out << builder.toString()

    }

    private getHeaderWriter() {
        def gspSitemeshPage = request[GrailsPageFilter.GSP_SITEMESH_PAGE]
        def headBuffer = gspSitemeshPage.metaClass.getProperty(gspSitemeshPage, 'headBuffer')
        return headBuffer.writer
    }
Asif
  • 354
  • 3
  • 12
  • Duplicate of https://stackoverflow.com/questions/28887118/grails-2-4-classnotfoundexception-sitemesh-grailspagefilter – Puneet Behl Mar 31 '21 at 09:39
  • This issue for Grails 2.x. and my issue of Grails 4..x – Asif Mar 31 '21 at 10:00
  • 1
    `org.codehaus.groovy.grails.web.sitemesh.GrailsPageFilter` shouldn't exist in Grails 4.x. What is it that you are trying to accomplish? – Jeff Scott Brown Mar 31 '21 at 11:32
  • Hi @JeffScottBrown, I added codes into the question, I think you'll get the issue if you see the codes. Thanks for your response. – Asif Mar 31 '21 at 11:47
  • I added an answer. This is unrelated and I know you didn't ask about this, but I expect you are going to have problems with `def r = grailsApplication.mainContext.getBean('org.grails.plugin.resource.ResourceTagLib')`. I don't expect that to work in Grails 4. – Jeff Scott Brown Mar 31 '21 at 11:49
  • The `groovy-dateutil` dependency that you show doesn't really have anything to do with `GrailsPageFilter`. – Jeff Scott Brown Mar 31 '21 at 11:49

1 Answers1

2

Instead of import org.codehaus.groovy.grails.web.sitemesh.GrailsPageFilter and GrailsPageFilter.GSP_SITEMESH_PAGE you could use import org.grails.web.sitemesh.GrailsLayoutView and GrailsLayoutView.GSP_SITEMESH_PAGE.

Jeff Scott Brown
  • 26,804
  • 2
  • 30
  • 47