Announcement Announcement Module
Collapse
No announcement yet.
Architectural question: dispose presentationmodel on logout? Page Title Module
Move Remove Collapse
X
Conversation Detail Module
Collapse
  • Filter
  • Time
  • Show
Clear All
new posts

  • Architectural question: dispose presentationmodel on logout?

    Hi there,

    I'm currently fiddling around with Spring AS, and I'm having an architectural question.
    It seems so basic to me, and I don't know why I never really got to think of this before..

    I'm making an application with a pretty big users-database behind it, to make all kinds of reports.

    Let's take the next flow as an example:
    - User logs on to my application
    - User clicks a button that says "Create Report" (which obviously, well.... -- creates a new "Report")
    - Application displays a form (called "ReportComponent"), and a ReportPresentationModel is created & linked to this, using DI.
    - User starts to fill out form.
    - User decides to log out of application before submitting the form

    Now, the problem is that if a new user logs in without doing a page refresh in the browser first,
    he will see the formwhich is half-ass filled out (in our example), because the state was never lost.

    So I thought: instead of clearing all the filled out fields in the presentationmodel and the view,
    it would be better that on a logout I would do somewhere "reportpresentationmodel.instance = null"
    and on a new login, I would say "view = new ReportComponent".
    -> ReportpresentationModel would be null, so the singleton implementation would create a new "instance",
    resulting in no clearing issues, or data that gets persisted while it shouldn't.

    So my questions are:
    - does this sound like "the right way to do this" to you?
    - if so: is there a way in Spring AS to clear a presentationModel (or make it multiton instead of singleton or something)
    - if not: how do you tackle this usually? creating a new context (sounds dirty..)? Are there modules I should work with, ....?

    Note:
    I also had a look at this application:
    http://springactionscript.org/sample...dule/Main.html
    Log in and make a new user, select "Boles, Matt" in the list, log out, and log back in.
    You still see the same users, and "Boles, Matt" will still be selected.

    To me this is just not the behaviour I expect...No?

    Looking forward to hear your opinions on this!
    Hans

  • #2
    Hi Hans,

    presentation models should be a 1-on-1 with their view in terms of instances created. In other words, a presentation model should be a singleton. So if the user logs out and the views are destroyed, I would also expect the presentation models to be destroyed. If you set the scope of your pm definition to "prototype" this will inject a NEW instance of the pm each time it is wired into the view.

    On a general note when logging out a user, I found it best practice to simply reload the application. That way you don't have to do any resetting, disposing etc yourself and you are sure that there is no stale state in the application.

    Here a code snippet I use to reload a Flex web app:

    var ref:URLRequest = new URLRequest( "javascript:history.go(0)" );
    navigateToURL( ref, "_self" );

    cheers,
    Christophe

    Comment


    • #3
      Thanks a lot for your answer, Christophe!
      Your javascript call on log out seems like a very good idea!

      Comment

      Working...
      X