You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@myfaces.apache.org by Jana Parvanova <ja...@sirma.bg> on 2006/01/19 16:47:44 UTC
Custom component with children?
Hi all!
I have a strange problem while trying to create a custom component.
I extend ComponentBase and add 4 child components:
public class UIAddressInput extends UIComponentBase implements ValueHolder,
StateHolder {
....
public UIAddressInput() {
....
countryList.addValueChangeListener(new AddressChangeListener());
countryList.setImmediate(true);
countryList.setOnchange("this.form.submit( );");
getChildren().clear();
getChildren().add(countryList);
getChildren().add(regionFld);
getChildren().add(municipalityFld);
getChildren().add(siteFld);
}
I don't save/restore the children in the save/restoreState method of the
custom component.
Everything goes fine up to the form submission. I get:
java.lang.IndexOutOfBoundsException: Index: 4, Size: 4
at java.util.ArrayList.RangeCheck(ArrayList.java:547)
at java.util.ArrayList.get(ArrayList.java:322)
at
com.sirma.speedy.common.ui.component.UIAddressInput.processRestoreState(UIAddressInput.java:218)
at
javax.faces.component.UIComponentBase.processRestoreState(UIComponentBase.java:502)
at
javax.faces.component.UIComponentBase.processRestoreState(UIComponentBase.java:502)
at
org.apache.myfaces.application.jsp.JspStateManagerImpl.restoreComponentState(JspStateManagerImpl.java:129)
It occurred that in this method my component's getChildren method has 8
items instead of 4 (that is, all children are duplicated there).
Children list is ok (4) in encodeBegin, decode, saveState and restoreState
methods.
I just don't know when the children were added once more.
Any ideas?
Thanks,
Jana