You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@wicket.apache.org by Stephan Koch <sk...@remove-n0spam.sk-dev.com> on 2008/03/21 10:54:22 UTC

Panel setVisible() in Ajax call

Hi all,

I have a Page with a DropDown Component and a Panel. The Panel displays 
some stuff based on the model object of the DropDown.
In the constructor of my page, I set panel.setVisible(false) to prevent 
the panel from being rendered while the model object of the DropDown is 
null because the user has not yet selected an option.

Now I want the Panel to be rendered once a valid choice is selected by 
the user. I tried this:

protected void onEvent(AjaxRequestTarget target) {
                log.debug("ddMonth onChange triggered.");
                if(month != null) {
                    reportPanel.setVisible(true);
                    reportPanel.updatePanel(getServiceManager(), 
getUser(), month);
                    target.addComponent(reportPanel); 
                }
}


The event is triggered, the panel is not rendered though. Is there a way 
to achieve this without reloading the entire page?
If not, how would I trigger a page reload from the onEvent method?

Thanks,
Stephan

---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@wicket.apache.org
For additional commands, e-mail: users-help@wicket.apache.org


Re: Panel setVisible() in Ajax call

Posted by Timo Rantalaiho <Ti...@ri.fi>.
On Fri, 21 Mar 2008, Gerolf Seitz wrote:
> if you set the panel to be invisible on first render,
> you also have to call panel.setOutputMarkupPlaceholderTag(true) so that
> a "hidden" placeholder is rendered, which gets replaced with the real panel
> once you set it to visible and add it to the ajaxrequestarget.

...and when this is the case, you should see an error about
it on the Ajax debug console (Wicket javascript complaining
about how it cannot find the specified element in HTML.

Best wishes,
Timo

-- 
Timo Rantalaiho           
Reaktor Innovations Oy    <URL: http://www.ri.fi/ >

---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@wicket.apache.org
For additional commands, e-mail: users-help@wicket.apache.org


Re: Panel setVisible() in Ajax call

Posted by Gerolf Seitz <ge...@gmail.com>.
if you set the panel to be invisible on first render,
you also have to call panel.setOutputMarkupPlaceholderTag(true) so that
a "hidden" placeholder is rendered, which gets replaced with the real panel
once you set it to visible and add it to the ajaxrequestarget.

  Gerolf

On Fri, Mar 21, 2008 at 10:54 AM, Stephan Koch <sk...@remove-n0spam.sk-dev.com>
wrote:

> Hi all,
>
> I have a Page with a DropDown Component and a Panel. The Panel displays
> some stuff based on the model object of the DropDown.
> In the constructor of my page, I set panel.setVisible(false) to prevent
> the panel from being rendered while the model object of the DropDown is
> null because the user has not yet selected an option.
>
> Now I want the Panel to be rendered once a valid choice is selected by
> the user. I tried this:
>
> protected void onEvent(AjaxRequestTarget target) {
>                log.debug("ddMonth onChange triggered.");
>                if(month != null) {
>                    reportPanel.setVisible(true);
>                    reportPanel.updatePanel(getServiceManager(),
> getUser(), month);
>                    target.addComponent(reportPanel);
>                }
> }
>
>
> The event is triggered, the panel is not rendered though. Is there a way
> to achieve this without reloading the entire page?
> If not, how would I trigger a page reload from the onEvent method?
>
> Thanks,
> Stephan
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: users-unsubscribe@wicket.apache.org
> For additional commands, e-mail: users-help@wicket.apache.org
>
>