File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
The moose likes JSF and the fly likes h:selectManyListbox NO VALUES returned if binding used Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Java » JSF
Bookmark "h:selectManyListbox NO VALUES returned if binding used" Watch "h:selectManyListbox NO VALUES returned if binding used" New topic

h:selectManyListbox NO VALUES returned if binding used

Sergey Kargopolov
Ranch Hand

Joined: Jul 04, 2003
Posts: 63
<h:selectManyListbox value="#{EventJSFBean.selectedUserFriends}" binding="#EventJSFBean.selectedMenuComponent}">

<f:selectItems value="#{EventJSFBean.userFriends}"/>


When I click on Submit button method getSelectedUserFriends() returns me correct values. That tells me that selected values are being submited. But selectedMenuComponent(which is my binding) is always empty. I cannot access values thru compoment UISelectMany. Please help me to find where I am wrong.

public UISelectMany getSelectedMenuComponent()
System.out.println("Here in getSelectMenuComponent()");
Object[] selectedUsers = selectedMenuComponent.getSelectedValues(); // THIS IS ALWAYS EMPTY, EVEN WHEN FORM IS SUBMITED. WHY?
return this.selectedMenuComponent;

is always empty. But why?

if I try to do this

public UISelectMany getSelectedMenuComponent()
List v = selectedMenuComponent.getChildren();
Iterator i = v.iterator();
javax.faces.component.UISelectItems si = (javax.faces.component.UISelectItems );
List list = si.getChildren();
if(list==null) return "";

Iterator iter = list.iterator();

return this.selectedMenuComponent;


Children of UISelectMany are also empty.. meaning zero is returned.

Please advise me what am I doing wrong?
I agree. Here's the link:
subject: h:selectManyListbox NO VALUES returned if binding used
It's not a secret anymore!