Programmatically jump to a link in a dynamic HTML page

Previous Topic Next Topic
 
classic Classic list List threaded Threaded
2 messages Options
Reply | Threaded
Open this post in threaded view
|

Programmatically jump to a link in a dynamic HTML page

Ulli Hafner-2
Hi,

Is there a way to programmatically jump to a link (linenumber) in a dynamic HTML page? In my tasks plugin 1.6 the results are presented in an overview page with links to the actual files. When clicking on the link I use the following method to create a detail object that is capable of displaying the source file:

On the Stapler TaskResult Summary Object (URL: build/taskResult):

    public Object getDynamic(final String subLink, final StaplerRequest request, final StaplerResponse response) {
        return new TaskDetail(owner, subLink);
    }

Then the HTML page represented by the index.jelly of the TaskDetail is shown (URL: build/taskResult/subLink), the visible area is at the top of the page.
What I actually would like to see is the same index.jelly, but already scrolled to the corresponding line number (which is given by a link anchor in the HTML page). Is this possible programatically? (Currently I placed the actual link at the top, i.e., the user needs to click twice to scroll to the task).

Ulli
--
Avaloq - essential for banking.

Avaloq Evolution AG
Allmendstrasse 140, 8027 Z├╝rich
T +41 44 488 6790, F +41 44 488 6868, http://www.avaloq.com 
Dr. Ullrich Hafner mailto:[hidden email]

---------------------------------------------------------------------
To unsubscribe, e-mail: [hidden email]
For additional commands, e-mail: [hidden email]

Reply | Threaded
Open this post in threaded view
|

Re: Programmatically jump to a link in a dynamic HTML page

Kohsuke Kawaguchi
Administrator
Hafner Ullrich wrote:
> Hi,
>
> Is there a way to programmatically jump to a link (linenumber) in a
> dynamic HTML page? In my tasks plugin 1.6 the results are presented in
> an overview page with links to the actual files. When clicking on the
> link I use the following method to create a detail object that is
> capable of displaying the source file:



>
> On the Stapler TaskResult Summary Object (URL: build/taskResult):
>
>     public Object getDynamic(final String subLink, final StaplerRequest request, final StaplerResponse response) {
>         return new TaskDetail(owner, subLink);
>     }
>
> Then the HTML page represented by the index.jelly of the TaskDetail is
> shown (URL: build/taskResult/subLink), the visible area is at the top of
> the page.
 >
> What I actually would like to see is the same index.jelly, but already
> scrolled to the corresponding line number (which is given by a link
> anchor in the HTML page). Is this possible programatically? (Currently I
> placed the actual link at the top, i.e., the user needs to click twice
> to scroll to the task).

Normal technique is to use page anchors. For example, you can have
TaskDetail/index.jelly generate

   <a name="L5"></a>
   <a name="L6"></a>
   <a name="L7"></a>

...

and then you can link to arbitrary line number by using
"path/to/page#L123" or something

--
Kohsuke Kawaguchi
Sun Microsystems                   [hidden email]

smime.p7s (4K) Download Attachment