You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@myfaces.apache.org by "Dellisanti, Brian" <Br...@fedex.com> on 2006/04/19 21:07:30 UTC

Managed-property array handling incorrect in 1.1.1?

It seems that arrays (of boolean at least) are not handled correctly with respect to value-class based on this from the spec:

The "list-entries" element represents a set of initialization elements for a managed property that is a java.util.List or an array. In the former case, the "value-class" element can optionally be used to declare the Java type to which each value should be converted before adding it to the Collection


As I read it, value-class is only used when the property is a list. However, when I tried something like this:

    <managed-property>
      <property-name>disabled</property-name>
      <property-class>boolean[]</property-class>
      <list-entries>
        <value>false</value>
        <value>true</value>
        <value>true</value>
        <value>true</value>
        <value>true</value>
      </list-entries>
    </managed-property>

I got an exception saying the bean this property is a member of could not be resolved. I discovered that adding "<value-class>boolean</value-class>" to list-entries would make everything work correctly.

This does not seem correct to me based on the spec and would be redundant since the type could be determined from the property-class.

Am I mistaken or is this a bug?

Thanks,
Brian

Re: Managed-property array handling incorrect in 1.1.1?

Posted by Alexandre Poitras <al...@gmail.com>.
Well the spec said even if you specify a <property-class> element, if
your property is null, JSF will always initialize it with a newly
created ArrayList.  If,
however, the object has already created an object of a different type, JSF
won't replace it with an ArrayList. I guess it also apply to arrays. I
think when you have a list or map this property isn't read at all.

On 4/19/06, Dellisanti, Brian <Br...@fedex.com> wrote:
> It seems that arrays (of boolean at least) are not handled correctly with respect to value-class based on this from the spec:
>
> The "list-entries" element represents a set of initialization elements for a managed property that is a java.util.List or an array. In the former case, the "value-class" element can optionally be used to declare the Java type to which each value should be converted before adding it to the Collection
>
>
> As I read it, value-class is only used when the property is a list. However, when I tried something like this:
>
>     <managed-property>
>       <property-name>disabled</property-name>
>       <property-class>boolean[]</property-class>
>       <list-entries>
>         <value>false</value>
>         <value>true</value>
>         <value>true</value>
>         <value>true</value>
>         <value>true</value>
>       </list-entries>
>     </managed-property>
>
> I got an exception saying the bean this property is a member of could not be resolved. I discovered that adding "<value-class>boolean</value-class>" to list-entries would make everything work correctly.
>
> This does not seem correct to me based on the spec and would be redundant since the type could be determined from the property-class.
>
> Am I mistaken or is this a bug?
>
> Thanks,
> Brian
>


--
Alexandre Poitras
Québec, Canada