• 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 Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Ron McLeod
  • Paul Clapham
  • Devaka Cooray
  • Liutauras Vilda
Sheriffs:
  • Jeanne Boyarsky
  • paul wheaton
  • Henry Wong
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Tim Moores
  • Carey Brown
  • Mikalai Zaikin
Bartenders:
  • Lou Hamers
  • Piet Souris
  • Frits Walraven

<#if> </#if>

 
Ranch Hand
Posts: 17424
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
how are these <#if> </#if> tags defined?
what is the mapping for them?
i need to show a span (based on values taken from databes) on the post_forum.htm page
here is what i need to do

if (forum.isSubscribedToMailingList) //isSubscribedtoMailingList is a boolean returned from the database
show msg

how do if map this to <#if> </#if> in the htm page?
[originally posted on jforum.net by test895]
 
Migrated From Jforum.net
Ranch Hand
Posts: 17424
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
JForum currently uses FreeMarker ( http://freemarker.sf.net ) as it's template engine. You can find documentation on the syntax there.

In general, Freemarker uses Java objects stored in it "context". In JForum, the context is filled in the "Action" classes that call the template (with some defaults being set in the general controller process that calls the action class).

Freemarker uses Bean set/get property syntax to access values from Java objects or can call methods directly. E.g., if there is a boolean property like subscribedToMailingList with getter like isSubscribedToMailingList(), in a context object with the handle of forum, you can access it's value by forum.subscribedToMailingList or forum.isSubscribedToMailingList().

The if syntax would be:

<#if forum.subscribedToMailingList >
...
</#if>

Since this is a boolean property, true/false testing work. For other properties, this can be a test for null / has value.
[originally posted on jforum.net by monroe]
 
Migrated From Jforum.net
Ranch Hand
Posts: 17424
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
i created a boolean variable in post.java and filled it in the context in postAction.java
now when i try to access it in the post_form.htm

<#if posts.isForumSubscribed>
<tr>
<td ><span class="gen">${I18n.getMessage("PostForm.forumSubscribedInfo")}
</span></td>

</#if>

Expression posts is undefined on line 212, column 30 in default/post_form.htm. The problematic instruction: ---------- ==> if posts.isForumSubscribed [on line 212, column 25 in default/post_form.htm] ---------- Java backtrace for programmers: ---------- freemarker.core.InvalidReferenceException: Expression posts is undefined on line 212, column 30 in default/post_form.htm. at freemarker.core.TemplateObject.assertNonNull(TemplateObject.java:124)
[originally posted on jforum.net by test895]
 
Migrated From Jforum.net
Ranch Hand
Posts: 17424
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Do you want "posts" or "post"? Generally, "posts" (or any plural template variable) is a list of objects. You have to use the List methods to get a single object from this to then use the single objects methods. E.g. something like:

posts.get(0).isForumSubscribed

Of course, you might want to check that there are actually posts available, etc.
[originally posted on jforum.net by monroe]
 
30 seconds to difuse a loaf of bread ... here, use this tiny ad:
We need your help - Coderanch server fundraiser
https://coderanch.com/wiki/782867/Coderanch-server-fundraiser
reply
    Bookmark Topic Watch Topic
  • New Topic