Announcement Announcement Module
Collapse
No announcement yet.
Injection conversation scoped objects in spring beans Page Title Module
Move Remove Collapse
X
Conversation Detail Module
Collapse
  • Filter
  • Time
  • Show
Clear All
new posts

  • Injection conversation scoped objects in spring beans

    In order to inject conversation scoped objects into JSF backing beans, I currently do the following :

    Define a request based backing bean in faces-config, use setter injection to inject #{someObject} (defined as a conversation scoped variable in my flow definition)

    Code:
    <managed-bean>
    <managed-bean-name>backingbean</managed-bean-name>
    <managed-bean-class>com.acme.backingbean</managed-bean-class>
    <managed-bean-scope>request</managed-bean-scope>
    <managed-property>
    <property-name>someObject</property-name>
    <value>#{someObject}</value>
    </managed-property>
    </managed-bean>
    My flow definition defines the someObject variable in conversation scope

    Code:
    <flow>
    <var name="someObject" scope="conversation"/>
    ...
    </flow>
    My spring beans configuration contains the definition of the someObject bean

    Code:
    <beans>
    <bean id="someObject" class="com.acme.SomeObject" scope="prototype"/>
    ...
    </beans>
    For every request, the backing bean get's re-created, and injected with the same conversation scoped object during the flow (behavior that I want).

    Suppose I don't want to use faces-config to define my backing beans, but I want to use spring beans as backing beans, how do I inject the flowscoped someObject into the spring bean ?

    I removed the entry in faces-config.xml, and defined the backing bean in my spring beans configuration :

    Code:
    <bean id="backingbean" class="com.acme.backingbean" scope="request">
    <property name="someObject" ref="???"/>
    </bean>
    Spring allows me to refer to #{backingbean} via EL without a problem, but how do I inject someObject ? What do I need to put as a ref or value attribute ? If a use ref="someObject", I get a new someObject injected on every request. How do I tell Spring to lookup the conversation scoped object belonging to my flow (as is the case when the backing bean is configured in faces-config) ?
Working...
X