• Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

h:selectManyListbox NO VALUES returned if binding used

 
Sergey Kargopolov
Ranch Hand
Posts: 63
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
<h:selectManyListbox value="#{EventJSFBean.selectedUserFriends}" binding="#EventJSFBean.selectedMenuComponent}">

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

</h:selectManyListbox>

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;
}


selectedMenuComponent.getSelectedValues();
is always empty. But why?


if I try to do this


public UISelectMany getSelectedMenuComponent()
{
List v = selectedMenuComponent.getChildren();
Iterator i = v.iterator();
while(i.hasNext())
{
javax.faces.component.UISelectItems si = (javax.faces.component.UISelectItems )i.next();
List list = si.getChildren();
if(list==null) return "";
System.out.println(list.size());

Iterator iter = list.iterator();
while(iter.hasNext())
{
System.out.println(iter.next().getClass());
}
}

return this.selectedMenuComponent;

}

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


Please advise me what am I doing wrong?
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic