You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@myfaces.apache.org by "Skjalg Stilson Arstad (JIRA)" <de...@myfaces.apache.org> on 2007/01/19 15:20:29 UTC

[jira] Commented: (MYFACES-1524) Setter method for list-entries and map-entries called regardless of value returned by getter

    [ https://issues.apache.org/jira/browse/MYFACES-1524?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel#action_12466058 ] 

Skjalg Stilson Arstad commented on MYFACES-1524:
------------------------------------------------

I discovered this issue when porting an application from MyFaces to Sun's RI - the application depended on the setter being called, which always was the case when using MyFaces. Switching to RI, it no longer did, preventing the logic in the setter from being called. At first I assumed it was the reference implementation that wasn't following the spec, as it prevents good encapsulation having to expose your internal list in the getter. Looking at the spec, I was surprised to see that it indeed specifies that the getter should be called, and used instead of creating a new list. Of course, from a performance point of view, you can save a little by not having to copy or wrap lists all the time, but still...

A drawback of fixing this will of course be that applications relying on the setters for list- and map-entries being called will break, but I guess being standards compliant is more important. 

> Setter method for list-entries and map-entries called regardless of value returned by getter
> --------------------------------------------------------------------------------------------
>
>                 Key: MYFACES-1524
>                 URL: https://issues.apache.org/jira/browse/MYFACES-1524
>             Project: MyFaces Core
>          Issue Type: Bug
>          Components: JSR-127
>    Affects Versions: 1.1.4
>            Reporter: Skjalg Stilson Arstad
>
> Section 5.3.1.3 states that lists returned by getters for list-entries properties should be used if they are non-null:
> For <list-entries>:
> 1. Call the property getter, if it exists.
> 2. If the getter returns null or doesn't exist, create a java.util.ArrayList,
>    otherwise use the returned Object (an array or a java.util.List).
> ...
> 5. If a new java.util.List was created in step 2) and the property is of type
>    List, set the property by calling the setter method, or log an error if there is no
>    setter method.
> From point 5, it's obvious that the corresponding setter should only be called only if a new list was created in step 2, which only happens if there is no getter or the getter returns null. The implementation in MyFaces (org.apache.myfaces.config.ManagedBeanBuilder.initializeProperties(...)) does however always call the setter, even when a list was returned from the getter.
> The implementation should remember if a new list had to be created (either because it was null/no getter present, or because an array was returned from the getter), and only call the setter if that was the case.

-- 
This message is automatically generated by JIRA.
-
If you think it was sent incorrectly contact one of the administrators: https://issues.apache.org/jira/secure/Administrators.jspa
-
For more information on JIRA, see: http://www.atlassian.com/software/jira