Aida application instance data

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

Aida application instance data

Rob Rothwell
Can anyone help me understand where to store data specific to that instance of the application?  For example, if I use the in-place editor [ajax] demo on one computer and then I open the same page from another computer, I see what you typed on the first computer.  If I type something new and refresh the page on the first computer, I get the same result.  What I WANT to see is "private" data for that page.

When I experiment with the session object, I find the same results...a session seems to be shared across all instances of the application.

Maybe what I don't really understand is:

(AIDASite named: 'aidaOn8888') urlResolver defaultURL: '/mypage.html' forObject: myobj.

I am assuming there is only ever one instance of myobj created (not multiple objects for each request), so where can I create/store a NEW object, and is there a method called in my application when a new instance is requested so that I can initialize that object?

Does this make sense?  I think I don't understand something basic, because it seems that every "page" (from either multiple browsers or multiple computers) should have it's own object space.

Thanks,

Rob Rothwell


_______________________________________________
Aida mailing list
[hidden email]
http://lists.aidaweb.si/mailman/listinfo/aida
Reply | Threaded
Open this post in threaded view
|

Re: Aida application instance data

Janko Mivšek
Hi Rob,

Rob Rothwell wrote:

> Can anyone help me understand where to store data specific to that
> instance of the application?  For example, if I use the in-place editor
> [ajax] demo on one computer and then I open the same page from another
> computer, I see what you typed on the first computer.  If I type
> something new and refresh the page on the first computer, I get the same
> result.  What I WANT to see is "private" data for that page.

Besides domain objects which are accessible by any user, any session (if
security allows) you have the instances of an App, one per each session
per domain object. You can put session specific (temporary!) data here.
Temporary because this state is usually cleared, each night for
instance. But you can use WebSession userValues or WebUser userValues
for permanent session/user specific data.

> When I experiment with the session object, I find the same results...a
> session seems to be shared across all instances of the application.

Session is shared only among App instances for different domain objects.
But you have never more than one app instance for the same domain object
per session. That's obvious if you know the rule: a new App instances
for every new session, per domain object. So if you have say 10 domain
objects and 10 session, you have up to 100 App objects, one for each
session:domain object combination.

> Maybe what I don't really understand is:
>
> (AIDASite named: 'aidaOn8888') urlResolver defaultURL: '/mypage.html'
> forObject: myobj.
>
> I am assuming there is only ever one instance of myobj created (not
> multiple objects for each request), so where can I create/store a NEW
> object, and is there a method called in my application when a new
> instance is requested so that I can initialize that object?

> Does this make sense?  I think I don't understand something basic,
> because it seems that every "page" (from either multiple browsers or
> multiple computers) should have it's own object space.

Let we look at Aida tutorial: AddressBook with Addresses. That's a
domain model with anAddressBook as root domain object. Is your question
(translated to a tutorial case) how to add a new address to address book?

JAnko


--
Janko Mivšek
AIDA/Web
Smalltalk Web Application Server
http://www.aidaweb.si
_______________________________________________
Aida mailing list
[hidden email]
http://lists.aidaweb.si/mailman/listinfo/aida
Reply | Threaded
Open this post in threaded view
|

Re: Aida application instance data

Rob Rothwell
On Feb 5, 2008 2:06 PM, Janko Mivšek <[hidden email]> wrote:
Hi Rob,

Besides domain objects which are accessible by any user, any session (if
security allows) you have the instances of an App, one per each session
per domain object. You can put session specific (temporary!) data here.
Temporary because this state is usually cleared, each night for
instance. But you can use WebSession userValues or WebUser userValues
for permanent session/user specific data.

Maybe a more concrete example will help, because I am obviously missing something!

Using Squeak, if I create domain object:

Object subclass: #MyObject
    instanceVariableNames: 'textInput'
    classVariableNames: ''
    poolDictionaries: ''
    category: 'FMC-Model'

And a WebApplication:

WebApplication subclass: #MyObjectApp
    instanceVariableNames: ''
    classVariableNames: ''
    poolDictionaries: ''
    category: 'FMC-View'

with a main view:

viewMain
    |e|
    e := WebElement new.
    e addTextH1: 'My Application'. e addBreak.
    e addText: self observee textInput. e addBreak.
    e addInputFieldAspect: #textInput for: self observee.
    self add: e.

