My knowledge about JForum is very minimal so forgive me if my question is very stupid or unrelated to JForum.
I want to add a token to an htm (template) page by calling a java static function. The token is meant to protect the form from Cross-Site Request Forgery (CSRF) attacks, and therefore needs to be generated dynamically.
I saw that calling static functions is possible from htm templates, and since this is normally not possible from htm/html pages I assumed that this is a JForum feature.
What I did is add the following code to the htm page:
However when I run the code I get the following error:
Expression TokenGenerator is undefined on line 4, column 47 in custom/forum_login.htm.
It seems that I also need to configure something to complete this, however I have no clue how to do that ...
Welcome to JavaRanch. That's not so much a feature of JForum, but rather of the FreeMarker templating engine JForum uses. I don't think it allows you to call random static methods without some preparation; at least that's how I read http://freemarker.org/docs/pgui_misc_beanwrapper.html#autoid_55. A better way would be to call that method in the Java class, and then put its results into the HashMap that collects all template variables.