All,
I have a question on the combination Primefaces for JSF2.0 + Spring (2.5.6) + Facelets.
From the JSF spec I understand Facelets is now built in, so the facelets (maven) dependency can be dropped, but I remember that in JSF 1.x versions, for the integration Facelets + Spring, you had to add this to the faces-config.xml:
<application>
<view-handler>com.sun.facelets.FaceletViewHandler</view-handler>
<variable-resolver>org.springframework.web.jsf.DelegatingVariableResolver</variable-resolver>
...
... to properly resolve Spring beans inside jsf pages.
When I try this in my JSF 2 app, my IDE turns the <view-handler> red, which means the class doesn't exist anymore (or has been moved/...).
--> Hence the question: what, if still applicable, configuration is required for the integration Facelets + Spring in JSF2.0?
Any help is greatly appreciated.
JSF 2.0 & Facelets & Spring[SOLVED]
Hello,
As I know the Spring configuration can be let unchaged. But view-handler must not be definied! Pay also attention to right DOCTYPE in faces-config, otherwise you fall back to JSF 1.x functionality (accoring to specification).
Best regards.
Oleg.
As I know the Spring configuration can be let unchaged. But view-handler must not be definied! Pay also attention to right DOCTYPE in faces-config, otherwise you fall back to JSF 1.x functionality (accoring to specification).
Best regards.
Oleg.
PrimeFaces Cookbook (2. edition): http://ova2.github.io/primefaces-cookbook/ Learning Angular UI Development with PrimeNG: https://github.com/ova2/angular-develop ... th-primeng Blog: https://medium.com/@OlegVaraksin
@Oleg,
Thanks for your quick reply.
Indeed, this new ns was used for the faces-config:
xsi:schemaLocation="http://java.sun.com/xml/ns/javaee http://java.sun.com/xml/ns/javaee/web-f ... ig_2_0.xsd"
So, you're saying I can just drop the whole element and
- spring beans referenced in jsf 2 pages will still be found (I guess after adding the spring-web mvn dependency too then?)
- Spring & JSF beans lifecycles will be automatically synced too?
Thanks for your quick reply.
Indeed, this new ns was used for the faces-config:
xsi:schemaLocation="http://java.sun.com/xml/ns/javaee http://java.sun.com/xml/ns/javaee/web-f ... ig_2_0.xsd"
So, you're saying I can just drop the whole element and
- spring beans referenced in jsf 2 pages will still be found (I guess after adding the spring-web mvn dependency too then?)
- Spring & JSF beans lifecycles will be automatically synced too?
-
- Prime
- Posts: 18616
- Joined: 05 Jan 2009, 00:21
- Location: Cybertron
- Contact:
* Doctype xsd should be the new one yes.
* <view-handler>com.sun.facelets.FaceletViewHandler</view-handler> must be removed as Facelets is ready of the box.
* As long as the Spring's delegatingvariableresolver is there, spring beans can be referenced in JSF 2 pages. No change required on that.
Core spring would be enough, as I know spring-web contains spring mvc framework which is not required for JSF centric JSF-Spring integration.
* <view-handler>com.sun.facelets.FaceletViewHandler</view-handler> must be removed as Facelets is ready of the box.
* As long as the Spring's delegatingvariableresolver is there, spring beans can be referenced in JSF 2 pages. No change required on that.
(I guess after adding the spring-web mvn dependency too then?)
Core spring would be enough, as I know spring-web contains spring mvc framework which is not required for JSF centric JSF-Spring integration.
I didn't quite understand what you meant by lifecycles being synced, JSF 1.2 - Spring and JSF 2.0 - Spring integration should not differ.Spring & JSF beans lifecycles will be automatically synced too?
Yeah, that was perhaps a bit short, let me explain what I meant:
About the life cycle synchronization: Spring beans and JSF beans both have their own life cycle. E.g. JSF beans are typically session/request scoped (per user session), where Spring beans are typically either app(singleton) or prototype scoped.
Now, this means that if you declare your JSF beans as Spring beans, you need to make Spring aware of e.g. the concept "Session", and that Spring should respect that those threads are to be tied to the set of threads for that Session. They should understand each other's life cycle and nicely work together.
It was my belief you needed spring-web for this (e.g. to make a bean Session scoped, as a session scope doesn't make any sense outside of the web tier).
Can you confirm I was wrong about this assumption?
(It's good news in any case. Less jars/slimmer size)
Furthermore: you say "As long as the Spring's delegatingvariableresolver is there". Could you please provide the exact xml fragment for this? What I have currently doesn't work.
Bye & Thanks,
About the life cycle synchronization: Spring beans and JSF beans both have their own life cycle. E.g. JSF beans are typically session/request scoped (per user session), where Spring beans are typically either app(singleton) or prototype scoped.
Now, this means that if you declare your JSF beans as Spring beans, you need to make Spring aware of e.g. the concept "Session", and that Spring should respect that those threads are to be tied to the set of threads for that Session. They should understand each other's life cycle and nicely work together.
It was my belief you needed spring-web for this (e.g. to make a bean Session scoped, as a session scope doesn't make any sense outside of the web tier).
Can you confirm I was wrong about this assumption?
(It's good news in any case. Less jars/slimmer size)
Furthermore: you say "As long as the Spring's delegatingvariableresolver is there". Could you please provide the exact xml fragment for this? What I have currently doesn't work.
Bye & Thanks,
-
- Prime
- Posts: 18616
- Joined: 05 Jan 2009, 00:21
- Location: Cybertron
- Contact:
Here's an article I've written before regarding integrating JSF 1.2 and Spring 2.5.
http://cagataycivici.wordpress.com/2008 ... pring-jpa/
Hope this helps as it's very detailed.
http://cagataycivici.wordpress.com/2008 ... pring-jpa/
Hope this helps as it's very detailed.
All,
The example is very compleete and well written, yet not a JSF 2 example.
I think it matters now, as
<application>
<view-handler>com.sun.facelets.FaceletViewHandler</view-handler>
<variable-resolver>org.springframework.web.jsf.DelegatingVariableResolver</variable-resolver>
</application>
, valid for JSF 1.2 apps, is marked red in my IDE in JSF 2 apps. (which suggests I need a different config for JSF 2)
I looked around in the Spring fora too but didn't find anything back there.
Plus, in the web.xml, I see stuff like
<listener-class>org.springframework.web.context.ContextLoaderListener</listener-class>
<listener-class>org.springframework.web.context.request.RequestContextListener</listener-class>
This suggests I do need spring-web as dependency (contrary to an earlier reply in this topic).
... which leaves me with the 2 questions I started this topic for!
The example is very compleete and well written, yet not a JSF 2 example.
I think it matters now, as
<application>
<view-handler>com.sun.facelets.FaceletViewHandler</view-handler>
<variable-resolver>org.springframework.web.jsf.DelegatingVariableResolver</variable-resolver>
</application>
, valid for JSF 1.2 apps, is marked red in my IDE in JSF 2 apps. (which suggests I need a different config for JSF 2)
I looked around in the Spring fora too but didn't find anything back there.
Plus, in the web.xml, I see stuff like
<listener-class>org.springframework.web.context.ContextLoaderListener</listener-class>
<listener-class>org.springframework.web.context.request.RequestContextListener</listener-class>
This suggests I do need spring-web as dependency (contrary to an earlier reply in this topic).
... which leaves me with the 2 questions I started this topic for!
-
- Prime
- Posts: 18616
- Joined: 05 Jan 2009, 00:21
- Location: Cybertron
- Contact:
For JSF 2, facelets viewhandler is absolutely not required, as Facelets is built-in to JSF2 package name is changed as well. That's why the ide doesn't like it.
spring-web constraint depends on which spring packaging you use, do you have that huge all in one spring 2.5 jar? or seperate jars like spring-core, spring-aop stuff? As I know with spring 3.0, all in one spring jar doesn't exists anymore.
Code: Select all
<application>
<el-resolver>org.springframework.web.jsf.el.SpringBeanFacesELResolver</el-resolver>
</application>
-
- Prime
- Posts: 18616
- Joined: 05 Jan 2009, 00:21
- Location: Cybertron
- Contact:
Glad it works.
-
- Information
-
Who is online
Users browsing this forum: No registered users and 40 guests