This week's giveaway is in the Android forum.
We're giving away four copies of Android Security Essentials Live Lessons and have Godfrey Nolan on-line!
See this thread for details.
The moose likes JSF and the fly likes Facing Problem in JSF form SelectItem[] Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Android Security Essentials Live Lessons this week in the Android forum!
JavaRanch » Java Forums » Java » JSF
Bookmark "Facing Problem in JSF form SelectItem[]" Watch "Facing Problem in JSF form SelectItem[]" New topic
Author

Facing Problem in JSF form SelectItem[]

Ankit Thakkar
Ranch Hand

Joined: Apr 29, 2005
Posts: 33

Hello ALL,

I am working in Combobox in JSF, I am setting data of combo from database,

1)
JSP Part is :
<h:selectOneMenu styleClass="selectOneMenu" id="menu1"
value="#{pc_Index.selectedData}">
<f:selectItems value="#{pc_Index.listData}"/>
</h:selectOneMenu>

Backing Bean :
I am getting SelectItem[] from Method getData,
SelectItem[] listData = getData();

But I am getting error like :
java.lang.IllegalArgumentException: "{2}" Conversion Error setting value ''{0}'' for ''{1}''


2)
Now when I am doing same thing using ArrayList then it working fine.

JSP Part is :
<h:selectOneMenu styleClass="selectOneMenu" id="menu1"
value="#{pc_Index.selectedData}">
<f:selectItems value="#{pc_Index.arrayList}"/>
</h:selectOneMenu>

Backing Bean :
I am getting SelectItem[] from Method getData,
I am explicitly converting SelectItem[] into ArrayList means I am adding one SelectItem at a time from for loop to arrayList.
So It is working fine in JSP.

Can anybody have any idea regarding this error, Am I doing something wrong in my code?
Please reply ASAP.


- Ankit
David O'Meara
Rancher

Joined: Mar 06, 2001
Posts: 13459

"Bunty",
Welcome to the JavaRanch.

We're a friendly group, but we do require members to have valid display names.

Display names must be two words: your first name, a space, then your last name. Fictitious names are not allowed.

Please edit your profile and correct your display name since accounts with invalid display names get deleted, often without warning

thanks,
Dave
Ankit Thakkar
Ranch Hand

Joined: Apr 29, 2005
Posts: 33

Ya David, I have updated my Profile.
Sajan Patel
Ranch Hand

Joined: Oct 25, 2004
Posts: 77
But I am getting error like :
java.lang.IllegalArgumentException: "{2}" Conversion Error setting value ''{0}'' for ''{1}''


Normally, This error occur when your list object is NULL.
Try debug statement on getter method to see is it been called or not.
Paul Swarnapandian
Greenhorn

Joined: Mar 04, 2007
Posts: 1
The problem could be that you have not mapped the bean properly in faces-config.xml
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: Facing Problem in JSF form SelectItem[]
 
Similar Threads
Value Change Listener
selectOneMenu
Validation Error on SelectOneMenu
on change combo box not working.
Bean Value is always Null