Assuming you are using JSP, how are using this on your page? With your own taglib or binding to an existing instance? If you are simply binding a standard HtmlPanelGrid and then declaring child components, you will need to bind any nested components as well.

--
James Mitchell




On Jul 13, 2006, at 10:01 AM, David Delbecq wrote:

Hello all,

Starting to learn JSF, i tried to create my custom UI component. Because
it will be made of several fields and button, i decided to extends
HTMLPanelGrid. The constructor creates the various components part of
the Panel. After getting "funny" errors in console, i worked on a step
by step and noticed in restore view, myfaces does inject childs in my
component (so the number of child is double: those created at
intanciation of my component and those saved from previous instance and
injected as part of restore view).

My question is, considering the way i do it for now (which is bad ;) ),
what is the best way to avoid this restore view problem. How can my
component know if it is in a state where it need to create itself it's
children or in a state where the controller will restore the children
tree itself?

Thank for help.

public class HTMLAddressComponent extends HtmlPanelGrid implements
        NamingContainer {
.....

    public HTMLAddressComponent(){
        street = new HtmlInputText();
        number = new HtmlInputText();
        town = new HtmlInputText();
        postCode = new HtmlInputText();
        command = new HtmlCommandButton();
        command.setValue("enable/disable");
        street.setId("street");
        number.setId("number");
        town.setId("town");
        postCode.setId("postCode");
        command.setId("command");
        List childs = getChildren();
        HtmlPanelGroup group = new HtmlPanelGroup();
        List l = group.getChildren();
        l.add(getText("Street: "));
        l.add(street);
        l.add(getText("Number: "));
        l.add(number);
        childs.add(group);
        group = new HtmlPanelGroup();
        l = group.getChildren();
        l.add(getText("postcode: "));
        l.add(postCode);
        l.add(getText("Town: "));
        l.add(town);
        childs.add(group);
        childs.add(command);
    }
    private UIComponent getText(String value){
        HtmlOutputText text = new HtmlOutputText();
        text.setValue(value);
        return text;
    }




Reply via email to