问题
I want to use angular2 framework for frontend, so for UI part I want to use primeng but I don't know how npm works.
Tech info:
- My IDE is eclipse/netbeans
- project is going to be deployed on Wildfly8.0
Can I mix JSF components with primeng?
回答1:
TL;DR: Yes it is possible, but there are better alternatives
Important concepts:
AngularJS
is a synonym for angular version 1Angular2
is synonym for angular version 2 (not backwards compatible with v1)primeng
is a components library that depends onangular2
primefaces
is a components library that depends onJSF
JSF
andangular2
are MVC frameworks, where each one has injection mechanisms based on annotations (@annotation) although the terminology is similar the underneath of both mechanisms is very differentangular2
+primeng
is used withtypescript
(recommended) orjavascript
, on the other hand,JSF
+primefaces
is used withjava
primeng
is client-side,primefaces
is server-side- the company developing
primeng
is the same company developingprimefaces
, and recently we as users have seen a very good synergy, where if there is an improvement in one component is then ported to the other library. - Right now (2016)
primefaces
has more components thanprimeng
and feels more polished
Implications of using primeng
+ JSF
(primefaces
):
- Each framework has different lifecycles with different concepts and implications (given that one is client-side and the other is server-side), if you start to use both frameworks you have to understand them at great detail.
- If you start mixing components of both frameworks this is going to be very hard to maintain
Other approaches:
primeng
+JAX-RS
: Given that you are usingwildfly
this will be easy to implement, all services provide the info to the client components. It tends to be the 'modern' approach.JSF
+primefaces
: this is the simplest solution, only server side, only one framework to learn.- use
JSF
only as a template engine (facelets) and on top of it useangular2
+primeng
: yes, this could work but needs more investigation to make it properly, you need to really understandJSF
andangular2
lifecycles, is not impossible but requires time.
As for you other question about npm
: Yes, you can use angular2
without npm
, but you will need to write more boilerplate code than necessary, you can use this plunker as starting point (you need to add the js file for primeng
): http://plnkr.co/edit/bApfY9?p=info.
Update 1:
I once read that JSF
was planning to implement a lifecycle phase to execute javascript code. No official statement by now.
来源:https://stackoverflow.com/questions/37984827/is-possible-to-use-primeng-angular2-embedded-in-jsf-without-npm