You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@wicket.apache.org by "Corbin, James" <jc...@IQNavigator.com> on 2010/02/05 05:45:28 UTC

Bring Panel into View in Browser

Hi,

 

I am dynamically adding panel components to my display and eventually
the list of panels grows big enough that the most recently added is not
visible (not in visible scroll region) in the browser.

 

I am looking for an approach to force the last panel added to scroll
into view if it's out of the visible browser view.

 

All my panels derive from a common panel implementation.  I thought I
might be able to have the base panel implementation implement
IHeaderContributor and then in the renderHead method, try to do the
following similar to the following:

 

      public void renderHead(IHeaderResponse response) {

            ...

            String js =
"document.getElementById('"+getMarkupId()+"').focus();";

            response.renderOnLoadJavascript(js);

      }

 

This does not work, but my hope was that by setting the panel to have
focus after its created, that it would scroll into view if it wasn't
already.

Assuming setting focus on a panel would even work, which I'm not sure it
would, I noticed that I am getting Debug errors in the Javascript Debug
window that the result of the "document.getElementById('<objectid>')"
call is null.

 

I've thought of using the following javascript functions,
window.scrollBy or window.scrollTo, but haven't had any luck with those.

 

Is it possible in wicket to do this?

 

Thanks,
J