Hi,
I'm trying to implement a custom UIColumn that shows a checkbox against
each row that the user can check to select multiple rows. Due to issue
MYFACES-781 I can't handle decode directly in this class (UIColumns
don't get any decode callbacks) so I instead want to add a dummy
component as a child of my custom column:
public class HtmlRowSelector extends UIColumn {
public static class SelectBoolean extends UIInput {
public void decode(FacesContext context) {
log.debug("decode called. id=" + getClientId(context));
// more stuff to be added later
}
}
public HtmlRowSelector() {
setRendererType(DEFAULT_RENDERER_TYPE);
UIComponent child = new SelectBoolean();
this.getChildren().add(child);
}
...
// override encodeChildren to render a checkbox per row
}
This component renders fine when the page is first viewed. However on
first postback I get:
java.lang.IndexOutOfBoundsException: Index: 1, Size: 1
at java.util.ArrayList.RangeCheck(ArrayList.java:547)
at java.util.ArrayList.get(ArrayList.java:322)
at
javax.faces.component.UIComponentBase.processRestoreState(UIComponentBase.java:499)
at
javax.faces.component.UIComponentBase.processRestoreState(UIComponentBase.java:502)
at
javax.faces.component.UIComponentBase.processRestoreState(UIComponentBase.java:502)
at
javax.faces.component.UIComponentBase.processRestoreState(UIComponentBase.java:502)
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:155)
at
org.apache.myfaces.application.jsp.JspStateManagerImpl.restoreView(JspStateManagerImpl.java:211)
at
org.apache.myfaces.application.jsp.JspViewHandlerImpl.restoreView(JspViewHandlerImpl.java:255)
at
org.apache.myfaces.application.jsp.JspTilesViewHandlerImpl.restoreView(JspTilesViewHandlerImpl.java:320)
at
org.apache.myfaces.lifecycle.LifecycleImpl.restoreView(LifecycleImpl.java:139)
Any idea what I might be doing wrong? Commenting out the line
this.getChildren().add(child);
makes the exception go away, though of course I then can't get any
decode callbacks.
NB: I've tried marking the new child as transient, as there really isn't
any state for the child to save but that doesn't help; an exception is
thrown in the table decoding instead. I've provided a decode
implementation in SelectBoolean which just calls super.decode and logs a
message; that method is completing fine - ie it's not the SelectBoolean
class decode method that's causing the exception *directly*.
All hints/suggestions/guesses/alternatives very gratefully received!
Thanks,
Simon