In my JSP, the 'dataFile' will contain all the
multiple selections that users make from the list box.
 I do not understand your question.  Why should the
List dataFile be initialized?

--- Volker Weber <[EMAIL PROTECTED]>
wrote:

> Hi,
> 
> where did you initialize the List dataFile?
> you posted the code incompletly.
> 
> but from your exception it looks like
>   return dataFile.toArray();
> throws a java.lang.NullPointerException.
> 
> Bye
> 
> Caroline Jen wrote:
> > I have gotten rid of the "Argument Type Mismatch"
> > problem.  
> > 
> > I found that if I use UISelectMany, user
> selections
> > from a list box will be in an Object[].
> > 
> > But, I got another runtime error:
> > "EvaluationException: Error getting property
> > 'dataFile' from bean of type
> > actions.FileManagementBean:
> > java.lang.NullPointerException'
> > 
> > Maybe people could help me better now.  I have the
> > getter and setter for the property 'dataFile' in
> my
> > backing bean.  Let me repeat my code.  In my JSP,
> I
> > create a list box:
> > [code]
> > <h:selectManyListbox
> > binding="#{fileManagementBean.dataFile}" size="7"
> >
> >     <f:selectItems
> > value="#{fileManagementBean.dataFileItems}"/>
> > </h:selectManyListbox>
> > [/code]
> > And this is my backing bean:
> > [code]
> > public class FileManagementBean 
> > {
> >     private UISelectMany dataFileItems;
> >     protected List dataFile;
> >     
> >     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 Object[] getDataFile() 
> >     {
> >             return dataFile.toArray();
> >     }
> >     
> >     public void setDataFile( Object[] newDataFile ) 
> >     {
> >         int len = 0;
> >             if ( null == newDataFile ||
> >                ( len = newDataFile.length) == 0) 
> >             {
> >                 return;
> >             }
> >             dataFile.clear();
> >             dataFile = new ArrayList( len );
> >             for ( int i = 0; i < len; i++ ) 
> >             {
> >                 dataFile.add( newDataFile[i] );
> >                 }   
> >     }
> >     
> >     public UISelectMany getDataFileItems() 
> >         {
> >             return dataFileItems;
> >     }
> > }
> > [/code]
> > 
> > 
> > 
> > --- Caroline Jen <[EMAIL PROTECTED]> wrote:
> > 
> > 
> >>Hi, I had known how to create selectManyListbox. 
> >>Two
> >>weeks before I posted my question, I had
> >>successfully
> >>used a List of SelectItem to create a list box.  I
> >>do
> >>not want to have pre-selected items when the web
> >>page
> >>is loaded into the browser.
> >>
> >>My problem occurred when I changed the
> dataFileItems
> >>from List to UISelectMany, I started getting
> >>"argument
> >>type mismatch".  
> >>
> >><h:selectManyListbox
> >>binding="#{fileManagementBean.dataFile}" size="7"
> >
> >>    <f:selectItems
> >>value="#{fileManagementBean.dataFileItems}"/>
> >></h:selectManyListbox>
> >>
> >>I am working on how to resolve my current problem.
> >>
> >>Besides, someone advised that "dataFile" should be
> >>of
> >>type SelectItem[].  Therefore, I changed the type
> of
> >>the "dataFile" from String[] to SelectItem[].  I
> >>still
> >>have argument type mismatch problem.
> >>
> >>--- Bruno Aranda <[EMAIL PROTECTED]> wrote:
> >>
> >>
> >>>Mmmh, if I understood you ok at the beginning we
> >>>have two objectives:
> >>>
> >>>#1 - Have a list filled dinamically with
> >>
> >>SelectItem
> >>
> >>>objects
> >>>#2 - Some of the elements of the list are
> >>>pre-selected when the page loads.
> >>>
> >>>To do #1 we need to use the f:selectItems
> >>
> >>components
> >>
> >>>with a value that
> >>>points to an array/List of SelectItem objects in
> >>
> >>the
> >>
> >>>backing bean.
> >>>Something like this:
> >>>
> >>>[jsp]
> >>>
> >>><h:selectManyListBox>
> >>>  <f:selectItems
> >>>value="#{fileManagementBean.listOfSelectItems}"/>
> >>></h:selectManyListBox>
> >>>
> >>>[/jsp]
> >>>
> >>>Notice that I have used the value attribute of
> the
> >>>selectItems
> >>>component, instead of the binding... The backing
> >>>bean code should be,
> >>>in this case:
> >>>
> >>>[code]
> >>>
> >>>public class FileManagementBean
> >>>{
> >>>       private List listOfSelectItems
> >>>
> >>>       public FileManagementBean()
> >>>       {
> >>>               listOfSelectItems = new
> >>
> >>ArrayList();
> >>
> >>>               SelectItem file = new SelectItem(
> >>>"file1", "Data
> >>>File No. 1");
> >>>               listOfSelectItems.add( file );
> >>>
> >>>               SelectItem file2 = new SelectItem(
> >>>"file2", "Data File No. 2");
> >>>               listOfSelectItems.add( file2 );
> >>>.....
> >>>.....
> >>>       }
> >>>
> >>>       public List getListOfSelectItems() {
> >>>               return dataFileItems;
> >>>       }
> >>>
> >>>     public void setListOfSelectItems(List
> >>>listOfSelectItems) {
> 
=== message truncated ===



        
                
__________________________________ 
Yahoo! Mail - PC Magazine Editors' Choice 2005 
http://mail.yahoo.com

Reply via email to