1

I'm looking for some help Although AngularJS and JSF are completely different frameworks at first sight, AngularJS is client side HTML and Javascript, JSF is server side Java and XML.

When I was looking for a framework a couple of months ago, to do some web development with JavaScript, I stumbled by accident on AngularJS.

I found a few clear differences. Well, basically JSF’s XHTML pages are just pimped-up HTML code. It offers a lot of high-level components translating to a lot of HTML code, but basically, it’s just HTML the way it should be. Plus a few syntactical peculiarities.

<h:panelgrid columns="2">
 <h:outputText value="Your name:" />
 <h:input id="commentatorsNameID" type="text"
      value="#{commentBean.yourName}"
      placeholder="Anonymous" />
 <h:outputText value="Your website: />
<h:input id="commentatorsWebSiteID" type="text"
      value="#{commentBean.website}"
      placeholder="advertise your website here"/>
<h:outputText value="Your comment:" />
<h:textarea id="commentID" type="text"
         value="#{commentBean.comment}"
         placeholder="feel free to leave your comment here" />
</h:panelGrid>

Now AngularJS code

<table>
<tr>
 <td>Your name:</td>
 <td>
  <input id="commentatorsNameID" type="text"
         ng-model="yourName"
         placeholder="Anonymous" />
 </td>
</tr>
<tr>
<td>Your website:</td>
<td>
  <input id="commentatorsWebSiteID" type="text"
     ng-model="website"
     placeholder="advertise your website here"/>
</td> 
</tr>
 <tr>
   <td>Your comment:</td>
   <td>
     <textarea id="commentID" type="text"
     ng-model="comment"
     placeholder="feel free to leave your comment here">
     </textarea>
    </td>
  <tr>
</table>

So with this in mind, I would like to read your opinion about which of both is better for a simple Java Application or some real examples.

If anyone can point me in the right direction that'd be great. Sorry for the huge post, it needed a bit of explaining to make it coherent. Hopefully it makes sense. Thanks.

Antonio Cachuan
  • 475
  • 1
  • 9
  • 22
  • 1
    As you said, they apply to different sides of the request and thus are very different/largely independent of one another. Why not use both? You can use plain HTML with JSF as well or spice up the generated HTML. On the server side you'd still need some framework (at least servlets) to handle the requests. – Thomas Nov 26 '13 at 15:35
  • @Thomas Could be a good idea to use JSF and Angular. At this moment I am looking for a simple example of Angular and Java servlets. I found $http service (http://docs.angularjs.org/api/ng.$http) and I tried without success to send the request to the servlet. – Antonio Cachuan Nov 26 '13 at 16:12
  • JSF and AngularJS are completely different languages, frameworks and context (where they run) .. the only similar thing is the "JS" which stands for Java Server and for Angular is JavaScript, I'm not sure about JSF but I think you can use AngujarJS altogether as I can use PHP with it. Give it a try it's an awesome framework. – alejandro Nov 27 '13 at 17:36
  • 1
    1. As most point out, JSF are server side, and Angular is client side. To decide to choose which one is determine by your requirements and needs. E.g: Validation: can both happen on client side or server side, but if on client side, browser like chrome allow you to directly mess with the js, thus possible bypass the validation, while this will not happen for server side validation. 2: how do you want to talk to your model (other system/database ...). Client side will definitely need to talk to server somehow (whether it is via Servlet or WebService), like @Thomas mentioned. – Thang Pham Nov 27 '13 at 21:59
  • With all these in mind, JSF are quite powerful, not only it does server side, but there are many component suite ui that build on top of JSF like Primefaces(http://www.primefaces.org/showcase/ui/selectOneListbox.jsf), or Richfaces or Icefaces, that provide nice UI for JSF. – Thang Pham Nov 27 '13 at 22:04
  • @ThangPham Have You ever try to code JSF and angular JS. For example JSF include its own tags different from Html, may I include angularjs attributes Like ng-click? Thanks – Antonio Cachuan Nov 29 '13 at 02:33
  • @cachuan07: JSF allow you to write plain HTML or JS in it, so sure you can use Angular. However, JSF tag wont render "ng-click", for click event, it will render "onclick". But there is nothing to prevent you to have a "div" on a your xhtml page with `ng-click` in it – Thang Pham Dec 02 '13 at 19:06

1 Answers1

1

I dont know AngularJS but I work with JSF. JSF and RichFaces is ok for simple solutions like forms, tables, simple pages. But when requirements are more complex like dynamic rerender part of the page or some fancy features then things get more cumbersome if you try to do not standard things (especially when you want some complex validation where few fields depends on each other or you want to write own component). But generaly JSF is OK You can read more here

Have you considered building Web app without touching html :) ? Look for Vaadin

Community
  • 1
  • 1
bary
  • 1,699
  • 2
  • 15
  • 24