You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@myfaces.apache.org by an...@magnasteyr.com on 2006/01/02 18:00:25 UTC

What Object Type for SelectManyCheckbox

Hi all!

I'm just trying the SelectManyCheckbox component. What is the best Object type the value of the SelectManyCheckbox should point to?
Should I take a List or a Long[]  or a Object[]? What should be newPartnerDto.datenarten?
And how can I retrieve the selected items in my backing bean?


<h:selectManyCheckbox id="Datenarten" required="true" value="#{newPartnerDto.datenarten}">
	<f:selectItems value="#{queryHelper.datenartContact}"/>
</h:selectManyCheckbox>


Regards,
Andy

______________________________________________________________________

This email and any files transmitted with it are confidential and
intended solely for the use of the individual or entity to whom they
are addressed. If you have received this email in error please notify
your system manager.
 
This footnote also confirms that this email message has been swept
for the presence of computer viruses. 
______________________________________________________________________

Re: What Object Type for SelectManyCheckbox

Posted by Dave Brondsema <da...@brondsema.net>.
Don't use a List (the spec requires that no conversion happens), use an
array.  The type of array elements should be that of what you want to
store (e.g. Long, OrgPerson).  Provide a converter if it is your own
class (e.g. OrgPerson).

See
http://java.sun.com/j2ee/javaserverfaces/1.1_01/docs/api/javax/faces/component/UISelectMany.html
especially the 3 bullet points in the class description.

