Hi,

i'm a bit confused about what you want to do.

Lets clear up by consructing an example:

If i understand you correct you want your application to provide a
component (UISelectMany) which is rendered as a listbox
(<select size=5 ...> <option ... >label</option>+ </select>).

The items should created by application and put into the component.


The Bean class:
===============================================================================
package org.apache.myfaces.examples;

import javax.faces.component.UISelectMany;
import javax.faces.component.UISelectItems;
import javax.faces.model.SelectItem;
import java.util.List;
import java.util.ArrayList;

public class TestBean {

  private UISelectMany selectMany;

  private Object[] selectedItems;

  public TestBean() {
    selectMany = new UISelectMany();
    selectMany.setId("selectMany");

    UISelectItems items = new UISelectItems();
    items.setId("selectManyItems");
    items.setValue(createSelectItems());

    selectMany.getChildren().add(items);
  }

  private Object createSelectItems() {
    List items = new ArrayList();
    for (int i = 0; i < 10; i++){
      items.add(new SelectItem("item" + i, "Item No. " + i));
    }
    return items;
  }

  public UISelectMany getSelectMany() {
    return selectMany;
  }

  public void setSelectMany(UISelectMany selectMany) {
    this.selectMany = selectMany;
  }

  public Object[] getSelectedItems() {
    return selectedItems;
  }

  public void setSelectedItems(Object[] selectedItems) {
    this.selectedItems = selectedItems;
  }
}
===============================================================================

and the jsp page:
===============================================================================
<%@ page import="org.apache.myfaces.examples.TestBean"%>
<%@ taglib uri="http://java.sun.com/jsf/html"; prefix="h"%>
<%@ taglib uri="http://java.sun.com/jsf/core"; prefix="f"%>

<%
  Object testbean = pageContext.getAttribute(
      "TestBean", PageContext.SESSION_SCOPE);
  if (testbean == null) {
    pageContext.setAttribute(
        "TestBean", new TestBean(), PageContext.SESSION_SCOPE);
  }
%>

<html>
<body>
<f:view>
  <h:form>

    <h:selectManyListbox id="selectMany"
        binding="#{TestBean.selectMany}"
        value="#{TestBean.selectedItems}" />

    <h:commandButton value="Submit"/>

  </h:form>
</f:view>
</body>
</html>
===============================================================================


If this is what you want to do, it should be easy to adapt it to your needs.

If not you shoud explain a bit clearer what you want.

Regards

  Volker Weber

Caroline Jen wrote:
> I understand what you are talking about.  I created
> select one and select many long time ago without any
> problem.
> 
> I think the conclusion is that it is NOT POSSIBLE to
> supply a UISelectMany to render a list box.  Is it
> correct?
> 

-- 
Don't answer to From: address!
Mail to this account are droped if not recieved via mailinglist.
To contact me direct create the mail address by
concatenating my forename to my senders domain.

Reply via email to