Use of request.getSession(false) in TagLib of Grails throws exception -
i trying use below code in taglib of grails 2.3.5.
class logintaglib { def logincontrol = { if(request.getsession(false) && session.user){ out << "hello ${session.user.login} " out << """[${link(action:"logout",controller:"user"){"logout"}}]""" } else { out << """[${link(action:"login", controller:"user"){"login"}}]""" } }
}
i getting following error:
groovy.lang.missingmethodexception: no signature of method: org.apache.catalina.connector.requestfacade.session() applicable argument types: (java.lang.boolean) values: [false] possible solutions: getsession(boolean), getsession() racetrack.logintaglib$_closure1.docall(logintaglib.groovy:9) d__java_grails_workspace_racetrack_grails_app_views_layouts__header_gsp.run(_header.gsp:7) d__java_grails_workspace_racetrack_grails_app_views_layouts_main_gsp$_run_closure2.docall(main.gsp:22) d__java_grails_workspace_racetrack_grails_app_views_layouts_main_gsp.run(main.gsp:25) java.util.concurrent.threadpoolexecutor.runworker(threadpoolexecutor.java:1145) java.util.concurrent.threadpoolexecutor$worker.run(threadpoolexecutor.java:615) java.lang.thread.run(thread.java:724)
try instead
def user = session?.user if (user) { out << "hello ${session.user.login} " out << """[${link(action:"logout",controller:"user"){"logout"}}]""" }
Comments
Post a Comment