Re: BeansWrapper.populateClassMapWithPropertyDescriptor failing to create property descriptors

Attila Szegedi <[email protected]>
Newsgroups gmane.comp.web.freemarker.user
Message-ID <[email protected]>
Ok, made the change on Github: <https://github.com/freemarker/freemarker/commit/f88a21323d5f9658728cc848152d5133444c2e63>. Donnchadh, you should be able to clone the repo and build from source simply by:

git clone git://github.com/freemarker/freemarker.git
cd freemarker
ant jar

the JAR file will be in build/freemarker.jar

Attila.

On Nov 15, 2011, at 10:48 AM, Newman, John W wrote:

> sounds great to me... I can't see any reason why that block would even need to bother with the write method .. just leave it as null and move on.  Unless .. is anyone using beanswrapper to write properties?  I hope not, but maybe.
> 
> [#assign x = (bean.setY('z'))!"" /] 
> 
> ^ does that even work?  If it does, it probably would even without messing with the write method as it's calling setY explicitly.  I think the part in question with the write method is there to avoid writing "get" and "set", like  ${bean.x.y}    = bean.getX().getY() ... but is it even possible to do a direct assignment to a field in FM?  I don't think so... ?
> 
> -----Original Message-----
> From: Donnchadh Ó Donnabháin [mailto:[email protected]] 
> Sent: Tuesday, November 15, 2011 13:34
> To: FreeMarker-user
> Subject: Re: [FreeMarker-user] BeansWrapper.populateClassMapWithPropertyDescriptor failing to create property descriptors
> 
> Yes, that does seem like a much simpler solution.
> 
>  Donnchadh
> 
> On 15 November 2011 17:56, Attila Szegedi <[email protected]> wrote:
>> Actually, I don't think we use write methods at all, do we? FreeMarker is only ever reading properties, never writing them. I'm not even sure why I wrote the code so that it's putting the write methods into the property descriptors; I guess we could just replace them with nulls and thus emulate read-only properties.
>> 
>> Attila.
>> 
>> On Nov 15, 2011, at 7:26 AM, Donnchadh Ó Donnabháin wrote:
> ...
>>> 
>>> Maybe this code on line 1255 of BeansWrapper.java (FreeMarker 2.3.17):
>>>                        pd = new PropertyDescriptor(pd.getName(),
>>>                                publicReadMethod, 
>>> pd.getWriteMethod());
>>> 
>>> could be replaced with something like this:
>>> 
>>>                        Method writeMethod = pd.getWriteMethod();
>>>                        if (writeMethod != null && 
>>> (pd.getWriteMethod().getParameterTypes().length != 1
>>>                                ||
>>> pd.getWriteMethod().getParameterTypes()[0] !=
>>> publicReadMethod.getReturnType())) {
>>>                            writeMethod = null;
>>>                        }
>>>                        pd = new PropertyDescriptor(pd.getName(),
>>>                                publicReadMethod, writeMethod);
>>> 
>>> What do you think?
>>> 
>>>    Donnchadh
>>> 
> 
> ------------------------------------------------------------------------------
> RSA(R) Conference 2012
> Save $700 by Nov 18
> Register now
> http://p.sf.net/sfu/rsa-sfdev2dev1
> _______________________________________________
> FreeMarker-user mailing list
> [email protected]
> https://lists.sourceforge.net/lists/listinfo/freemarker-user
> ------------------------------------------------------------------------------
> RSA(R) Conference 2012
> Save $700 by Nov 18
> Register now
> http://p.sf.net/sfu/rsa-sfdev2dev1
> _______________________________________________
> FreeMarker-user mailing list
> [email protected]
> https://lists.sourceforge.net/lists/listinfo/freemarker-user

------------------------------------------------------------------------------
RSA(R) Conference 2012
Save $700 by Nov 18
Register now
http://p.sf.net/sfu/rsa-sfdev2dev1

_______________________________________________
FreeMarker-user mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/freemarker-user
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.