Results 1 to 8 of 8

Thread: The best way to save objects...

  1. #1
    Join Date
    Jul 2005
    Posts
    15

    Default The best way to save objects...

    Hi all.

    In my project I need to save objects in some container and later to get them. I have found StaticListableObjectFactory which do this. but I want to ask.

    Maybe there is an another way?

  2. #2
    Join Date
    Sep 2004
    Location
    Leeds, UK
    Posts
    166

    Default

    Hi Dmitrij

    I'm not palming this question off, but in order to answer your question I'd like to get more of a handle on just why you need to save objects into the configuration at runtime.

    So... why do you need to save objects into the configuration at runtime? Without obviously going into too much detail, what is the problem that you are trying to solve?

    Ciao
    Rick
    Senior Consultant, Interface21 - Spring Services from the Source

    The Spring Experience - The Premier Spring Event of 2006. December 7-10, 2006, Hollywood, Florida

  3. #3
    Join Date
    Jul 2005
    Posts
    15

    Default

    Ok Rick, I'll try to describe my problem.

    There is web-form with some datas. The user press submit button , Spring assemble some object and pass it into project's logic. The logic do something with object's data and return new object which Spring pass to the another web-form.

    That'a all...)

  4. #4
    Join Date
    Mar 2005
    Posts
    78

    Default

    Did you just want to save the object in the client's session container?

    * http://msdn.microsoft.com/library/de...710538d6c1.asp

    Keep in mind that references are being passed. If the business logic make changes to object, the reference in the session will be able to see the changes too. So, you don't really have to pass it around. Once it's in the session, the business logic can change it, and other pages will see the latest version.

    HTH, Ted.

  5. #5
    Join Date
    Jul 2005
    Posts
    15

    Default

    I've thinking that I can use Spring like a container for transporting objects between web-forms...

  6. #6
    Join Date
    Sep 2004
    Location
    Leeds, UK
    Posts
    166

    Default

    Hiya

    I would second Ted's answer... if you want to pass objects around between pages, using the session would (generally) be the way to go.

    And Ted is correct again in that its references that are being passed aorund and obtained from the container. If you pull and configured object out of the container and subsequently change the values in the object, those changes will be available to other pages (if one is pulling a singleton object out the the container that is).

    Ciao
    Rick
    Senior Consultant, Interface21 - Spring Services from the Source

    The Spring Experience - The Premier Spring Event of 2006. December 7-10, 2006, Hollywood, Florida

  7. #7
    Join Date
    Mar 2005
    Posts
    78

    Default

    Quote Originally Posted by dfed
    I've thinking that I can use Spring like a container for transporting objects between web-forms...
    What you might want to do is create your own container, with properties for whatever attributes you need to transport, and store that in the client's session. This way, you don't have a bunch of value objects floating around in the session, and you have a quick-and-easy way to keep track of your session use.

    I usually call this a client "Profile" obtject, Aside from attributes to transfer between pages, you can use it to track the client's identity and preferences.

    Of course, you can use Spring to deliver up a Profile object when you need to create one, but Spring itself is about manufacturing objects, not storing them afterwards.

    HTH, Ted.

  8. #8
    Join Date
    Sep 2004
    Location
    Belgrade, Serbia
    Posts
    613

    Default

    Quote Originally Posted by dfed
    I've thinking that I can use Spring like a container for transporting objects between web-forms...
    Technically you can, although it will not work for every scenario and it might not be the best solution depending on your needs. As Ted pointed out, Spring is mostly about creating and configuring objects, not about transporting them from page to page.

    That said, if your business logic modifies singleton object that is exposed by the Spring container, every page that has that object injected will see the changes. Keep in mind that standard singleton objects have application scope, so once you make any change to an object all users of the application will see new, changed values. If you need to have different state per application user, you will have to add scope="session" attribute to your object definition, which will tell Spring that it needs to create one instance per user, instead of one instance for the whole application.

    However, this will only work as long as your business logic is simply manipulating existing objects. If you are creating new objects, you need to use one of the standard ASP.Net mechanisms to transport it to another page -- either by using HTTP session as Ted and Rick suggested, or by storing it within HTTP context and transferring request to your target page.

    HTH,

    Aleks

Similar Threads

  1. objects auto-init
    By Gengis in forum Core Container
    Replies: 1
    Last Post: 04-23-2006, 05:33 PM
  2. file system watcher for objects config file
    By MNBob in forum Core Container
    Replies: 14
    Last Post: 02-17-2006, 02:13 PM
  3. Interactive Code and objects from spring
    By chrisdonnan in forum Core Container
    Replies: 1
    Last Post: 01-25-2006, 05:44 PM
  4. Replies: 5
    Last Post: 08-13-2005, 01:17 PM
  5. Should abstract objects be registered?
    By Anonymous in forum Core Container
    Replies: 13
    Last Post: 02-04-2005, 10:27 PM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •