Manipulating an ILApplication instance

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

Manipulating an ILApplication instance

ZuLuuuuuu-2
Hello,

I have some questions about ILApplication class. The first thing I
wonder is whether just 1 ILApplication instance is created per an
ILApplication subclass (and the same instance is served to the
clients) or a different instance is created for every client surfing
the web application. If only one instance is created, how can we reach
that instance? I am asking this because I created an ILApplication
subclass, but then added some new instance variables and changed the
initialize method. So, how can I resend the initialize method so that
the new instance variables are initialized? Maybe there is no need to
resend it?

Note: I did an experiment by increasing the count of counter
application. When I reload the page the count stays the same which
might be because only one instance is created (and every new client
who connects see the same count number) or there is a session going on
(and every new client who connects see 0 as the count number). But
after saving the workspace and revisiting a few minutes later the
count was reset to zero which indicates that it was a session and
actually a new instance of ILApplication is created. But I'm not sure
which one is true :)

I'm coming from ASP/PHP web programming world and using a web
framework for the first time. So, probably these are pretty basic
questions, if that is the case, sorry :)
Reply | Threaded
Open this post in threaded view
|

Re: Manipulating an ILApplication instance

Nicolas Petton
Le dimanche 16 mai 2010 à 16:16 -0700, ZuLuuuuuu a écrit :

> Hello,
>
> I have some questions about ILApplication class. The first thing I
> wonder is whether just 1 ILApplication instance is created per an
> ILApplication subclass (and the same instance is served to the
> clients) or a different instance is created for every client surfing
> the web application. If only one instance is created, how can we reach
> that instance? I am asking this because I created an ILApplication
> subclass, but then added some new instance variables and changed the
> initialize method. So, how can I resend the initialize method so that
> the new instance variables are initialized? Maybe there is no need to
> resend it?
Hi Canol,

One application is created by session. You don't have to instantiate
applications yourself, this is done automatically by the framework.

Application instances are stored in sessions. They are root objects of
stateful UIs, that's why widgets should always be stored in instance
variables, to keep their state in the application or parent widget.

As sessions have timeouts, after some time inactivity the session will
expire, so a new application instance is created for the new session,
that's why the counter is resetted (it's a new widget actually). This is
expected, as the counter widget only holds UI state.

About initialization, as long as you call "super initialize", you should
be fine :)

HTH,

Nico

signature.asc (205 bytes) Download Attachment
Reply | Threaded
Open this post in threaded view
|

Re: Manipulating an ILApplication instance

ZuLuuuuuu-2
On 17 Mayıs, 11:30, Nicolas Petton <[hidden email]> wrote:

> Hi Canol,
>
> One application is created by session. You don't have to instantiate
> applications yourself, this is done automatically by the framework.
>
> Application instances are stored in sessions. They are root objects of
> stateful UIs, that's why widgets should always be stored in instance
> variables, to keep their state in the application or parent widget.
>
> As sessions have timeouts, after some time inactivity the session will
> expire, so a new application instance is created for the new session,
> that's why the counter is resetted (it's a new widget actually). This is
> expected, as the counter widget only holds UI state.
>
> About initialization, as long as you call "super initialize", you should
> be fine :)
>
> HTH,
>
> Nico

Thanks Nico.

For further info, I also found the "ILSessionManager current
removeAllSessions" method to force all sessions to expire immediately,
which will be useful for me :)
Reply | Threaded
Open this post in threaded view
|

Re: Manipulating an ILApplication instance

Bèrto ëd Sèra
In reply to this post by Nicolas Petton
I was wondering if there is a chance to trap a "session expired" event
in order to send out a msg informing the user of what happened.

Berto

2010/5/17 Nicolas Petton <[hidden email]>:

> Le dimanche 16 mai 2010 à 16:16 -0700, ZuLuuuuuu a écrit :
>> Hello,
>>
>> I have some questions about ILApplication class. The first thing I
>> wonder is whether just 1 ILApplication instance is created per an
>> ILApplication subclass (and the same instance is served to the
>> clients) or a different instance is created for every client surfing
>> the web application. If only one instance is created, how can we reach
>> that instance? I am asking this because I created an ILApplication
>> subclass, but then added some new instance variables and changed the
>> initialize method. So, how can I resend the initialize method so that
>> the new instance variables are initialized? Maybe there is no need to
>> resend it?
>
> Hi Canol,
>
> One application is created by session. You don't have to instantiate
> applications yourself, this is done automatically by the framework.
>
> Application instances are stored in sessions. They are root objects of
> stateful UIs, that's why widgets should always be stored in instance
> variables, to keep their state in the application or parent widget.
>
> As sessions have timeouts, after some time inactivity the session will
> expire, so a new application instance is created for the new session,
> that's why the counter is resetted (it's a new widget actually). This is
> expected, as the counter widget only holds UI state.
>
> About initialization, as long as you call "super initialize", you should
> be fine :)
>
> HTH,
>
> Nico
>



