How I should change following example that after changes values in inputText not disappears after commandButton was submitted? I'm understanding why it happens, but I don't know how to fix it.
<h:form>
    <h:selectOneMenu valueChangeListener="#{foo.selectChanges}" onchange="submit()" >
        <f:selectItem itemValue="5" itemLabel="Five"/>
        <f:selectItem itemValue="10" itemLabel="Ten"/>
    </h:selectOneMenu>
    <ui:repeat value="#{foo.repeatItems}" var="item">
        <div>
            <h:inputText value="#{item.value}"/>
        </div>
    </ui:repeat>
    <h:commandButton value="test" action="#{foo.submit}">
    </h:commandButton>
</h:form>
And bean:
public class FooBean {
    private RepeatItem[] repeatItems;
    private String value = "5";
    public String getValue() {
        return value;
    }
    public void setValue(final String value) {
        this.value = value;
    }
    public void submit() {
    }
    public void selectChanges(ValueChangeEvent e) {
        value = (String) e.getNewValue();
    }
    public RepeatItem[] getRepeatItems() {
        repeatItems = new RepeatItem[Integer.parseInt(value)];
        for (int i = 0; i < Integer.parseInt(value); i++) {
            repeatItems[i] = new RepeatItem();
        }
        return repeatItems;
    }
    public void setRepeatItems(final RepeatItem[] repeatItems) {
        this.repeatItems = repeatItems;
    }
    public static class RepeatItem {
        private String value;
        public String getValue() {
            return value;
        }
        public void setValue(final String value) {
            this.value = value;
        }
    }
}