You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@myfaces.apache.org by Richard Wallace <rw...@thewallacepack.net> on 2005/09/26 21:29:33 UTC
Long[] and selectManyListbox
Hey all,
I'm trying to use a selectManyListbox component on a page to allow the
user to select multiple things. The SelectItems are created from a list
returned from Hibernate so the value object is of type Long. In my
backing bean I'm using the following methods:
public Long[] getSelectedItems();
public void setSelectedItems (Long[] ids);
The page comes up just fine to start with but when I try to submit it I
get conversion error. The headlines from the stack trace are:
javax.faces.el.EvaluationException: Cannot set value for expression
'#{departmentTypeHandler.selectedInstitutionTypeIds}' to a new value of
type [Ljava.lang.Object;
Caused by: javax.servlet.jsp.el.ELException: Attempt to coerce a value
of type "[Ljava.lang.Object;" to type "[Ljava.lang.Long;
I tried setting a converter on the selectManyListbox with
converter="javax.faces.Long" to try and make it convert the String[] to
a Long[]. But that didn't work at all, seemed as if the converter
didn't even get used. Is this the right approach or do I need to create
a converter for converting a String[] to a Long[]?
I know I could probably convert the value to of the SelectItems to
Strings, but I'd rather not do that unless I absolutely have to. Seems
a little hackish. What else might I try?
Thanks,
Rich
Re: Long[] and selectManyListbox
Posted by Bruno Aranda <br...@gmail.com>.
This has been fixed now in the SVN! Thanks for reporting!
Bruno
2005/9/27, Peter Mahoney <pm...@digitalbrain.com>:
> I think this is a similar issue to that which I have previously reported
> as bug MYFACES-583. Hopefully the suggested patches can get applied soon.
>
> Peter
>
> Richard Wallace wrote:
>
> > Ok, well what's weird is that I couldn't even do it if I set the
> > return type and parameter type and stuff to String[]. It was still
> > giving me the same problems. The only way I could get this to work is
> > by returning an Object[] and in the setter having the parameter be an
> > Object[]. But then I can just do a direct cast to a Long of elements
> > of that array, so it is, in fact, a Long[].
> >
> > I'm chalking this up to odd conversion issues that others seem to be
> > reporting.
> >
> > Richard Wallace wrote:
> >
> >> Hey all,
> >>
> >> I'm trying to use a selectManyListbox component on a page to allow
> >> the user to select multiple things. The SelectItems are created from
> >> a list returned from Hibernate so the value object is of type Long.
> >> In my backing bean I'm using the following methods:
> >>
> >> public Long[] getSelectedItems();
> >> public void setSelectedItems (Long[] ids);
> >>
> >> The page comes up just fine to start with but when I try to submit it
> >> I get conversion error. The headlines from the stack trace are:
> >>
> >> javax.faces.el.EvaluationException: Cannot set value for expression
> >> '#{departmentTypeHandler.selectedInstitutionTypeIds}' to a new value
> >> of type [Ljava.lang.Object;
> >>
> >> Caused by: javax.servlet.jsp.el.ELException: Attempt to coerce a
> >> value of type "[Ljava.lang.Object;" to type "[Ljava.lang.Long;
> >>
> >> I tried setting a converter on the selectManyListbox with
> >> converter="javax.faces.Long" to try and make it convert the String[]
> >> to a Long[]. But that didn't work at all, seemed as if the converter
> >> didn't even get used. Is this the right approach or do I need to
> >> create a converter for converting a String[] to a Long[]?
> >> I know I could probably convert the value to of the SelectItems to
> >> Strings, but I'd rather not do that unless I absolutely have to.
> >> Seems a little hackish. What else might I try?
> >>
> >> Thanks,
> >> Rich
> >
> >
>
>
Re: Long[] and selectManyListbox
Posted by Peter Mahoney <pm...@digitalbrain.com>.
I think this is a similar issue to that which I have previously reported
as bug MYFACES-583. Hopefully the suggested patches can get applied soon.
Peter
Richard Wallace wrote:
> Ok, well what's weird is that I couldn't even do it if I set the
> return type and parameter type and stuff to String[]. It was still
> giving me the same problems. The only way I could get this to work is
> by returning an Object[] and in the setter having the parameter be an
> Object[]. But then I can just do a direct cast to a Long of elements
> of that array, so it is, in fact, a Long[].
>
> I'm chalking this up to odd conversion issues that others seem to be
> reporting.
>
> Richard Wallace wrote:
>
>> Hey all,
>>
>> I'm trying to use a selectManyListbox component on a page to allow
>> the user to select multiple things. The SelectItems are created from
>> a list returned from Hibernate so the value object is of type Long.
>> In my backing bean I'm using the following methods:
>>
>> public Long[] getSelectedItems();
>> public void setSelectedItems (Long[] ids);
>>
>> The page comes up just fine to start with but when I try to submit it
>> I get conversion error. The headlines from the stack trace are:
>>
>> javax.faces.el.EvaluationException: Cannot set value for expression
>> '#{departmentTypeHandler.selectedInstitutionTypeIds}' to a new value
>> of type [Ljava.lang.Object;
>>
>> Caused by: javax.servlet.jsp.el.ELException: Attempt to coerce a
>> value of type "[Ljava.lang.Object;" to type "[Ljava.lang.Long;
>>
>> I tried setting a converter on the selectManyListbox with
>> converter="javax.faces.Long" to try and make it convert the String[]
>> to a Long[]. But that didn't work at all, seemed as if the converter
>> didn't even get used. Is this the right approach or do I need to
>> create a converter for converting a String[] to a Long[]?
>> I know I could probably convert the value to of the SelectItems to
>> Strings, but I'd rather not do that unless I absolutely have to.
>> Seems a little hackish. What else might I try?
>>
>> Thanks,
>> Rich
>
>
Re: Long[] and selectManyListbox
Posted by Richard Wallace <rw...@thewallacepack.net>.
Ok, well what's weird is that I couldn't even do it if I set the return
type and parameter type and stuff to String[]. It was still giving me
the same problems. The only way I could get this to work is by
returning an Object[] and in the setter having the parameter be an
Object[]. But then I can just do a direct cast to a Long of elements of
that array, so it is, in fact, a Long[].
I'm chalking this up to odd conversion issues that others seem to be
reporting.
Richard Wallace wrote:
> Hey all,
>
> I'm trying to use a selectManyListbox component on a page to allow the
> user to select multiple things. The SelectItems are created from a
> list returned from Hibernate so the value object is of type Long. In
> my backing bean I'm using the following methods:
>
> public Long[] getSelectedItems();
> public void setSelectedItems (Long[] ids);
>
> The page comes up just fine to start with but when I try to submit it
> I get conversion error. The headlines from the stack trace are:
>
> javax.faces.el.EvaluationException: Cannot set value for expression
> '#{departmentTypeHandler.selectedInstitutionTypeIds}' to a new value
> of type [Ljava.lang.Object;
>
> Caused by: javax.servlet.jsp.el.ELException: Attempt to coerce a value
> of type "[Ljava.lang.Object;" to type "[Ljava.lang.Long;
>
> I tried setting a converter on the selectManyListbox with
> converter="javax.faces.Long" to try and make it convert the String[]
> to a Long[]. But that didn't work at all, seemed as if the converter
> didn't even get used. Is this the right approach or do I need to
> create a converter for converting a String[] to a Long[]?
> I know I could probably convert the value to of the SelectItems to
> Strings, but I'd rather not do that unless I absolutely have to.
> Seems a little hackish. What else might I try?
>
> Thanks,
> Rich