Is JSF 2.2 suitable for modern HTML and CSS?

Asked

Viewed 1,423 times

8

I will develop several web applications, and in most of them, besides receiving the documentation with the requirements, I will receive from a good web designer, all the front-end (static) with HTML, CSS and Javascript, using modern layouts.

My mission will be to transform this static front-end into a functional java web application that meets the requirements, among them, maintaining the original front-end layout.

Knowing that JSF is a tool that generates HTML, will it meet all my requirements? Or I should look for an alternative that I have more control of the generated HTML, such as JSP?

  • You have no more control over the generated html using JSP than using JSF. You may have better things but JSF will do. You will only have to modify some tags in the designer’s HTML in order to point to the properties and methods of your Beans. You can even teach the designer to make this link to test Beans and to use JSF tags when applicable instead of html tags. A good singer can learn this. I’ve seen a few who have, in Java and other platforms. Another option is you first backend each page or each part of the page and the designer act next.

  • 3

    Bruno, as far as I know, jsf version 2.2 supports custom attributes (Pass-through attributes) which you can use to make configuration using your javascript framework or components. Another way is to write your own components, where you control the behavior and the generated Markup. I believe that everything you can do with JSP, you do better with Facelets (I may be wrong). In addition, JSP is an older technology, and facelets incorporate many more advantages than jsp. (e. g: UEL).

  • 3

    As for the JSF itself, I don’t know if it’s the best alternative, because its integration with front-end frameworks (Angular, Knockoutjs, Ember, React, etc.) is quite complicated, but it’s possible. Another problem is the component libraries, which have a lot of css and need to be overwritten, which makes it difficult to use a CSS framework (Bootstrap, Foundation and etc...). But you can take into consideration the possibility of building Webservices in Java EE as well.

  • I’ve done a job like this using JSF 1.2 and it worked. It was a bit of a hassle. You need to know what the component renders. nor try to apply a front-end framework. for this I suggest html statico and the java-rs that would be mounted its api.

  • @Wakim The JS frameworks you described are to facilitate the implementation of single-page Applications and have nothing to do with getting ready the views in HTML and CSS from the designer; likewise, if the views are already ready, no JSF component library will be used.

  • @Caffé, I agree, but it is possible to use these frameworks without routing, only with Data Bind, Template and etc, which is already very interesting. I already worked on a project where Primefaces and Knockoutjs were used, to take advantage of several of the Primefaces features that JSF adds but trying to have a larger processing in Javascript to reduce the load on the server. In the end we finished the components based on Primefaces but with our own Renderer to generate a Markup interacting with Knockout.

Show 1 more comment

1 answer

4


I got caught up with a question like that about 5 years ago at the launch of JSF2.1 and chose to use JSF to do my projects. It was the worst decision I ever made:

  1. "I will receive from a good web-designer all html, css and javascript...". If you are really a good web-designer it will give you several pages with functional jquery plugins. Modern layouts made with some css framework like bootstrap and html 5. In my time JSF did not support Html5 tags, in fact it did not accept anything but the tags themselves, but now it seems to be better. When we talk about the rest I see problems, usually all JSF components (I used prime) use Tables and various archaic structures to generate a compatible html for all browsers. The result is that you’ll spend more time adjusting JSF to do something similar to what you need than reusing what the web-designer gave you.
  2. "Modern applications..." usually require various gimmicks and jquery libs that the designer will insert into the application and lots of ajax communication between pages. At this point you start to have problems with JSF in the scripting part, because you will have to use the ajax part that it gives you, and abandon what the web-designer had predicted. Using JSON with JSF is simply unnatural and almost always you’ll find yourself writing conversions manually.
  3. The "Component" template that JSF uses is not suitable for traditional web applications, such as open web applications. This type of model consumes more memory and will require a more robust server depending on the number of accesses you want. For these types of application it is better to use something of type MVC.

I think JSF is useful for creating traditional applications, like admin panel, etc. Applications that run away from the traditional one is better to use some tool that really gives you freedom. Since then I only use JSP as a template, even some components like select are written in pure html. Some will find this a return to the age of caves, I prefer to think that so the component is rendered perfectly, without breaking any pixel of the layout, in devices of all sizes. And that’s all that matters to me at the end of the day.

  • It is perfectly feasible to use pure HTML5 with JSF and even merge the use of both in the same view. You say "all JSF components (I used prime)" But if AP will get the ready views in HTML, CSS and JS, it is obvious that it will not use Primefaces. There is also no problem using any JS to make AJAX requests to the JSF server, as well as never having any difficulty using JSON+JSF. Finally, JSF is MVC. Too bad you find so many difficulties in making a modern application using JSF, but AP may have more luck as I had, and can post here your specific questions.

  • 1

    @Caffé I share the same pains as Célio. If HTML comes ready, JSF would only be used to do the bind of the screen fields with the model. Of course you can use pure HTML in a facelet and do manual Ajax, but then what is the purpose of JSF? It would be an unnecessary complexity. In this case, a framework action based ends up being much more advantageous.

  • 1

    By the way, the JSF may even be MVC, but quite different from a traditional web MVC. The model Component based stores by default server status, scopes of Session and view break the model stateless HTTP, the normal navigation model, without redirection, causes several navigation problems. Of course, you can use request Scope, store the state in client and redirect the user after each call. Except that out of the common bugs in JSF implementations that arise when you leave the pattern, at the end of the day so many adjustments are needed that ends up just like one action based.

  • @utluiz I do not believe that the model of navigation without redirection is the "normal", although I agree that unfortunately this is widely used. I also don’t see why a view built by a designer would make it impossible to use JSF Ajax. But I also don’t know what designer we’re talking about; the designers I’ve been working with know the part of the framework that concerns their work, be it JSF, Rails, React... and have the environment and knowledge to develop and test the views. There is no "html ready" in a web application - it will only exist on static pages.

  • @utluiz As for MVC, JSF actually makes a very transparent MVC which you don’t even realize you’re using and from which you easily escape precisely because you’re not worried about the concept. Anyway, the question does not require MVC.

  • I’ll stick to the content of the conversation. I have over 8 years of experience working with JSP (5 years JSP and Servlets and 3 years working with JSF 1.1, 2.1, and 2.2, last project use botstrap, js libraries (here always have Adjustments)but what I mean is that if you have $$ and knowledge to make your own framework do. but the primefaces with JSF 2.2 is excellent. Use the most modern thing about css (class inheritance, complexity that all speak, runs and loads css classes at runtime, if you don’t know how to overrate css class, then it will hurt),

  • As for the parrudo server is history, my server is from 2GB to OS and the system and still leaves 300MB, for 100 Simultaneos users. nowadays this is so cheap, that 2 to 3 hours of service buy or rent a lot of memory (there will spend 1000 hours to make a framework and another 20 hours per month to give maintenance to the framework), then need to put in the balance, other your application needs and should be distributed if you need to meet a large number of users, to meet scalability.

Show 2 more comments

Browser other questions tagged

You are not signed in. Login or sign up in order to post.