We are after the same behavior, as well.  During the initial page load, the
AjaxLazyLoadPanel works great.  However, after hiding/showing the image
(using an AjaxLink), the panel no longer loads.  I tried using the custom
ReloadingAjaxLazyPanel, too, and the results were the same as replacing with
a new panel instance.  Any ideas?  Below is a code snippet:

        final Label gbrowseHideShowLabel = new Label("gbrowseHideShowLabel",
new LoadableDetachableModel() {
            protected Object load() {
                return gbrowseHideShowText;
            }
        });
        gbrowseHideShowLabel.setOutputMarkupId(true);
        gbrowseLazyLoaded = getNewGbrowseLazyLoaded();
        add(gbrowseLazyLoaded);
        AjaxLink gbrowseHideShow = new AjaxLink("gbrowseHideShow") {
            public void onClick(AjaxRequestTarget target) {
                if (!gbrowseVisible) {
                    gbrowseVisible = true;
                    gbrowseHideShowText = "Hide image";
                    user.setImageViewer(true);
                } else {
                    gbrowseVisible = false;
                    gbrowseHideShowText = "Show image";
                    user.setImageViewer(false);
                }
                target.addComponent(gbrowseHideShowLabel);
                AjaxLazyLoadPanel newPanel = getNewGbrowseLazyLoaded();
                newPanel.setOutputMarkupId(true);
                getGbrowseLazyLoaded().replaceWith(newPanel);
                setGbrowseLazyLoaded(newPanel);
                target.addComponent(newPanel);
            }
        };
        gbrowseHideShow.add(gbrowseHideShowLabel);
        add(gbrowseHideShow);

Thanks,
Ryan


igor.vaynberg wrote:
> 
> you can just replace the entire panel with a new instance.
> 
> -igor
> 
> On Sat, May 30, 2009 at 3:11 AM, Antony Stubbs <antony.stu...@gmail.com>
> wrote:
>> We use AjaxLazyLoadingPanel, and want to be able to trigger the process
>> of
>> showing the indicator, and requesting the panels contents with a separate
>> Ajax request, after the first complete render has finished. I.e. do the
>> whole process over and over, without having to reload the entire page.
>>
>> I came up with this, which I was surprised actually worked first try :)
>> gotta love Wicket.
>>
>> But perhaps there's a better way to do it ? A simpler way? Something I'm
>> missing? I tried simply replacing the lazy loading panel with a new
>> instance
>> of one but that didn't seem to have an effect - I think the magic is in
>> the
>> adding a new AbstractAjaxBehaviour on each request.
>>
>>
>> import org.apache.wicket.Component;
>> import org.apache.wicket.ajax.AbstractDefaultAjaxBehavior;
>> import org.apache.wicket.ajax.AjaxRequestTarget;
>> import org.apache.wicket.extensions.ajax.markup.html.AjaxLazyLoadPanel;
>> import org.apache.wicket.markup.html.IHeaderResponse;
>>
>> /**
>>  * An {...@link AjaxLazyLoadPanel} extension which allows it to
>>  * {...@link #restart(AjaxRequestTarget)} the process of showing the loading
>>  * indicator, then load it's contents using a separate Ajax request.
>>  *
>>  * @author Antony Stubbs
>>  */
>> abstract public class ReloadingAjaxLazyPanel extends AjaxLazyLoadPanel {
>>
>>    private static final long serialVersionUID = 1L;
>>
>>    public ReloadingAjaxLazyPanel(String id) {
>>        super( id );
>>    }
>>
>>    /**
>>     * Causes the {...@link AjaxLazyLoadPanel} to re-display the loading
>> indicator,
>>     * then in a seperate ajax request, get it's contents.
>>     *
>>     * @param target
>>     */
>>    public void restart(AjaxRequestTarget target) {
>>        target.addComponent( this );
>>
>>        // replace panel contents with loading icon
>>        Component loadingComponent = getLoadingComponent( "content" );
>>
>>        this.replace( loadingComponent );
>>
>>        // add ajax behaviour to install call back
>>        loadingComponent.add( new AbstractDefaultAjaxBehavior() {
>>
>>            private static final long serialVersionUID = 1L;
>>
>>           �...@override
>>            protected void respond(AjaxRequestTarget target) {
>>                Component component =
>> ReloadingAjaxLazyPanel.this.getLazyLoadComponent( "content" );
>>                ReloadingAjaxLazyPanel.this.replace(
>> component.setRenderBodyOnly( true ) );
>>                target.addComponent( ReloadingAjaxLazyPanel.this );
>>                // setState((byte)2);
>>            }
>>
>>           �...@override
>>            public void renderHead(IHeaderResponse response) {
>>                super.renderHead( response );
>>                response.renderOnDomReadyJavascript(
>> getCallbackScript().toString() );
>>            }
>>
>>        } );
>>    }
>>
>> }
>>
>> As you can see, there is duplication from AjaxLazyLoadingPanel - which
>> would
>> need re-factoring in order to remove. - no problem there.
>> But also, because the setState method is private, I can't use that state
>> system.
>>
>> Regards,
>> Antony Stubbs,
>> NZ
>> http://friendfeed.com/astubbs
>>
>>
> 
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: users-unsubscr...@wicket.apache.org
> For additional commands, e-mail: users-h...@wicket.apache.org
> 
> 
> 

-- 
View this message in context: 
http://old.nabble.com/Restarting-AjaxLazyLoadingPanel-tp23792018p26325186.html
Sent from the Wicket - User mailing list archive at Nabble.com.


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

Reply via email to