Results 1 to 4 of 4

Thread: Question for context

  1. #1
    Join Date
    Sep 2005
    Posts
    2

    Default Question for context

    I'm using Spring in a standalone java application (SWT/JFace).

    I want to ask is Spring able to provide me something like a session to save objects across the application?

    For example, I defined a bean in the application Context as a singleton bean.

    On the first frame, I want to get the bean and set values of the bean, then save the bean with the new values into the context.

    On another frame, I want to get the specific bean that was set on the first frame.

    Can spring do that? How?

  2. #2
    Join Date
    Nov 2004
    Location
    Hilversum - The Netherlands
    Posts
    1,054

    Default Re: Question for context

    Quote Originally Posted by yoda909
    I'm using Spring in a standalone java application (SWT/JFace).

    I want to ask is Spring able to provide me something like a session to save objects across the application?

    For example, I defined a bean in the application Context as a singleton bean.

    On the first frame, I want to get the bean and set values of the bean, then save the bean with the new values into the context.
    If you have a object in a hasmap.. and you change a value on that objects.. everybody that want to use that objects see the changed values. The same goes for Spring.. Spring is nothing magical.. you could see the application context as a hashmap for objects...

    Can spring do that? How?
    Code:
    <bean id="button" class="SWTButton"/>
    
    <bean id="frame1" class="SWTFrame">
        <constructor-arg ref="button"/>
    </bean>
    
    <bean id="frame2" class='SWTFrame">
        <constructor-arg ref="button"/>
    </bean>
    Now button is shared between frame1 and frame2.

  3. #3
    Join Date
    Sep 2005
    Posts
    2

    Default One more question

    Thanks for reply,

    <bean id="button" class="SWTButton"/>

    <bean id="frame1" class="SWTFrame">
    <constructor-arg ref="button"/>
    </bean>

    <bean id="frame2" class='SWTFrame">
    <constructor-arg ref="button"/>
    </bean>
    Let's say button has a property called name.



    Code:
    <bean id="button" class="SWTButton"> 
    <property "name">
    <value>button1</value>
    </property>
    </bean>
    How to reset the button name in code.

    Is that do a

    Code:
    Button b = &#40;Button&#41;applicationConext.getBean&#40;"Button"&#41;;
    b.setName&#40;"button2"&#41;;
    After set, will the context know the property of bean button has been change?

  4. #4
    Join Date
    Nov 2004
    Location
    Hilversum - The Netherlands
    Posts
    1,054

    Default Re: One more question

    Quote Originally Posted by yoda909
    Thanks for reply,
    After set, will the context know the property of bean button has been change?
    Does a hashmap need to know if a person in a hashmap got a different name ? (and the name isn`t part of the hashcode)

Similar Threads

  1. Forgot password (e.g. secret question) using Acegi
    By lowerymb77 in forum Security
    Replies: 1
    Last Post: Oct 16th, 2005, 10:46 PM
  2. design question: passing context
    By Alarmnummer in forum Management
    Replies: 0
    Last Post: Oct 3rd, 2005, 01:20 PM
  3. Replies: 3
    Last Post: Apr 3rd, 2005, 04:34 PM
  4. Replies: 6
    Last Post: Oct 8th, 2004, 02:21 PM
  5. Question regarding code in UI classes
    By dortman in forum Swing
    Replies: 5
    Last Post: Sep 22nd, 2004, 07:04 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
  •