I know this thread has strayed pretty far from the intent of the dev list, but
I need to update the solution I described in my previous posting.
I found a problem with using window.location.href to scroll to the anchor
location when using IE. IE sends a re-direct back to the server when the
anchor value is changed via window.location.href. Not only is that an
unnecessary round trip to the server, but it was causing errors in my portlet
because the additional render cycle did not go through the processAction
method. It send control through doView twice, the second time without any post
values.
I tried element.scrollIntoView, but it did not work on IE or Opera. There
seemed to be a timing issue with IE where it would scroll to the location but
then go to top of page. I think there may have been a conflict with the channel
id anchor on the url when using scrollIntoView with the onload event.
I was finally successful using jQuery animate. It was essential to have an
animate duration greater than 100 milliseconds for it to work consistently in
IE, but the following is a snippet of code that finally worked (anchor is the
query param value I created to indicate the anchor to scroll to):
if(anchor != null) {
var target_offset = $('a[name=' + anchor + ']').offset();
if (target_offset != null) {
var target_top = target_offset.top;
// Need to subtract 10 because Firefox positions too low on page.
if (target_top > 10) {
target_top = target_top - 10;
}
$("html, body").animate({scrollTop:target_top}, 250);
}
Paul Gazda
-----Original Message-----
From: [email protected]
[mailto:[email protected]] On Behalf Of Paul Gazda
Sent: Monday, June 21, 2010 3:56 PM
To: [email protected]
Subject: RE: [uportal-dev] Getting the anchor value from a portlet action url
Aaron,
I have implemented your suggestion, and it didn't turn out to be as much work
as I thought. I converted the anchors to a query param=value pair with the
param name being constant across the application, and the value being the
anchor name. I use the onload event to look for that param. If I find it, I set
window.location.href to the param value, which scrolls the page to the anchor
location. Sweet! I'm relieved I didn't have to kludge the framework to get this
to work. Many thanks!
Paul Gazda
-----Original Message-----
From: [email protected]
[mailto:[email protected]] On Behalf Of Aaron Brown
Sent: Tuesday, June 15, 2010 8:33 AM
To: [email protected]
Subject: Re: [uportal-dev] Getting the anchor value from a portlet action url
Paul -
Even so, you can probably still implement a javascript solution with a
little extra effort.
Presuming that your "show details" url includes a GET parameter
indicating which element to show, you might name the block with an ID
and use an onLoad-style javascript event pluck the GET param value from
the HTTP request, then scroll the window to that spot using the same
kind of window.location statement I used earlier.
I admit this is starting to look a little more kludgy, but it should be
workable.
- Aaron
On 06/15/2010 11:08 AM, Paul Gazda wrote:
> Thanks, Aaron and Steve for your suggestions. Unfortunately, we don't have
> javascript expanding the area right now. It is a full request-response to the
> server to add the details to the list. The lists can be quite large, so
> pre-populating the details and show/hiding them is not an option. Ajax would
> be an option, and we will be updating the application with more javascript
> and ajax in the future, but right now, the aim is to get it converted to a
> portlet with as few changes as possible. The application is large, with
> directory services for people, departments, groups and email aliases, so any
> re-design would involve a lot of hours. I appreciate your example, Aaron, and
> will keep it for reference when we start improvements; but right now, it's
> looking like a kludge will be the best solution to get us out of IChannel
> land. After that, we can re-design to get rid of the kludge.
>
> Paul Gazda
>
>
> -----Original Message-----
> From: [email protected]
> [mailto:[email protected]] On Behalf Of Aaron Brown
> Sent: Tuesday, June 15, 2010 6:24 AM
> To: [email protected]
> Subject: Re: [uportal-dev] Getting the anchor value from a portlet action url
>
> On 06/14/2010 05:53 PM, Paul Gazda wrote:
>> Bummer. Our problem is this. We have a directory list of people in
>> focused (maximized) mode, and if you click on an entry, it expands that
>> entry within the list to show detail, and uses an anchor in the clicked
>> url to put the clicked entry at top of page when it renders. This works
>> fine in an IChannel, but I can only think of a kludge to accomplish this
>> in a portlet. Is there a legitimate way for a portlet in focused mode to
>> do it?
>
> I think the easiest solution is Steve's - a little javascript might
> solve your problem. Here's a code sample:
>
> <ul>
>
> <li id="item_1" onClick="window.location='#item_1'"> One </li>
> <li id="item_2" onClick="window.location='#item_2'"> Two </li>
> <li id="item_3" onClick="window.location='#item_3'"> Three </li>
> <li id="item_4" onClick="window.location='#item_4'"> Four </li>
> <li id="item_5" onClick="window.location='#item_5'"> Five </li>
>
> </ul>
>
> If you construct your list element IDs with a bit of java/jsp/whatever,
> it's easy enough to use the same element ID in the window.location
> instruction. Since you already have a javascript function that expands
> the region to show extra detail, you could just add the window.location
> instruction to that existing code.
>
> - Aaron
>
--
Aaron Brown ([email protected] | 785-864-0462)
University of Kansas
Information Services
System Design
Enterprise System Integration
Developer
--
You are currently subscribed to [email protected] as:
[email protected]
To unsubscribe, change settings or access archives, see
http://www.ja-sig.org/wiki/display/JSG/uportal-dev
--
You are currently subscribed to [email protected] as:
[email protected]
To unsubscribe, change settings or access archives, see
http://www.ja-sig.org/wiki/display/JSG/uportal-dev