Is possible to use Primeng, Angular2 embedded in JSF without npm?

喜夏-厌秋 提交于 2020-01-05 05:55:09

问题


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:

  1. My IDE is eclipse/netbeans
  2. 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 1
  • Angular2 is synonym for angular version 2 (not backwards compatible with v1)
  • primeng is a components library that depends on angular2
  • primefaces is a components library that depends on JSF
  • JSF and angular2 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 different
  • angular2 + primeng is used with typescript (recommended) or javascript, on the other hand, JSF + primefaces is used with java
  • primeng is client-side, primefaces is server-side
  • the company developing primeng is the same company developing primefaces, 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 than primeng 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 using wildfly 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 use angular2 + primeng: yes, this could work but needs more investigation to make it properly, you need to really understand JSF and angular2 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

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!