Java Mailing List Archive

http://www.junlu.com/

Home » FreeMarker-user »

Re: [FreeMarker-user] help in understand how to reference my
 objects in my view

Daniel Dekany

2012-04-10

Replies: Find Java Web Hosting

Author LoginPost Reply
Monday, April 9, 2012, 10:10:12 PM, S Ahmed wrote:

> I have a UserSession object that I add into my model like:
>
>
> UserSession userSession = get....
>
> ModelAndView mav = new ModelAndView("..");
>
>
> mav.add("session", userSession);
>
> return mav;
>
> Now in my index.ftl page I want to do this:
>
> if userSession.isLoggedIn
> <p>....
> </p>
> end if
>
> How do I do that using freemarker?
>
> I tried this:
>
> <#if session.isSignedIn>
> </#if>
>
> But I get an error saying that session.isSignedIn has to return
> true/false. Is does return true/false, so what is wrong?

I suppose the error also says that the value is a method. So that's
the problem. In FreeMarker methods are first-class values, and you
haven't *called* the method (like `session.isSignedIn()`) just got the
method itself. Anyway, since this looks like a JavaBean property, you
could just write `session.signedIn` (no "is" and lowercase "s").

> thanks!

--
Best regards,
Daniel Dekany


------------------------------------------------------------------------------
Better than sec? Nothing is better than sec when it comes to
monitoring Big Data applications. Try Boundary one-second
resolution app monitoring today. Free.
http://p.sf.net/sfu/Boundary-dev2dev
_______________________________________________
FreeMarker-user mailing list
FreeMarker-user@(protected)
https://lists.sourceforge.net/lists/listinfo/freemarker-user
©2008 junlu.com - Jax Systems, LLC, U.S.A.