and create the site in a workspace with:

SwazooAida startOn: 8890.
obj := MyObject new.
(AIDASite named: 'aidaOn8890') urlResolver defaultURL: '/myapplication.html' forObject: obj.

And then open the site (http://localhost:8890/myapplication.html), I will see "nil" displayed on the screen the first time I enter the site right below the header.  Once I enter "some text" into the input field, I will see "some text," and if I go to another computer and enter the site (http://mynetworkaddress:8890/myapplication.html), I will ALSO see "some text" displayed at the top of the screen.

Furthermore, if I enter the site from the same computer in two different browsers and add "self inspect" at the top of MyObjectApp>>viewMain, I the app instance seems to be the same.

Does it matter that I have "logged in" as admin in both cases?

Where can I store data (and what methods do I use to access it) so that entering text on one computer does NOT affect what displays on another computer?

Sorry...there is something fundamental I don't understand yet.


Session is shared only among App instances for different domain objects.
But you have never more than one app instance for the same domain object
per session. That's obvious if you know the rule: a new App instances
for every new session, per domain object. So if you have say 10 domain
objects and 10 session, you have up to 100 App objects, one for each
session:domain object combination.

So Sessions let different applications share objects?



Let we look at Aida tutorial: AddressBook with Addresses. That's a
domain model with anAddressBook as root domain object. Is your question
(translated to a tutorial case) how to add a new address to address book?

No...it would be more like, how can two users have two DIFFERENT address books?  Or, for something even more temporary (to use a common web analogy), how can two sessions have two different shopping carts?

_______________________________________________
Aida mailing list
[hidden email]
http://lists.aidaweb.si/mailman/listinfo/aida
Reply | Threaded
Open this post in threaded view
|

Re: Aida application instance data

Janko Mivšek
Rob Rothwell wrote:

>     Besides domain objects which are accessible by any user, any session (if
>     security allows) you have the instances of an App, one per each session
>     per domain object. You can put session specific (temporary!) data here.
>     Temporary because this state is usually cleared, each night for
>     instance. But you can use WebSession userValues or WebUser userValues
>     for permanent session/user specific data.
>
>
> Maybe a more concrete example will help, because I am obviously missing
> something!
>
> Using Squeak, if I create domain object:
>
> Object subclass: #MyObject
>     instanceVariableNames: 'textInput'
>     classVariableNames: ''
>     poolDictionaries: ''
>     category: 'FMC-Model'
>
> And a WebApplication:
>
> WebApplication subclass: #MyObjectApp
>     instanceVariableNames: ''
>     classVariableNames: ''
>     poolDictionaries: ''
>     category: 'FMC-View'
>
> with a main view:
>
> viewMain
>     |e|
>     e := WebElement new.
>     e addTextH1: 'My Application'. e addBreak.
>     e addText: self observee textInput. e addBreak.
>     e addInputFieldAspect: #textInput for: self observee.
>     self add: e.
>
> and create the site in a workspace with:
>
> SwazooAida startOn: 8890.
> obj := MyObject new.
> (AIDASite named: 'aidaOn8890') urlResolver defaultURL:
> '/myapplication.html' forObject: obj.
>
> And then open the site (http://localhost:8890/myapplication.html), I
> will see "nil" displayed on the screen the first time I enter the site
> right below the header.  Once I enter "some text" into the input field,
> I will see "some text," and if I go to another computer and enter the
> site (http://mynetworkaddress:8890/myapplication.html), I will ALSO see
> "some text" displayed at the top of the screen.

That's completely right and expected Aida behavior, because from both
browsers you look at the same domain object. But see the further answer
below.

> Furthermore, if I enter the site from the same computer in two different
> browsers and add "self inspect" at the top of MyObjectApp>>viewMain, I
> the app instance seems to be the same.

Do you mean different browser windows of the same browser (just FF for
instance) or two different browsers, like IE and FF? In first case it is
natural that you see just one session because by just opening a new
window you don't open a new session but reusing an existing one. In
later case you should have two separate sessions.

> Does it matter that I have "logged in" as admin in both cases?

No.

> Where can I store data (and what methods do I use to access it) so that
> entering text on one computer does NOT affect what displays on another
> computer?

You need to have different domain object for different sessions in that
case. As I described in previous mail you can use your App to hold that
domain object temporary or use WebSession or WebUser userValues for
permanent storage of such session/user specific domain objects.

> Sorry...there is something fundamental I don't understand yet.

  It is very good that you raised that question because it seems that
many people have the same and it should be addressed in a tutorial or
maybe in FAQ.

>
>     Session is shared only among App instances for different domain objects.
>     But you have never more than one app instance for the same domain object
>     per session. That's obvious if you know the rule: a new App instances
>     for every new session, per domain object. So if you have say 10 domain
>     objects and 10 session, you have up to 100 App objects, one for each
>     session:domain object combination.

> So Sessions let different applications share objects?

Better said this enable apps to isolate their session specific state
from each others while observing the same domain object.

>     Let we look at Aida tutorial: AddressBook with Addresses. That's a
>     domain model with anAddressBook as root domain object. Is your question
>     (translated to a tutorial case) how to add a new address to address
>     book?
>
>
> No...it would be more like, how can two users have two DIFFERENT address
> books?  Or, for something even more temporary (to use a common web
> analogy), how can two sessions have two different shopping carts?

Let's go with a shoping card analogy. You'll make a new ShopingCard and
register it in WebUser userValues until user checkout. At checkout
you'll add it to anOrders domain object. That's because you need to
store that shopping card permanently for a long time.

But if you don't care, you can store simply in an OrdersApp instvar
newOrder, for instance. That's because anORdersApp will be created for
each session separately, so you'll have and isolation of shoping card
guaranteed.

Later case is preferred for short-living temporary state while former
for long-living ones , as I mentioned already.


JAnko

--
Janko Mivšek
AIDA/Web
Smalltalk Web Application Server
http://www.aidaweb.si
_______________________________________________
Aida mailing list
[hidden email]
http://lists.aidaweb.si/mailman/listinfo/aida
Reply | Threaded
Open this post in threaded view
|

Re: Aida application instance data

Rob Rothwell
Thanks for the help...

That's completely right and expected Aida behavior, because from both
browsers you look at the same domain object. But see the further answer
below.

Do you mean different browser windows of the same browser (just FF for
instance) or two different browsers, like IE and FF? In first case it is
natural that you see just one session because by just opening a new
window you don't open a new session but reusing an existing one. In
later case you should have two separate sessions.

Sorry.  I DO see the behavior you described.  Two different browsers create two different applications, but multiple instances of the same browser create the same application.  I didn't understand that sessions were reused like that.

You need to have different domain object for different sessions in that
case. As I described in previous mail you can use your App to hold that
domain object temporary or use WebSession or WebUser userValues for
permanent storage of such session/user specific domain objects.

Let's go with a shoping card analogy. You'll make a new ShopingCard and
register it in WebUser userValues until user checkout. At checkout
you'll add it to anOrders domain object. That's because you need to
store that shopping card permanently for a long time.

But if you don't care, you can store simply in an OrdersApp instvar
newOrder, for instance. That's because anORdersApp will be created for
each session separately, so you'll have and isolation of shoping card
guaranteed.

Later case is preferred for short-living temporary state while former
for long-living ones , as I mentioned already.

Ok...thanks...I am getting something to work now if I use two different browsers (IE vs FF) combined with an App instvar.


 It is very good that you raised that question because it seems that
many people have the same and it should be addressed in a tutorial or 
maybe in FAQ.

Have you seen Wink?

http://www.debugmode.com/wink/

Maybe I'll use it as a test case for my first tutorial and see what you think of it!

Sorry for the confusion...!

Rob

_______________________________________________
Aida mailing list
[hidden email]
http://lists.aidaweb.si/mailman/listinfo/aida
Reply | Threaded
Open this post in threaded view
|

Re: Aida application instance data

Janko Mivšek

Rob Rothwell wrote:

> Have you seen Wink?
>
> http://www.debugmode.com/wink/
>
> Maybe I'll use it as a test case for my first tutorial and see what you
> think of it!

Vow! Hardly waiting for that!

> Sorry for the confusion...!

No confusion, clarification!

Best regards
Janko


--
Janko Mivšek
AIDA/Web
Smalltalk Web Application Server
http://www.aidaweb.si
_______________________________________________
Aida mailing list
[hidden email]
http://lists.aidaweb.si/mailman/listinfo/aida