Based on Hugo's suggestion:

1.  The component class...

public abstract class Scroller extends BaseComponent
{
    @Parameter(required=true)
    public abstract String getElementId();

    @Asset("/WEB-INF/Scroller.script")
    public abstract IAsset getScriptAsset();
}

2.  The script file...

<!DOCTYPE script PUBLIC
        "-//Apache Software Foundation//Tapestry Script Specification
3.0//EN"
        "http://jakarta.apache.org/tapestry/dtd/Script_3_0.dtd";>
<script>
    <input-symbol key="elementId" required="yes"/>

    <body>
        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;
            if (obj.offsetParent)
            {
                while (obj.offsetParent)
                {
                    curtop += obj.offsetTop
                    obj = obj.offsetParent;
                }
            }
            else if (obj.y)
                curtop += obj.y;
            return curtop;
        }
    </body>
    <initialization>
        var element = document.getElementById('${elementId}');
        if( element != null )
        {
          scrollTo(findPosX(element), findPosY(element));
        }
    </initialization>

</script>       

3.  The HTML template...

<span jwcid="@If" condition="ognl:elementId != null">
    <span jwcid="@Script" scriptAsset="ognl:scriptAsset"
elementId="ognl:elementId"/> 
</span>

-----Original Message-----
From: Hugo Palma [mailto:[EMAIL PROTECTED] 
Sent: Thursday, July 06, 2006 11:39 AM
To: Tapestry users
Subject: Re: Focus issues...

Have u tried implementing a component to create a javascript that scrolls to
a element in the document by id ?
You can look here http://www.quirksmode.org/js/findpos.html for how to find
the position of an element.

Cheers,

Hugo

On 7/6/06, James Carman <[EMAIL PROTECTED]> wrote:
>
> All,
>
> Does anyone know how to get Tapestry to "stay put" on a screen when you
> submit the form and reshow it?  I have a form that is somewhat long.  When
> I
> use an event (like selecting something in a drop-down box) that forces a
> form submit to refresh some other parts of the screen, the screen goes
> back
> up to the top.  I would like it to just stay where it is (somewhere near
> the
> originating drop-down).  Any ideas?
>
> James
>
>
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: [EMAIL PROTECTED]
> For additional commands, e-mail: [EMAIL PROTECTED]
>
>



---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]

Reply via email to