--
==============================
Constitution du 24 juin 1793 - Article 35. - Quand le gouvernement
viole les droits du peuple, l'insurrection est, pour le peuple et pour
chaque portion du peuple, le plus sacré des droits et le plus
indispensable des devoirs.
Reply | Threaded
Open this post in threaded view
|

Re: Manipulating an ILApplication instance

Nicolas Petton
Le mardi 18 mai 2010 à 11:41 +0300, Bèrto ëd Sèra a écrit :
> I was wondering if there is a chance to trap a "session expired" event
> in order to send out a msg informing the user of what happened.

Not currently. But if you want I can add it :)

Nico

signature.asc (205 bytes) Download Attachment
Reply | Threaded
Open this post in threaded view
|

Re: Manipulating an ILApplication instance

Nicolas Petton
In reply to this post by Bèrto ëd Sèra
Le mardi 18 mai 2010 à 11:41 +0300, Bèrto ëd Sèra a écrit :
> I was wondering if there is a chance to trap a "session expired" event
> in order to send out a msg informing the user of what happened.

Hi bèrto,

I committed changes to be able to trigger events when the session
expires. You can do whatever you want in ILSession>>handleExpired:

This way you can close a db connection, or inform the user that his
session expired.

By default the method doesn't do anything, so you'll have to subclass
ILSession and override this method.

Something like this should work:

Iliad.ILSession subclass: MySession [


    handleExpired: aRequest [
        <category: 'events'>
        | response |

        response := ILResponse ok
            headerAt: 'refresh' put: '3';
            yourself.
       
        aRequest isTypeOfRequestForJson
            ifTrue: [response
                contentType: 'application/json';
                nextPutAll: '{''application'': ''Your session has expired''}']
            ifFalse: [response
                nextPutAll: '<html><body>Your session has expired</body></html>'].

        ILResponseNotification new
            response: response;
            signal
    ]
]

Iliad.ILSessionManager sessionClass: MySession

Cheers,
Nico

signature.asc (205 bytes) Download Attachment
Reply | Threaded
Open this post in threaded view
|

Re: Manipulating an ILApplication instance

Bèrto ëd Sèra
Thanks! Nowadays almost everyone is accustomed to see a "session
expired" message, so it's no problem if they get one, while simply
having their page reset to root without explanation was triggering
reactions more like "oh no, something doesn't work here!"

Berto

2010/5/19 Nicolas Petton <[hidden email]>:

> Le mardi 18 mai 2010 à 11:41 +0300, Bèrto ëd Sèra a écrit :
>> I was wondering if there is a chance to trap a "session expired" event
>> in order to send out a msg informing the user of what happened.
>
> Hi bèrto,
>
> I committed changes to be able to trigger events when the session
> expires. You can do whatever you want in ILSession>>handleExpired:
>
> This way you can close a db connection, or inform the user that his
> session expired.
>
> By default the method doesn't do anything, so you'll have to subclass
> ILSession and override this method.
>
> Something like this should work:
>
> Iliad.ILSession subclass: MySession [
>
>
>    handleExpired: aRequest [
>        <category: 'events'>
>        | response |
>
>        response := ILResponse ok
>            headerAt: 'refresh' put: '3';
>            yourself.
>
>        aRequest isTypeOfRequestForJson
>            ifTrue: [response
>                contentType: 'application/json';
>                nextPutAll: '{''application'': ''Your session has expired''}']
>            ifFalse: [response
>                nextPutAll: '<html><body>Your session has expired</body></html>'].
>
>        ILResponseNotification new
>            response: response;
>            signal
>    ]
> ]
>
> Iliad.ILSessionManager sessionClass: MySession
>
> Cheers,
> Nico
>



--
==============================
Constitution du 24 juin 1793 - Article 35. - Quand le gouvernement
viole les droits du peuple, l'insurrection est, pour le peuple et pour
chaque portion du peuple, le plus sacré des droits et le plus
indispensable des devoirs.
Reply | Threaded
Open this post in threaded view
|

Re: Manipulating an ILApplication instance

Nicolas Petton
Le mercredi 19 mai 2010 à 19:15 +0300, Bèrto ëd Sèra a écrit :
> Thanks! Nowadays almost everyone is accustomed to see a "session
> expired" message, so it's no problem if they get one, while simply
> having their page reset to root without explanation was triggering
> reactions more like "oh no, something doesn't work here!"

You're right. I'll try to come with something better than this. Maybe
deal with it in applications, because right now the event is handled
before any context is created for current the request.

Cheers,
Nico

signature.asc (205 bytes) Download Attachment