You could change the part where the children are added to the form but I'm not sure if this done using a method addChildren or via getChildren().add(obj). If the last option is used then this will become impossible. You could also override the restoreState method in your form object and first call the super class and then do your initialization of the children.

These are just some solutions from the top of my head so I haven't tested them. These solutions would prevent you from overriding getChildren which isn't a wise course of action.

Martyn


Where's the correct place to initialize a JSF custom component (in this case,
a subclass of HtmlForm)? Because much of my initializing involves
manipulating the component's children components, I decided to override
getChildren() and do my initialization there - BAD IDEA!

...it turns out that getChildren() is called BEFORE restoreState(), so when
you submit the form, restoreState isn't called and getChildren() fails
because it's in an uninitialized state.

I was thinking about using initializers or constructors, but then I figured
to avoid it because some initialization could depend on the component
properties getting populated first. (And initializers/constructors would be
called before those properties get populated, via their setters.)

It looks like I'm running out of options - what's the best practice on this?
Thanks.

Reply via email to