Yes, this is what I mean, and what I thought you were also trying to
do in your example. The 'value' attribute:

<h:selectManyListbox VALUE="pre-selection">

I could speak english better in a previous life :-)

Bruno

2005/10/11, Caroline Jen <[EMAIL PROTECTED]>:
> Thanks for your reply.
>
> [QUOTE]
> to have some values selected when the page is
> loaded you have to use the @value attribute.
> [/QUOTE]
>
> What is @value attribute?  I am completely confused by
> the sentence.  Do you mean if I want to display some
> pre-selected values when the page is loaded?
>
> --- Bruno Aranda <[EMAIL PROTECTED]> wrote:
>
> > Your code is not ok. You are binding the faces
> > components to wrong
> > types: h:selectManyListbox cannot be bound to
> > String[] and
> > f:selectItems cannot be bound to an instance of
> > UISelectMany....
> >
> > The best pattern here is to pass an Array/List of
> > SelectItem objects
> > to the value of your f:selectItems component, like
> > this:
> >
> > <h:selectManyListbox
> > value="#{fileManagementBean.dataFile}">
> >     <f:selectItem
> > value="#{fileManagementBean.listOfSelectItems}/>
> > </h:selectManyListbox>
> >
> > And also note that to have some values selected when
> > the page is
> > loaded you have to use the @value attribute.
> >
> > Regards,
> >
> > Bruno
> >
> > 2005/10/11, Caroline Jen <[EMAIL PROTECTED]>:
> > > I used the UISelectItem to set its value to the
> > > SelectItem (I have many SelectItme).  Then,  I
> > added
> > > each UISelectItem to the UISelectMany .  When I
> > > displayed a list box, I got the runtime error:
> > >
> > > "IllegalArgumentException: argument type mismatch"
> > >
> > > In my JSP, I create a list box for multiple
> > > selections:
> > >
> > > [code]
> > >         <h:selectManyListbox
> > > binding="#{fileManagementBean.dataFile}" size="7"
> > >
> > >             <f:selectItems
> > > value="#{fileManagementBean.dataFileItems}"/>
> > >         </h:selectManyListbox>
> > > [/code]
> > >
> > > Therefore, the "dataFileItems" is of type
> > UISelectMany
> > > that has elements of type UISelectItem.  The
> > multiple
> > > selections that users make will be in a String
> > array:
> > > String[] dataFile.  Did I mess up anything here?
> > My
> > > backing bean code is like:
> > >
> > > [code]
> > > .....
> > > .....
> > > public class FileManagementBean
> > > {
> > >         private String[] dataFile;
> > >         private UISelectMany dataFileItems;
> > >
> > >         public FileManagementBean()
> > >         {
> > >                 dataFileItems = new
> > UISelectMany();
> > >                 UISelectItem item = new
> > UISelectItem();
> > >
> > >                 SelectItem file = new SelectItem(
> > "file1", "Data
> > > File No. 1");
> > >                 item.setValue( file );
> > >                 dataFileItems.getChildren().add(
> > item );
> > >                 file = new SelectItem( "file2",
> > "Data File No. 2");
> > >                 item.setValue( file );
> > >                 dataFileItems.getChildren().add(
> > item );
> > > .....
> > > .....
> > >         }
> > >
> > >         public String[] getDataFile() {
> > >                 return dataFile;
> > >         }
> > >
> > >         public void setDataFile( String[] dataFile
> > ) {
> > >                 this.dataFile = dataFile;
> > >         }
> > >
> > >         public UISelectMany getDataFileItems() {
> > >                 return dataFileItems;
> > >         }
> > > }
> > > [/code]
> > >
> > >
> > >
> > >
> > > __________________________________
> > > Yahoo! Mail - PC Magazine Editors' Choice 2005
> > > http://mail.yahoo.com
> > >
> >
>
>
>
>
> __________________________________
> Yahoo! Music Unlimited
> Access over 1 million songs. Try it free.
> http://music.yahoo.com/unlimited/
>

Reply via email to