• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Liutauras Vilda
  • Jeanne Boyarsky
  • Devaka Cooray
  • Paul Clapham
Sheriffs:
  • Tim Cooke
  • Knute Snortum
  • Bear Bibeault
Saloon Keepers:
  • Ron McLeod
  • Tim Moores
  • Stephan van Hulst
  • Piet Souris
  • Ganesh Patekar
Bartenders:
  • Frits Walraven
  • Carey Brown
  • Tim Holloway

Freemarker: session object

 
Ranch Hand
Posts: 17424
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
How can I access the session object? In the former template it was widely used and I could easily use the following statement:

<#if logged && session?exists && (session.isAdmin() || session.isModerator())>

But now the following error comes up:
freemarker.core.InvalidReferenceException: Expression session is undefined on line 66, column 162 in docware/header.htm.

Funny enough in the bottom.htm you aswell use the session object..
<#if session?exists && session.isAdmin()>

So.. uhm... how can I validate if a user is moderator / admin now?
[originally posted on jforum.net by Sid]
 
Migrated From Jforum.net
Ranch Hand
Posts: 17424
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
"session" is always available. It is an instance of UserSession. It is included in JForum.java, line 196, and if bottom.htm uses it, all other templates can use it as well.

Rafael
[originally posted on jforum.net by Rafael Steil]
 
Migrated From Jforum.net
Ranch Hand
Posts: 17424
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I found the actual error. The reason is changed behaviour in application logic, allowing module/action to be an array. I've modified my code for redirection and now it seems to work. The failure messages were very irritating ...
[originally posted on jforum.net by Sid]
 
It is sorta covered in the JavaRanch Style Guide.
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!