On Tue, 07 Oct 2008, newbieabc wrote:
> I have another related question...
Often it's a good idea to start a new thread with a
descriptive subject for new questions.
> I want to change one of the Contact page form component's visibility
> property based in a parameter I set in another page.
>
> Is there a page onLoad function or something where I can check the parameter
> value and then change visibility of the component? If yes.. then where is it
> called? Or how? When ever I try to check the parameter value within the page
> constructor, I get a NullPointerException, but when the parameter is used
> for other things , like from a method called within the the Form onSubmit()
> there doesn't seem to be any problems.
Constructor is only called on construction, not rendering.
You have at least a couple of options;
FormComponent myComponentWithConditionalVisibility = new TextField("foo") {
@Override
public boolean isVisible() {
return fooFieldShouldBeBVisible();
}
}
or
FormComponent myComponentWithConditionalVisibility = new TextField("foo") {
@Override
public void onBeforeRender() {
setVisible(fooFieldShouldBeVisible());
}
}
Best wishes,
Timo
--
Timo Rantalaiho
Reaktor Innovations Oy <URL: http://www.ri.fi/ >
---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]