📜 ⬆️ ⬇️

JSF is dead?

JSF is Dead!


This is what I heard when I went to try the developer in one office. What an office does is not a topic topic, it’s enough to know that they use grails. To my question “why not JSF?” I heard what I heard. Judging by the latest posts about JSF on habr - the truth speaks! Not?!

What's in a name?


It would seem, well, he died and died, why are you clogging up the tape? But IT is itching! Grails and Play were found on the Internet! (keep silence about Spring - it’s slippery without it). In both, they sketched a project for 5 pages, with molds, a basic set of controls and navigation - beautifully. They closed ... They opened a maven-project with JSF 2.2.14 from 11.2016 (2.2.13 from 02.2016 ! DEAD !?) and continued to work.

Problem


In one not very large project on JSF, it was necessary to add FORM-Authentication with users from the database. Nothing complicated: here are a couple of JPA classes, here is a JSF page, a list of available roles in web.xml and security-constraint. STOP! Why is it so difficult ?! In Grails and Play! - a couple of annotations / methods and EVERYTHING! How to change web.xml if the list of roles changes? I thought ... Why is everything so and how does it work? Authentication is simply a process of checking the login-password pair, then a parsing of the URL and checking that the user has the appropriate role. So far everything is logical, but there is a nuance! Where exactly is the reconciliation of roles? Well, i.e. literally - where is the SAME point in the code, when will the reconciliation of roles occur?

Grails, Play !, etc.


The answer is: where is the annotation, there it is checked. If it is very rough , the request processing will look like this:
')
  1. User created a request
  2. Controller found by URL
  3. Annotation found in controller
  4. Checked the role
  5. The controller has prepared a model
  6. In the controller selected view
  7. Rendered to user

JavaServer Faces (JSF)


Answer: why do you need it? Anyway you will not find ... o_O

That's because in JSF, the processing will look something like this:

  1. User created a request
  2. The required role found by URL
  3. Checked the role
  4. Controller found by URL (FacesServlet)
  5. The controller on the URL found view
  6. By EL from the view prepared a model
  7. Rendered to user

And then I realized that I did not understand anything.


How to compare things like JSF and Play! or jsf and grails? They are just different ... If for some - the key element is the controller, for others - view. Some decide "which page to draw?", Others decide "what to draw?". Like the controversy: "what page" and "what is on the page", but the essence changes dramatically. But I understood why the GET parameters are declared in the view and why the links should be with "faces-redirect = true".

I also realized that to work with arbitrary roles, you need to write a filter, and, lo and behold , with annotation of WebFilter !

Afterword


Colleagues, forgive me my confusion in the story - I am writing how to communicate. In the text on purpose:


And in JSF 2.0, we drew an adequate implementation of custom tags and Flow. If interested - I will be glad to tell you, because about JSF topics really really outdated ... :-(

Source: https://habr.com/ru/post/315894/


All Articles