Announcement Announcement Module
Collapse
No announcement yet.
Question for context Page Title Module
Move Remove Collapse
X
Conversation Detail Module
Collapse
  • Filter
  • Time
  • Show
Clear All
new posts

  • 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
    Re: Question for context

    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.

    Comment


    • #3
      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?

      Comment


      • #4
        Re: One more question

        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)

        Comment

        Working...
        X