booleans

classic Classic list List threaded Threaded
6 messages Options
Reply | Threaded
Open this post in threaded view
|

booleans

graild
My java classes property is a boolean, and my getter/setters is like:

 public boolean isSold() {
        return isSold;
    }

    public void setSold(boolean sold) {
        isSold = sold;
    }

Trying to reference it in my .ftl is causing an error:

$(product.isSold}


Do I have to change my java class to use getter/setters like:

getIsSold
setisSold?

And then do:

${product.isSold}

?

------------------------------------------------------------------------------
Live Security Virtual Conference
Exclusive live event will cover all the ways today's security and
threat landscape has changed and how IT managers can respond. Discussions
will include endpoint security, mobile security and the latest in malware
threats. http://www.accelacomm.com/jaw/sfrnl04242012/114/50122263/
_______________________________________________
FreeMarker-user mailing list
[hidden email]
https://lists.sourceforge.net/lists/listinfo/freemarker-user
Reply | Threaded
Open this post in threaded view
|

Re: booleans

Daniel Dekany
Monday, July 2, 2012, 12:16:47 AM, S Ahmed wrote:

> My java classes property is a boolean, and my getter/setters is like:
>
>  public boolean isSold() {
>         return isSold;
>     }
>
>     public void setSold(boolean sold) {
>         isSold = sold;
>     }
>
> Trying to reference it in my .ftl is causing an error:
>
> $(product.isSold}

Should be ${product.sold}, following the JavaBeans rules.

> Do I have to change my java class to use getter/setters like:
>
> getIsSold
> setisSold?

"is" replaces "get", so isSold is fine, and the property name is
"sold".

> And then do:
>
> ${product.isSold}
>
> ?

--
Best regards,
 Daniel Dekany


------------------------------------------------------------------------------
Live Security Virtual Conference
Exclusive live event will cover all the ways today's security and
threat landscape has changed and how IT managers can respond. Discussions
will include endpoint security, mobile security and the latest in malware
threats. http://www.accelacomm.com/jaw/sfrnl04242012/114/50122263/
_______________________________________________
FreeMarker-user mailing list
[hidden email]
https://lists.sourceforge.net/lists/listinfo/freemarker-user
Reply | Threaded
Open this post in threaded view
|

Re: booleans

graild
(IntelliJ creates these properties for me using its code generation)

I changed my view code from bug.isResolved to bug.resolved, still getting an error....

Bug.java:

    public boolean isResolved() {
        return isResolved;
    }

    public void setResolved(boolean resolved) {
        isResolved = resolved;
    }

.ftl:

${bug.resolved}


I'm getting this error:

org.springframework.web.util.NestedServletException: Request processing failed; nested exception is freemarker.core.NonStringException: Error on line 4, column 47 in bugs/show.ftl
Expecting a string, date or number here, Expression bug.resolved is instead a freemarker.template.TemplateBooleanModel$1
	org.springframework.web.servlet.FrameworkServlet.processRequest(FrameworkServlet.java:894)
	org.springframework.web.servlet.FrameworkServlet.doGet(FrameworkServlet.java:778)
	javax.servlet.http.HttpServlet.service(HttpServlet.java:621)
	javax.servlet.http.HttpServlet.service(HttpServlet.java:722)





On Sun, Jul 1, 2012 at 6:25 PM, Daniel Dekany <[hidden email]> wrote:
Monday, July 2, 2012, 12:16:47 AM, S Ahmed wrote:

> My java classes property is a boolean, and my getter/setters is like:
>
>  public boolean isSold() {
>         return isSold;
>     }
>
>     public void setSold(boolean sold) {
>         isSold = sold;
>     }
>
> Trying to reference it in my .ftl is causing an error:
>
> $(product.isSold}

Should be ${product.sold}, following the JavaBeans rules.

> Do I have to change my java class to use getter/setters like:
>
> getIsSold
> setisSold?

"is" replaces "get", so isSold is fine, and the property name is
"sold".

> And then do:
>
> ${product.isSold}
>
> ?

--
Best regards,
 Daniel Dekany


------------------------------------------------------------------------------
Live Security Virtual Conference
Exclusive live event will cover all the ways today's security and
threat landscape has changed and how IT managers can respond. Discussions
will include endpoint security, mobile security and the latest in malware
threats. http://www.accelacomm.com/jaw/sfrnl04242012/114/50122263/
_______________________________________________
FreeMarker-user mailing list
[hidden email]
https://lists.sourceforge.net/lists/listinfo/freemarker-user


------------------------------------------------------------------------------
Live Security Virtual Conference
Exclusive live event will cover all the ways today's security and
threat landscape has changed and how IT managers can respond. Discussions
will include endpoint security, mobile security and the latest in malware
threats. http://www.accelacomm.com/jaw/sfrnl04242012/114/50122263/
_______________________________________________
FreeMarker-user mailing list
[hidden email]
https://lists.sourceforge.net/lists/listinfo/freemarker-user
Reply | Threaded
Open this post in threaded view
|

Re: booleans

Attila Szegedi-3
That's by design for booleans; use ${bug.resolved?string}. See
<http://fmpp.sourceforge.net/freemarker/ref_builtins_boolean.html> for
details.

On Mon, Jul 2, 2012 at 1:13 AM, S Ahmed <[hidden email]> wrote:

> (IntelliJ creates these properties for me using its code generation)
>
> I changed my view code from bug.isResolved to bug.resolved, still getting an
> error....
>
> Bug.java:
>
>     public boolean isResolved() {
>         return isResolved;
>     }
>
>     public void setResolved(boolean resolved) {
>         isResolved = resolved;
>     }
>
> .ftl:
>
> ${bug.resolved}
>
>
> I'm getting this error:
>
> org.springframework.web.util.NestedServletException: Request processing
> failed; nested exception is freemarker.core.NonStringException: Error on
> line 4, column 47 in bugs/show.ftl
> Expecting a string, date or number here, Expression bug.resolved is instead
> a freemarker.template.TemplateBooleanModel$1
> org.springframework.web.servlet.FrameworkServlet.processRequest(FrameworkServlet.java:894)
> org.springframework.web.servlet.FrameworkServlet.doGet(FrameworkServlet.java:778)
> javax.servlet.http.HttpServlet.service(HttpServlet.java:621)
> javax.servlet.http.HttpServlet.service(HttpServlet.java:722)
>

------------------------------------------------------------------------------
Live Security Virtual Conference
Exclusive live event will cover all the ways today's security and
threat landscape has changed and how IT managers can respond. Discussions
will include endpoint security, mobile security and the latest in malware
threats. http://www.accelacomm.com/jaw/sfrnl04242012/114/50122263/
_______________________________________________
FreeMarker-user mailing list
[hidden email]
https://lists.sourceforge.net/lists/listinfo/freemarker-user
Reply | Threaded
Open this post in threaded view
|

Re: booleans

Daniel Dekany
Monday, July 2, 2012, 7:04:18 AM, Attila Szegedi wrote:

> That's by design for booleans; use ${bug.resolved?string}. See
> <http://fmpp.sourceforge.net/freemarker/ref_builtins_boolean.html> for
> details.

For the sake of mail archives...

Something like ${bug.resolved?string('yes', 'no')} is more common.

Also of course, the latest docs are on freemarker.org, not on
fmpp.sf.net.

> On Mon, Jul 2, 2012 at 1:13 AM, S Ahmed <[hidden email]> wrote:
>> (IntelliJ creates these properties for me using its code generation)
>>
>> I changed my view code from bug.isResolved to bug.resolved, still getting an
>> error....
>>
>> Bug.java:
>>
>>     public boolean isResolved() {
>>         return isResolved;
>>     }
>>
>>     public void setResolved(boolean resolved) {
>>         isResolved = resolved;
>>     }
>>
>> .ftl:
>>
>> ${bug.resolved}
>>
>>
>> I'm getting this error:
>>
>> org.springframework.web.util.NestedServletException: Request processing
>> failed; nested exception is freemarker.core.NonStringException: Error on
>> line 4, column 47 in bugs/show.ftl
>> Expecting a string, date or number here, Expression bug.resolved is instead
>> a freemarker.template.TemplateBooleanModel$1
>>       org.springframework.web.servlet.FrameworkServlet.processRequest(FrameworkServlet.java:894)
>>       org.springframework.web.servlet.FrameworkServlet.doGet(FrameworkServlet.java:778)
>>       javax.servlet.http.HttpServlet.service(HttpServlet.java:621)
>>       javax.servlet.http.HttpServlet.service(HttpServlet.java:722)
>>
>
> ------------------------------------------------------------------------------
> Live Security Virtual Conference
> Exclusive live event will cover all the ways today's security and
> threat landscape has changed and how IT managers can respond. Discussions
> will include endpoint security, mobile security and the latest in malware
> threats. http://www.accelacomm.com/jaw/sfrnl04242012/114/50122263/
> _______________________________________________
> FreeMarker-user mailing list
> [hidden email]
> https://lists.sourceforge.net/lists/listinfo/freemarker-user
>

--
Best regards,
 Daniel Dekany


------------------------------------------------------------------------------
Live Security Virtual Conference
Exclusive live event will cover all the ways today's security and
threat landscape has changed and how IT managers can respond. Discussions
will include endpoint security, mobile security and the latest in malware
threats. http://www.accelacomm.com/jaw/sfrnl04242012/114/50122263/
_______________________________________________
FreeMarker-user mailing list
[hidden email]
https://lists.sourceforge.net/lists/listinfo/freemarker-user
Reply | Threaded
Open this post in threaded view
|

Re: booleans

graild
In reply to this post by Attila Szegedi-3
thanks that worked.

On Mon, Jul 2, 2012 at 1:04 AM, Attila Szegedi <[hidden email]> wrote:
That's by design for booleans; use ${bug.resolved?string}. See
<http://fmpp.sourceforge.net/freemarker/ref_builtins_boolean.html> for
details.

On Mon, Jul 2, 2012 at 1:13 AM, S Ahmed <[hidden email]> wrote:
> (IntelliJ creates these properties for me using its code generation)
>
> I changed my view code from bug.isResolved to bug.resolved, still getting an
> error....
>
> Bug.java:
>
>     public boolean isResolved() {
>         return isResolved;
>     }
>
>     public void setResolved(boolean resolved) {
>         isResolved = resolved;
>     }
>
> .ftl:
>
> ${bug.resolved}
>
>
> I'm getting this error:
>
> org.springframework.web.util.NestedServletException: Request processing
> failed; nested exception is freemarker.core.NonStringException: Error on
> line 4, column 47 in bugs/show.ftl
> Expecting a string, date or number here, Expression bug.resolved is instead
> a freemarker.template.TemplateBooleanModel$1
>       org.springframework.web.servlet.FrameworkServlet.processRequest(FrameworkServlet.java:894)
>       org.springframework.web.servlet.FrameworkServlet.doGet(FrameworkServlet.java:778)
>       javax.servlet.http.HttpServlet.service(HttpServlet.java:621)
>       javax.servlet.http.HttpServlet.service(HttpServlet.java:722)
>

------------------------------------------------------------------------------
Live Security Virtual Conference
Exclusive live event will cover all the ways today's security and
threat landscape has changed and how IT managers can respond. Discussions
will include endpoint security, mobile security and the latest in malware
threats. http://www.accelacomm.com/jaw/sfrnl04242012/114/50122263/
_______________________________________________
FreeMarker-user mailing list
[hidden email]
https://lists.sourceforge.net/lists/listinfo/freemarker-user


------------------------------------------------------------------------------
Live Security Virtual Conference
Exclusive live event will cover all the ways today's security and
threat landscape has changed and how IT managers can respond. Discussions
will include endpoint security, mobile security and the latest in malware
threats. http://www.accelacomm.com/jaw/sfrnl04242012/114/50122263/
_______________________________________________
FreeMarker-user mailing list
[hidden email]
https://lists.sourceforge.net/lists/listinfo/freemarker-user