I'm new at JSF-Spring (... but I used Spring and JSF). So, I'm looking for some infoemation how to setup and use JSF-Spring. I looked at the jsf-spring-3.0.0M3-testsuite.war and the jsf-spring-3.0.0M3.zip. Its a lot of compact information. Before I start to dive into it,, here my question.
Are the any Howto's, articles or tutorials about JSF-Spring ?
Friendly regards
Kai
If you would like to refer to this comment somewhere else in this project, copy and paste the following link:
there isn't any tutorial or cookbook yet, but it is being worked on. The testsuite can't really be considered being any documentation, although it shows the use of all of jsf-spring's features. It's main purpose is to provide a mean to do testing, as the name suggests. Furthermore, it isn't functional at the moment. Expect a functional version with the release of 3.0.0 RC1 by the end of next week. We can't predict when the documentation will be released yet, but it will grow during the preparation of a talk we're giving at the jax in may. I'm off for a meeting now but I'll post a short walk-through to get you going later today.
Cheers,
Thomas
If you would like to refer to this comment somewhere else in this project, copy and paste the following link:
This is a great offer. We actually did plan to open up the team this year, anyway. So I'll discuss this with Wolfgang, who is responsible for documentation, and we'll see how things work out. Thanks for wanting to contribute.
Cheers,
Thomas
If you would like to refer to this comment somewhere else in this project, copy and paste the following link:
1. You need to deploy the jars you want to use:
- jsf-spring-core.jar the core framework
- jsf-spring-context.jar integration of the the two IOC containers (JSF and Spring)
- jsf-spring-config.jar (optional) needed when you want to configure JSF components (eg. converters) using Spring
3. Create your configuration files:
- WEB-INF/applicationContext.xml for Spring
- WEB-INF/faces-context.xml for JSF
- WEB-INF/faces-spring-context.xml for JSF managed beans that are configured using a spring compatible syntax
- WEB-INF/faces-spring-config.xml for JSF components configured via jsf-spring-config
faces-spring-context.xml can use the following doctype:
<!DOCTYPE beans PUBLIC "-//JSF-SPRING//DTD BEAN//EN" "http://jsf-spring.sf.net/dtd/jsf-spring-beans.dtd">
This will enable you to use the scope attribute in your bean definitions.
If you want to split your configuration in several files, you have to specify them using the following context params:
- contextConfigLocation
- javax.faces.CONFIG_FILES
- faces.spring.CONTEXT_FILES
- faces.spring.CONFIG_FILES
This should be it (from the top of my head...) - if you have problems, post your questions here.
HTH,
Thomas
If you would like to refer to this comment somewhere else in this project, copy and paste the following link:
You can use all of Spring's standard injection methods. Keep in mind that you cannot inject beans from all contexts, though, due to the way jsf-spring sets up the context hierarchy. You can use the beans defined in your faces-config.xml file (or those configured in web.xml) and in your spring applicationContext.xml. You cannot use those defined in your faces context.
HTH,
Thomas
If you would like to refer to this comment somewhere else in this project, copy and paste the following link:
I did all the steps mentioned and I am getting this exception:
javax.servlet.ServletException: Error calling action method of component with id LoginForm:submit
javax.faces.webapp.FacesServlet.service(FacesServlet.java:121)
root cause
javax.faces.FacesException: Error calling action method of component with id LoginForm:submit
org.apache.myfaces.application.ActionListenerImpl.processAction(ActionListenerImpl.java:74)
javax.faces.component.UICommand.broadcast(UICommand.java:106)
javax.faces.component.UIViewRoot._broadcastForPhase(UIViewRoot.java:90)
javax.faces.component.UIViewRoot.processApplication(UIViewRoot.java:164)
org.apache.myfaces.lifecycle.LifecycleImpl.invokeApplication(LifecycleImpl.java:316)
org.apache.myfaces.lifecycle.LifecycleImpl.execute(LifecycleImpl.java:86)
javax.faces.webapp.FacesServlet.service(FacesServlet.java:106)
In tomcat logs:
Caused by: java.lang.NullPointerException
at com.strongmail.view.LoginBean.login(LoginBean.java:69)
Hallo,
I'm new at JSF-Spring (... but I used Spring and JSF). So, I'm looking for some infoemation how to setup and use JSF-Spring. I looked at the jsf-spring-3.0.0M3-testsuite.war and the jsf-spring-3.0.0M3.zip. Its a lot of compact information. Before I start to dive into it,, here my question.
Are the any Howto's, articles or tutorials about JSF-Spring ?
Friendly regards
Kai
Hi Kai,
there isn't any tutorial or cookbook yet, but it is being worked on. The testsuite can't really be considered being any documentation, although it shows the use of all of jsf-spring's features. It's main purpose is to provide a mean to do testing, as the name suggests. Furthermore, it isn't functional at the moment. Expect a functional version with the release of 3.0.0 RC1 by the end of next week. We can't predict when the documentation will be released yet, but it will grow during the preparation of a talk we're giving at the jax in may. I'm off for a meeting now but I'll post a short walk-through to get you going later today.
Cheers,
Thomas
If you need help, tell me, I think about joining the documentation team. I'm an examinated teacher, I might be able to help.
Greatings Kai
This is a great offer. We actually did plan to open up the team this year, anyway. So I'll discuss this with Wolfgang, who is responsible for documentation, and we'll see how things work out. Thanks for wanting to contribute.
Cheers,
Thomas
So here's the HowTo:
1. You need to deploy the jars you want to use:
- jsf-spring-core.jar the core framework
- jsf-spring-context.jar integration of the the two IOC containers (JSF and Spring)
- jsf-spring-config.jar (optional) needed when you want to configure JSF components (eg. converters) using Spring
2. You need to activate jsf-spring by inserting the corresponding listener/servlet to your web.xml, depending on whether your servlet container supports listeners. See http://jsf-spring.sourceforge.net/3.0.0M3/de/mindmatters/faces/spring/context/package-summary.html for an example for jsf-spring-context (mandatory) and http://jsf-spring.sourceforge.net/3.0.0M3/de/mindmatters/faces/spring/config/package-summary.html for jsf-spring-config (optional).
3. Create your configuration files:
- WEB-INF/applicationContext.xml for Spring
- WEB-INF/faces-context.xml for JSF
- WEB-INF/faces-spring-context.xml for JSF managed beans that are configured using a spring compatible syntax
- WEB-INF/faces-spring-config.xml for JSF components configured via jsf-spring-config
faces-spring-context.xml can use the following doctype:
<!DOCTYPE beans PUBLIC "-//JSF-SPRING//DTD BEAN//EN" "http://jsf-spring.sf.net/dtd/jsf-spring-beans.dtd">
This will enable you to use the scope attribute in your bean definitions.
If you want to split your configuration in several files, you have to specify them using the following context params:
- contextConfigLocation
- javax.faces.CONFIG_FILES
- faces.spring.CONTEXT_FILES
- faces.spring.CONFIG_FILES
This should be it (from the top of my head...) - if you have problems, post your questions here.
HTH,
Thomas
It, workd fine.
There is a little problem I got into,
how can I inject objects into
- ActionListener's
- Validators
- Converters
Kai
You can use all of Spring's standard injection methods. Keep in mind that you cannot inject beans from all contexts, though, due to the way jsf-spring sets up the context hierarchy. You can use the beans defined in your faces-config.xml file (or those configured in web.xml) and in your spring applicationContext.xml. You cannot use those defined in your faces context.
HTH,
Thomas
Bye the way thenx for your help :-)
Hallo Thomas,
thanx for your time.
Kai
I did all the steps mentioned and I am getting this exception:
javax.servlet.ServletException: Error calling action method of component with id LoginForm:submit
javax.faces.webapp.FacesServlet.service(FacesServlet.java:121)
root cause
javax.faces.FacesException: Error calling action method of component with id LoginForm:submit
org.apache.myfaces.application.ActionListenerImpl.processAction(ActionListenerImpl.java:74)
javax.faces.component.UICommand.broadcast(UICommand.java:106)
javax.faces.component.UIViewRoot._broadcastForPhase(UIViewRoot.java:90)
javax.faces.component.UIViewRoot.processApplication(UIViewRoot.java:164)
org.apache.myfaces.lifecycle.LifecycleImpl.invokeApplication(LifecycleImpl.java:316)
org.apache.myfaces.lifecycle.LifecycleImpl.execute(LifecycleImpl.java:86)
javax.faces.webapp.FacesServlet.service(FacesServlet.java:106)
In tomcat logs:
Caused by: java.lang.NullPointerException
at com.strongmail.view.LoginBean.login(LoginBean.java:69)
where LoginBean.java has:
ServletContext context =
(ServletContext)FacesContext.getCurrentInstance().getExternalContext().getContext();
ApplicationContext appContext =
WebApplicationContextUtils.getWebApplicationContext(context);
IAuth pAuth = (IAuth)appContext.getBean("AuthBean");
and I define the bean in applicationContext.xml
Is there anything that I am missing here?
I resolved the issue. web.xml configuration had no entry for jsf-spring listener (copy paste error) so I was getting null FacesContext.
It is working pretty well now.