掲示板

How do I use the URL parameter "scroll" correctly?

thumbnail
13年前 に Gustav Carlson によって更新されました。

How do I use the URL parameter "scroll" correctly?

New Member 投稿: 15 参加年月日: 11/03/22 最新の投稿
Hello,

I have a situation where the document lib portlet is featured way down on a page. Every time a user clicks on one of the links, the browser returns to vertical scroll position 0, and I'm desperately looking for a good way to resolve this as non-invasively as possible. (For instance, without setting portlet.url.anchor.enable=true.) I grokked some code and noticed that in /html/common/themes/bottom_js.jspf the presence of the request parameter "scroll" is evaluated and, if it exists, a JS event handler for "allPortletsReady" is registered which does the following:
document.getElementById('<%= HtmlUtil.escape(scroll) %>').scrollIntoView();

that is, it scrolls down to the element whose id is the value of the above request parameter by way of the native DOM method scrollIntoView(). Manually adding e.g. "&scroll=p_p_id_20_" to the query string does indeed trigger this functionality but what I don't understand is how to add this parameter to URLs generated through the portlet API.

Is it possible to append non-namespaced request parameters to URLs using the usual portlet tags (or possibly liferay-portlet? Or is there a far better/simpler way to make the web browser scroll down to the portlet to which the current URL points?

Regards

Gustav
thumbnail
13年前 に Gustav Carlson によって更新されました。

RE: How do I use the URL parameter "scroll" correctly?

New Member 投稿: 15 参加年月日: 11/03/22 最新の投稿
Bump
thumbnail
13年前 に Amos Fong によって更新されました。

RE: How do I use the URL parameter "scroll" correctly?

Liferay Legend 投稿: 2047 参加年月日: 08/10/07 最新の投稿
Hi Gustav,

I don't see a way to add a scroll parameter to the PortletURL object...the way I've always done it is to just add scroll to the end of portletURL like:

portletURL.toString + &scroll=abcdef

I can't think of an easy solution for your problem...maybe you can override the portletURL class to add a scroll if it's doc lib on that page.
thumbnail
13年前 に Gustav Carlson によって更新されました。

RE: How do I use the URL parameter "scroll" correctly?

New Member 投稿: 15 参加年月日: 11/03/22 最新の投稿
Hi,

and thanks for your reply!

Yeah, I was sort of expecting something like this. I've currently made a bunch of modifications to the JSPs of the portlet itself to achieve this, but in many ways it turned out a mess...

I've been grokking around in the source but I can't find the spot where the URL generation finally happens - or rather - the generation of the parameter names as Strings (with namespace prepended). Can you point me in the right direction?

Regards

Gustav
thumbnail
13年前 に Amos Fong によって更新されました。

RE: How do I use the URL parameter "scroll" correctly?

Liferay Legend 投稿: 2047 参加年月日: 08/10/07 最新の投稿
What version of Liferay are you using? I did some more digging and found out you can add scroll to portletURL without it being namespaced (it was fixed in http://issues.liferay.com/browse/LPS-9270(6.0.x). The fix was to add "scroll" to _reserverParams in PortalImpl.java).

I've been grokking around in the source but I can't find the spot where the URL generation finally happens - or rather - the generation of the parameter names as Strings (with namespace prepended). Can you point me in the right direction?


The class that generates all portletURLs is PortletURLImpl.java if you want to modify it.
thumbnail
13年前 に Gustav Carlson によって更新されました。

RE: How do I use the URL parameter "scroll" correctly?

New Member 投稿: 15 参加年月日: 11/03/22 最新の投稿
Hey, thanks a lot for pointing that out!

I definitely didn't start out with the most obvious thing to try - trying! emoticon Simply adding the parameter to the URLs does the trick. I hope others find this useful as well!

Gustav