Add javascript every request

classic Classic list List threaded Threaded
4 messages Options
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

Add javascript every request

Nathan Quirynen
Hi,

I want to add a session timeout warning popup to a Tapestry5.4
application. I thought of creating a javascript module that counts down
the remaining time left before the session times out and then shows a
popup warning with the option to logout or keep on going and if no
action is taken automatically logs out the user. But I'm not sure
where/when I can/should add this javascript module to the response. I
think I need to start or reset this count down every request (normal and
xhr) as this "resets" the sessions timeout and maybe exclude some pages
that have a specific annotation (NoSessionRequired). I thought of
implementing a component request filter to solve this, but there's no
JavaScriptSupport available there. How can I do this?

Nathan


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

Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

Re: Add javascript every request

David Diaz
Hi Nathan,

You can use a <t:trigger> in your main Layout.tml.

For example, in your Layout.tml

<html xmlns:t="http://tapestry.apache.org/schema/tapestry_5_4_1.xsd">
    <body>
        <t:trigger event="sessionTimeout"/>
    </body>
</html>

Then in your Layout.java

public void onSessionTimeout()
{
     ajaxResponseRenderer.addCallback(**do callback stuff here**);
}

I've implemented this in my application - if you need more help, ill be
happy to help!

Thanks,
David.

On Wed, Dec 7, 2016 at 9:26 PM, Nathan Quirynen <[hidden email]
> wrote:

> Hi,
>
> I want to add a session timeout warning popup to a Tapestry5.4
> application. I thought of creating a javascript module that counts down the
> remaining time left before the session times out and then shows a popup
> warning with the option to logout or keep on going and if no action is
> taken automatically logs out the user. But I'm not sure where/when I
> can/should add this javascript module to the response. I think I need to
> start or reset this count down every request (normal and xhr) as this
> "resets" the sessions timeout and maybe exclude some pages that have a
> specific annotation (NoSessionRequired). I thought of implementing a
> component request filter to solve this, but there's no JavaScriptSupport
> available there. How can I do this?
>
> Nathan
>
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: [hidden email]
> For additional commands, e-mail: [hidden email]
>
>
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

Re: Add javascript every request

Thiago H. de Paula Figueiredo
Hi!

Another solution, specially if you don't have a single layout component for
all the pages, would be creating a mixin to include the JavaScript you
want, plus implementing and contributing a ComponentClassTransformWorker to
apply it to all pages. I can provide you examples if you want.

On Wed, Dec 7, 2016 at 9:20 AM, David Diaz <[hidden email]> wrote:

> Hi Nathan,
>
> You can use a <t:trigger> in your main Layout.tml.
>
> For example, in your Layout.tml
>
> <html xmlns:t="http://tapestry.apache.org/schema/tapestry_5_4_1.xsd">
>     <body>
>         <t:trigger event="sessionTimeout"/>
>     </body>
> </html>
>
> Then in your Layout.java
>
> public void onSessionTimeout()
> {
>      ajaxResponseRenderer.addCallback(**do callback stuff here**);
> }
>
> I've implemented this in my application - if you need more help, ill be
> happy to help!
>
> Thanks,
> David.
>
> On Wed, Dec 7, 2016 at 9:26 PM, Nathan Quirynen <
> [hidden email]
> > wrote:
>
> > Hi,
> >
> > I want to add a session timeout warning popup to a Tapestry5.4
> > application. I thought of creating a javascript module that counts down
> the
> > remaining time left before the session times out and then shows a popup
> > warning with the option to logout or keep on going and if no action is
> > taken automatically logs out the user. But I'm not sure where/when I
> > can/should add this javascript module to the response. I think I need to
> > start or reset this count down every request (normal and xhr) as this
> > "resets" the sessions timeout and maybe exclude some pages that have a
> > specific annotation (NoSessionRequired). I thought of implementing a
> > component request filter to solve this, but there's no JavaScriptSupport
> > available there. How can I do this?
> >
> > Nathan
> >
> >
> > ---------------------------------------------------------------------
> > To unsubscribe, e-mail: [hidden email]
> > For additional commands, e-mail: [hidden email]
> >
> >
>



--
Thiago
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

Re: Add javascript every request

Nathan Quirynen
Would this cover all requests? My application uses a lot of ajax, so
preferably the countdown script would reset on every request (xhr or non
xhr) right?


On 07/12/16 12:47, Thiago H. de Paula Figueiredo wrote:

> Hi!
>
> Another solution, specially if you don't have a single layout component for
> all the pages, would be creating a mixin to include the JavaScript you
> want, plus implementing and contributing a ComponentClassTransformWorker to
> apply it to all pages. I can provide you examples if you want.
>
> On Wed, Dec 7, 2016 at 9:20 AM, David Diaz <[hidden email]> wrote:
>
>> Hi Nathan,
>>
>> You can use a <t:trigger> in your main Layout.tml.
>>
>> For example, in your Layout.tml
>>
>> <html xmlns:t="http://tapestry.apache.org/schema/tapestry_5_4_1.xsd">
>>      <body>
>>          <t:trigger event="sessionTimeout"/>
>>      </body>
>> </html>
>>
>> Then in your Layout.java
>>
>> public void onSessionTimeout()
>> {
>>       ajaxResponseRenderer.addCallback(**do callback stuff here**);
>> }
>>
>> I've implemented this in my application - if you need more help, ill be
>> happy to help!
>>
>> Thanks,
>> David.
>>
>> On Wed, Dec 7, 2016 at 9:26 PM, Nathan Quirynen <
>> [hidden email]
>>> wrote:
>>> Hi,
>>>
>>> I want to add a session timeout warning popup to a Tapestry5.4
>>> application. I thought of creating a javascript module that counts down
>> the
>>> remaining time left before the session times out and then shows a popup
>>> warning with the option to logout or keep on going and if no action is
>>> taken automatically logs out the user. But I'm not sure where/when I
>>> can/should add this javascript module to the response. I think I need to
>>> start or reset this count down every request (normal and xhr) as this
>>> "resets" the sessions timeout and maybe exclude some pages that have a
>>> specific annotation (NoSessionRequired). I thought of implementing a
>>> component request filter to solve this, but there's no JavaScriptSupport
>>> available there. How can I do this?
>>>
>>> Nathan
>>>
>>>
>>> ---------------------------------------------------------------------
>>> To unsubscribe, e-mail: [hidden email]
>>> For additional commands, e-mail: [hidden email]
>>>
>>>
>
>


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

Loading...