users@javaserverfaces.java.net

Binding to a Select One

From: TomSimmons <tom.simmons1_at_ge.com>
Date: Wed, 23 Jul 2008 05:49:08 -0700 (PDT)

I have the following code in my backing bean....

public UISelectOne getDrop()
    {
        if (drop == null)
            drop = new UISelectOne();
        
        UISelectItems items = new UISelectItems();
        
        for (int i = 0; i < 5; i++)
        {
            UISelectItem item = new UISelectItem();
            item.setItemLabel(String.valueOf(i));
            item.setItemValue(String.valueOf(i));
            items.getChildren().add(item);
        }
        
        drop.getChildren().add(items);
        
        return drop;
    }

...and in the JSP I have....

<h:selectOneMenu binding="#{Reports.drop}"/>

The problem is I always get the following error.....

Expected a child component type of UISelectItem/UISelectItems for component
type javax.faces.SelectOne(j_id_id47). Found null.

By inspecting the drop object just before it get's returned I can see that
it contains a UISelectItems,. which has the parent set correctly, and I can
seel the UISelectItems has multiple UISelectItem object in it, with their
parent set correctly.

I know this is not the normal way of doing this, but the final goal is
actually to build all these components in to a dynamically generated
UIPanelGrid and bind that in the JSP - its a totally dynamic report
parameter screen. Label, input text and panel grid binding works ok, just
this SelectOne that is causing me a problem.

Tom

-- 
View this message in context: http://www.nabble.com/Binding-to-a-Select-One-tp18610023p18610023.html
Sent from the javaserverfaces users mailing list archive at Nabble.com.