Re: java.lang.Boolean undefined
Ben Storey <[email protected]>
| Newsgroups | gmane.comp.web.freemarker.user |
|---|---|
| Message-ID | <[email protected]> |
Hi,
Thanks all for your help.
Just in case there is anyone else looking for the same information I
have included a set of tests and just thought I would outline my
requirements for what I wanted to do.
Basically we have an inheritance hierarchy when a method exists on a
certain object, populate a value when one does not exist just leave an
empty string effectively leaving a no value, so basically taking an
inheritance hierarchy and converting it to a flat structure. I settled
on the following syntax for dealing with java.lang.Boolean values.
<#if (model.isObjectBoolean())?has_content>${model.isObjectBoolean()}?string}</#if>
The line (model.isObjectBoolean()) catches the operation if method
does not exist.
If anyone has any improvements on how I can represent this better
please do let me know.
Cheers
Ben
On Tue, Jun 30, 2009 at 5:55 PM, Attila Szegedi<[email protected]> wrote:
> you could use model.isObjectBoolean() syntax.
>
> Attila.
>
> On 2009.06.30., at 18:12, Ben Storey wrote:
>
>> Hi,
>>
>> Thanks for your input. I tried that and it worked. However I am a
>> little restricted in the model in that it is a 3rd party model and
>> cannot rename all the methods as there are quite a few and they are
>> nested objects in the model. Are there any other work arounds. Also I
>> noticed that when I auto generate getters and setters my IDE defaults
>> to the "is" version for the java.lang.Boolean.
>>
>> Cheers
>> Ben
>>
>> On Tue, Jun 30, 2009 at 5:01 PM, Attila Szegedi<[email protected]>
>> wrote:
>>> Change isObjectBoolean to getObjectBoolean. JavaBeans introspector
>>> only recognizes "isXxx" method as a property getter if its return
>>> type
>>> is a primitive boolean.
>>>
>>> Attila.
>>>
>>> On 2009.06.30., at 17:48, Ben Storey wrote:
>>>
>>>> Hi,
>>>>
>>>> I am having some problems with freemarker 2.3.14 and 2.3.15 when I
>>>> am
>>>> trying to extract a value that returns a java.lang.Boolean value and
>>>> get this exception.
>>>>
>>>> Expression model.objectBoolean is undefined on line 1, column 64 in
>>>> testObjectBoolean.ftl.
>>>> The problematic instruction:
>>>> ----------
>>>> ==> ${model.objectBoolean?string} [on line 1, column 62 in
>>>> testObjectBoolean.ftl]
>>>> ----------
>>>>
>>>> Java backtrace for programmers:
>>>> ----------
>>>> freemarker.core.InvalidReferenceException: Expression
>>>> model.objectBoolean is undefined on line 1, column 64 in
>>>> testObjectBoolean.ftl.
>>>> at
>>>> freemarker.core.TemplateObject.assertNonNull(TemplateObject.java:
>>>> 124)
>>>>
>>>>
>>>> For example I have attached a test case that I have been running and
>>>> the second test always fails even though the value has been set. Any
>>>> help on how to resolve this issue would be greatly appreciated.
>>>>
>>>> Cheers
>>>>
>>>> Ben
>>>> <
>>>> BooleanFreemarkerTest
>>>> .java
>
>
>
>
>
> ------------------------------------------------------------------------------
> _______________________________________________
> FreeMarker-user mailing list
> [email protected]
> https://lists.sourceforge.net/lists/listinfo/freemarker-user
>
------------------------------------------------------------------------------
_______________________________________________
FreeMarker-user mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/freemarker-user
BooleanFreemarkerTest.java
(application/octet-stream, 6.3 KB) - not displayed