-1

I use org.springframework.web.jsf.el.SpringBeanFacesELResolver in my JSF + Spring application. Every backing bean needs an interface to be resolved. I guess that it's interface type of dependency injection.

#{bean.text}

public interface IBean {
    String getText();
}

@Named
@Scope("session")
public class Bean implements IBean {
    public String getText() {
        return "Hello World!";
    }
}

I would like to get rid of the interface. It's kind of bureaucracy for me. Is it possible?

ziri
  • 513
  • 7
  • 18
  • 1
    You do not have to implement an interface if you do not want to. You should probably read this [how-are-java-interfaces-actually-used](http://stackoverflow.com/questions/504904/how-are-java-interfaces-actually-used) before going further and this [spring-autowiring-class-vs-interface](http://stackoverflow.com/questions/2387431/spring-autowiring-class-vs-interface) – Ravi Kadaboina Oct 23 '12 at 08:43
  • By the way you are not injecting any property into your Bean class. Here is a [tutorial](http://cagataycivici.wordpress.com/2007/12/19/annotate-jsf-beans-with-spring-25/) to get you started on this. – Ravi Kadaboina Oct 23 '12 at 08:52
  • @Ravi: Tho problem was in Spring's default solving of dependencies for beans scoped as session or request. See my answer. – ziri Oct 28 '12 at 18:00

1 Answers1

0

I finally solved it. The problem was in beans with scope depending on HTTP (request, session). By default interfaces should be manually created. This can be avoided by using proxies.

If using component scan:

<context:component-scan base-package="..." scoped-proxy="targetClass" />

Or in bean definition:

<bean ...>
    <aop:scoped-proxy>
</bean>

See chapter 4.5.4.5 Scoped beans as dependencies in Spring documentation. http://static.springsource.org/spring/docs/3.1.x/spring-framework-reference/html/beans.html

ziri
  • 513
  • 7
  • 18