I've done this in a Struts Based Proyect, but I used javascript on the
onload, here's the deal:
I had to scroll to different parts of the page depending on the method
called (Struts' DispatchAction) on the method I set the action string in
the request to identify where it was called from, and then used a
JavaScript function to find the object to scroll to depending on the
action
Hope that helps.
Matias
<input type="hidden" name="action"
value="<%=request.getParameter("method")%>">
<body onload="javascript: collateralGroupSubmit ();">
function collateralGroupSubmit() {
var returnAction = document.getElementById("action").value;
var error = document.getElementById("error");
if((returnAction == "deleteCollateralGroup" ||returnAction ==
"getCollateralGroup" || returnAction == "modifyCollateralGroup" ||
returnAction == "addCollateralGroup") && error == null ) {
var obj = document.getElementById('collateralGroupEdition');
window.scrollTo(findPosX(obj), findPosY(obj)) ;
}
}
function findPosX(obj)
{
var curleft = 0;
if (obj.offsetParent)
{
while (obj.offsetParent)
{
curleft += obj.offsetLeft
obj = obj.offsetParent;
}
}
else if (obj.x)
curleft += obj.x;
return curleft;
}
function findPosY(obj)
{
var curtop = 0;
var printstring = '';
if (obj.offsetParent)
{
while (obj.offsetParent)
{
curtop += obj.offsetTop
obj = obj.offsetParent;
}
}
else if (obj.y)
curtop += obj.y;
return curtop;
}
-----Original Message-----
From: Mike Kienenberger [mailto:[EMAIL PROTECTED]
Sent: Tuesday, December 20, 2005 12:54 PM
To: MyFaces Discussion
Subject: Re: Sort Table - Page Refreshes - Then Auto Scroll Back to the
Table
If you've enabled the AUTOSCROLL parameter in your web.xml file, you
should be seeing javascript generated like the following for each
command-link/command-button.
onclick="clear__5FtagId1_5F2();document.forms['_tagId1_2'].elements['aut
oScroll'].value=getScrolling();document.forms['_tagId1_2'].elements['_ta
gId1_2:_link_hidden_'].value='_tagId1_2:showAttachmentStatusableWorkList
';if(document.forms['_tagId1_2'].onsubmit){var
result=document.forms['_tagId1_2'].onsubmit(); if( (typeof result ==
'undefined') || result )
{document.forms['_tagId1_2'].submit();}}else{document.forms['_tagId1_2']
.submit();}return
false;"
The javascript below sets the current element (generally a
command-link) as the location to scroll to when the page reloads.
document.forms['yourFormId'].elements['autoScroll'].value=getScrolling()
;
Unfortunately, I haven't figured out how to make it scroll to any
arbitrary component on the page, but I'd think just enabling the
parameter should make it scroll back to your sorting link.
<context-param>
<param-name>org.apache.myfaces.AUTO_SCROLL</param-name>
<param-value>true</param-value>
<description>
If true, a javascript function will be rendered that is
able to restore the
former vertical scroll on every request. Convenient
feature if you have pages
with long lists and you do not want the browser page to
always jump to the top
if you trigger a link or button action that stays on the
same page.
Default: "false"
</description>
</context-param>
On 12/19/05, Mike Duffy <[EMAIL PROTECTED]> wrote:
> I have implemented a sortable table with the <t:dataTable/> tag. It's
very cool. Thx to those
> who worked on this.
>
> I am not a JavaScript guru, so I am having some trouble with something
that should be very basic:
> My sortable table is near the bottom of my page. After the page
refreshes. I'd like to
> automatically scroll back to the table.
>
> Any suggestions?
>
> Mike
>
> __________________________________________________
> Do You Yahoo!?
> Tired of spam? Yahoo! Mail has the best spam protection around
> http://mail.yahoo.com
>