andreas.mitter@magnasteyr.com wrote:
> Hi all!
> 
> I'm just trying the SelectManyCheckbox component. What is the best
> Object type the value of the SelectManyCheckbox should point to?
> 
> Should I take a List or a Long[]  or a Object[]? What should be*/
> newPartnerDto.datenarten/*//?
> And how can I retrieve the selected items in my backing bean?
> 
> 
> <h:selectManyCheckbox id="Datenarten" required="true"
> value="#{newPartnerDto.datenarten}">
>         <f:selectItems value="#{queryHelper.datenartContact}"/>
> </h:selectManyCheckbox>
> 
> 
> Regards,
> Andy
> 
> 
> ______________________________________________________________________
> This email and any files transmitted with it are confidential and
> intended solely for the use of the individual or entity to whom they are
> addressed. If you have received this email in error please notify your
> system manager. This footnote also confirms that this email message has
> been swept for the presence of computer viruses.
> ______________________________________________________________________


-- 
Dave Brondsema
Software Developer
Cornerstone University

AW: What Object Type for SelectManyCheckbox

Posted by Matthias Kahlau <mk...@web.de>.
Hi!


I use the Tomahawk selectManyCheckbox with f:selectItems bound to a
LinkedList of SelectItem instances. This instances have a java.lang.String
as label and a java.lang.Character as value.

For the value-binding of the selectManyCheckbox, I tried to use a LinkedList
instead of an Object or primitive array because I think the selected options
can be processed more easily by iterating over a list.

To set the currently selected values of the selectManyCheckbox, I filled the
related LinkedList by iterating over the f:selectItems LinkedList.

> If the value binding is a List, then the myfaces assumes (per the spec)
> that all elements are of type String, not the same type as
> SelectItem.getValue().

I tried both, using SelectItem.getValue() and
SelectItem.getValue().toString(), and both worked to set the currently
selected values. But when I tried to submit the page, I got a validation
error saying the values are no valid options, with both variants described
before.

I found the following blog entry referring to the same validation error
issue (see June 18, 2004):
http://jroller.com/page/nuprn1/20040722

Or see also:
http://www.crazysquirrel.com/computing/java/jsf/select-many.jspx


Does anyone of you know of a working solution using a List as value-binding
of the selectManyCheckbox component? Or can you confirm that using a List is
not possible? Are there any official statements?

I searched the Issue Tracking database of MyFaces
(http://issues.apache.org/jira/secure/BrowseProject.jspa?id=10600) and SUN
JSF RI (https://javaserverfaces.dev.java.net/) but didn't find any issues
regarding the List value-binding problem.



Regards,

Matthias


> -----Ursprüngliche Nachricht-----
> Von: users-return-14631-mkahlau=web.de@myfaces.apache.org
> [mailto:users-return-14631-mkahlau=web.de@myfaces.apache.org]Im Auftrag
> von Dave Brondsema
> Gesendet: Mittwoch, 4. Januar 2006 15:01
> An: MyFaces Discussion
> Betreff: Re: What Object Type for SelectManyCheckbox
>
>
> Simon Kitching wrote:
> > On Mon, 2006-01-02 at 18:00 +0100, andreas.mitter@magnasteyr.com wrote:
> >
> >>Hi all!
> >>
> >>I'm just trying the SelectManyCheckbox component. What is the best
> >>Object type the value of the SelectManyCheckbox should point to?
> >>
> >>Should I take a List or a Long[]  or a Object[]? What should be
> >>newPartnerDto.datenarten?
> >>And how can I retrieve the selected items in my backing bean?
> >>
> >>
> >><h:selectManyCheckbox id="Datenarten" required="true"
> >>value="#{newPartnerDto.datenarten}">
> >>        <f:selectItems value="#{queryHelper.datenartContact}"/>
> >></h:selectManyCheckbox>
> >
> >
> > Hopefully the improved taglib documentation in the current MyFaces TRUNK
> > makes this clear. Search this file for "selectManyCheckbox":
> >
> http://svn.apache.org/repos/asf/myfaces/impl/trunk/src/main/tld/my
> faces_html.tld
> >
> > If the docs still aren't clear enough, please let me know.
> >
>
> If the value binding is a List, then the myfaces assumes (per the spec)
> that all elements are of type String, not the same type as
> SelectItem.getValue().
>
> That should be made clear and since using a List does work unintuitively
> like that, I'd suggest listing it last, after "Object array or primitive
> array"
>
>
> --
> Dave Brondsema
> Software Developer
> Cornerstone University
>


Re: What Object Type for SelectManyCheckbox

Posted by Dave Brondsema <da...@brondsema.net>.
Simon Kitching wrote:
> On Mon, 2006-01-02 at 18:00 +0100, andreas.mitter@magnasteyr.com wrote:
> 
>>Hi all!
>>
>>I'm just trying the SelectManyCheckbox component. What is the best
>>Object type the value of the SelectManyCheckbox should point to?
>>
>>Should I take a List or a Long[]  or a Object[]? What should be
>>newPartnerDto.datenarten? 
>>And how can I retrieve the selected items in my backing bean?
>>
>>
>><h:selectManyCheckbox id="Datenarten" required="true"
>>value="#{newPartnerDto.datenarten}"> 
>>        <f:selectItems value="#{queryHelper.datenartContact}"/> 
>></h:selectManyCheckbox>
> 
> 
> Hopefully the improved taglib documentation in the current MyFaces TRUNK
> makes this clear. Search this file for "selectManyCheckbox":
> http://svn.apache.org/repos/asf/myfaces/impl/trunk/src/main/tld/myfaces_html.tld
> 
> If the docs still aren't clear enough, please let me know.
> 

If the value binding is a List, then the myfaces assumes (per the spec)
that all elements are of type String, not the same type as
SelectItem.getValue().

That should be made clear and since using a List does work unintuitively
like that, I'd suggest listing it last, after "Object array or primitive
array"


-- 
Dave Brondsema
Software Developer
Cornerstone University

Re: What Object Type for SelectManyCheckbox

Posted by Simon Kitching <sk...@apache.org>.
On Mon, 2006-01-02 at 18:00 +0100, andreas.mitter@magnasteyr.com wrote:
> Hi all!
> 
> I'm just trying the SelectManyCheckbox component. What is the best
> Object type the value of the SelectManyCheckbox should point to?
> 
> Should I take a List or a Long[]  or a Object[]? What should be
> newPartnerDto.datenarten? 
> And how can I retrieve the selected items in my backing bean?
> 
> 
> <h:selectManyCheckbox id="Datenarten" required="true"
> value="#{newPartnerDto.datenarten}"> 
>         <f:selectItems value="#{queryHelper.datenartContact}"/> 
> </h:selectManyCheckbox>

Hopefully the improved taglib documentation in the current MyFaces TRUNK
makes this clear. Search this file for "selectManyCheckbox":
http://svn.apache.org/repos/asf/myfaces/impl/trunk/src/main/tld/myfaces_html.tld

If the docs still aren't clear enough, please let me know.

Regards,

Simon