Announcement Announcement Module
No announcement yet.
Injection conversation scoped objects in spring beans Page Title Module
Move Remove Collapse
Conversation Detail Module
  • 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)

    My flow definition defines the someObject variable in conversation scope

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

    <bean id="someObject" class="com.acme.SomeObject" scope="prototype"/>
    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 :

    <bean id="backingbean" class="com.acme.backingbean" scope="request">
    <property name="someObject" ref="???"/>
    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) ?