Are You Crazy Still Using JSF! - Ralph's Open Source Blog

Download as pdf or txt
Download as pdf or txt
You are on page 1of 7

2024. 04. 29. 7:33 Are You Crazy Still Using JSF!

- Ralph's Open Source Blog

0 4 / 0 9 / 2 0 2 2 BY RA L P H S O I KA

Are You Crazy Still Using JSF!


JSF stands for Java-Server-Faces which is a web technology that is underestimated by
many people. I wonder why is that? And are you actually crazy if you still use JSF? I don’t
think so and I will share some of my thoughts. (To get an impression about the
technology see the Getting Started Blog form Rudy De Busscher.)

Jakarta EE and Java Server Faces 4.0

The Specification
First of all JSF is a specification which is an important advantage over all the other
technologies that JSF is usually compared to. The specification is an open process that
is accompanied by many developers for years to define a general solid standard for web
applications. This specification process has recently taken place in the Eclipse
Foundation, which sets up rules that follow very high quality standards. This is one of
the biggest advantages, as it guarantees that your web application is build on a solid
core. Of course, other web frameworks also have large communities, but often these
are represented by a single company that does not always take the developers into
account. Angular from Google is just one example.

Server Based Framework


But back to JSF. Why is JSF sometimes ridiculed as an outdated technology? I
personally started with JSF in its early beginning in 2001. So it’s obviously an old
technology. And I am an old developer too ;-). In the meantime, many other web
frameworks have evolved. Many of them are based on JavaScript and follow the single
page paradigm (SPA) running in the browser. The idea is to move the application logic
https://ralph.blog.imixs.com/2022/09/04/are-you-crazy-still-using-jsf/ 1/7
2024. 04. 29. 7:33 Are You Crazy Still Using JSF! - Ralph's Open Source Blog

into the browser to get applications faster. This idea came up at a time when not
everyone was satisfied with JSF and JavaScript took off. Java Server Faces – as the
name implies – in contrast is a server based framework. This means the application
logic is executed on the server. And this is where we have the big difference. At that
time it was a valid argument to reduce the load on the servers. And of course, this
should still be a desirable goal today. But the people who use this as an argument
against JSF are often the same ones who rave about serverless functions. Therefore, I
don’t think we should consider a server-based framework as a stupid idea today.

Self-Contained Microservice
In fact, a server-based web framework offers some advantages. In this way, application
logic and business logic can be easily coupled. This is achieved within Jakarta EE mainly
through CDI, EJB and JPA. These technologies are the backend for JSF components.
Jakarta EE provides a very clear understanding of the separation of layers and JSF fits
seamlessly into this concept. The server-side implementation also hides application
details from the client. In contrast in a JavaScript SPA, large parts of the application
logic are usually unprotected in the browser which can be a security risk in some cases.

So rendering the application logic on the server side makes it more easy for developers
responsible for both – the backend and the frontend part. And this leads to the fact that
applications can be developed faster in many cases. From the point of view of the
microservice architecture, a JSF application corresponds to the principle of the Self-
Contained Services. This is a pattern which is commonly used in microservice
architectures.

Simplicity
Since JSF is often referred to as complex and clumsy, I recently wondered if this is really
true. I migrated one of my Vue.js SPA to JSF 4.0 and compared the complexity of the
resulting code. So finally, I would like to show in an example the simplicity of JSF. (Note: I
do not compare JavaScript code with Java here)

In JavaScript Frameworks you typically bind your HTML tags to some code by additional
tagging.

https://ralph.blog.imixs.com/2022/09/04/are-you-crazy-still-using-jsf/ 2/7
2024. 04. 29. 7:33 Are You Crazy Still Using JSF! - Ralph's Open Source Blog

<!-- Vue.js -->


<input type="text"
name="userwebsite"
v-model="userwebsite"
placeholder="enter your website">
Your Website is: <span>{{api}}</span>

The SPA framework resolve the tag (v-model) and place the correct value from your
model written in JavaScript. It also binds the input field to track changes of your model.

The JSF counter part looks not much different:

<!-- JSF -->


<h:inputText value="#{userController.website}"
pt:placeholder="enter your website" />
Your Website is: <h:outputText value="#{userController.website}" />

Here you also bind your model values to input fields or output text. But the code is
executed in Java on the server side which is often equal to your backend code written in
Java also for SPAs.

Ajax is used by JavaScript Web frameworks out of the box. So you usually have no need
to care about it. In the example above the span tag is automatically updated when the
value of the input changes.

In JSF you use also Ajax, but you have more control about how it behaves. You can
simple enclose a part of your page with a f:ajax tag to get the same behaviour:

<!-- JSF -->


<f:ajax>
<h:inputText value="#{userController.website}"
pt:placeholder="enter your website" />
Your Website is: <h:outputText value="#{userController.website}" />
<f:ajax>

Another example is linking. In a JavaScript framework you use again a kind of tagging to
initiate a rendering life-cycle when the user clicks on an element:

https://ralph.blog.imixs.com/2022/09/04/are-you-crazy-still-using-jsf/ 3/7
2024. 04. 29. 7:33 Are You Crazy Still Using JSF! - Ralph's Open Source Blog

<!-- Vue.js -->


<li class="nav-item" v-on:click="showSection('search')">
<label>Search</label>
</li>

The showSection implements some business logic in your JavaScript code and is
responsible for handling data and changing the layout.

JSF is not much different:

<!-- JSF -->


<li class="nav-item">
<h:link outcome="search" >
<label>Search</label>
</li>

The h:link tag loads a new page from the backend named ‘search.xhtml’ containing
the new layout. All the model binding is handled behind the scene in the backend. For
the user there is no different in behaviour.

So as you can see from the markup, there is not much difference and it is not more or
less complex to write a JSF frontend as it is in JavaScript based Web frameworks.

Conclusion
My personal conclusion is that JSF gives me a clearer and more consistent concept for
writing my code within a framework. Backend logic and application design are
combined in one technology resulting in a pattern also known as self-contained
microservice.

To me, this is a valid concept even for modern web applications. And computing
application logic on the server side is not crazy at all.

With JSF Version 4.0 you will find a modern and well designed Web technology
embedded into the latest Jakarta EE 10 framework.

https://ralph.blog.imixs.com/2022/09/04/are-you-crazy-still-using-jsf/ 4/7
2024. 04. 29. 7:33 Are You Crazy Still Using JSF! - Ralph's Open Source Blog

ARCHITECTURE

J A K A R TA E E , J S F

9 Replies to “Are You Crazy Still Using JSF!”

J. Domingos
2 7 / 0 9 / 2 0 2 2 AT 1 2 : 3 2 P M

To be honest, I feel the same way to regarding to this topic.

But the hype on Javascript frameworks and clean font and back-end separation may be
the major reason for JSF exodus towards JavaScript realm.

Starting new projects using JSF (or other non Spring framework tech) is considered a
“crazy” move.

Utkarsh
2 6 / 1 1 / 2 0 2 2 AT 3 : 0 1 A M

Jsf like frameworks are facing revival.


Now they are called server driven ui frameworks

querwurzel
2 7 / 1 1 / 2 0 2 2 AT 1 1 : 0 2 A M

The frontend-backend separation is not only about technology but also about developers.
You can stay in JS land while developing rich frontends and are not forced to know Java
Land.

Anyway .. thanks for the blog post, I liked it, reminds me on my studenthood. For simple
views I even just stick with JSPs on my side projects. And server-side rendering has never
died thanks to SEO .. =)

JEE_Developer

https://ralph.blog.imixs.com/2022/09/04/are-you-crazy-still-using-jsf/ 5/7
2024. 04. 29. 7:33 Are You Crazy Still Using JSF! - Ralph's Open Source Blog
2 5 / 0 7 / 2 0 2 3 AT 9 : 5 8 A M

I think JSF is a great technology, i know it well and never left it. I have not found a single
valid reason for that. I even developed a complete development framework for developing
JSF SIngle Page Application:

https://medium.com/@j2eeinside/the-jsf-single-page-applications-spa-with-dynamic-
tabs-f85b9a5f6b94

https://www.linkedin.com/pulse/jsf-job-flow-new-development-model-single-page-
dynamic-radoj%25C4%258Din/?trackingId=zT1jM7TRSPWRZMBm9SSCnQ%3D%3D

Cyper
0 1 / 0 8 / 2 0 2 3 AT 1 0 : 1 2 P M

JavaScript is an universal language whether your background is Java, C#, Golang, Python,
Node.js.

JSF is too limited, it’s just for “old” java boy.

Also a designer/front-end guy can pick up javascript/css (or even vue.js) quickly and craft
some beautiful UI framework. It would be a nightmare for them to use JSF.

JEE_Developer
0 7 / 0 8 / 2 0 2 3 AT 8 : 2 4 A M

@Cyper, “JSF is too limited”


– in what way is it limited? I don’t really feel any restrictions. These are pure prejudices,
which have been adopted uncritically.

@”|and craft some beautiful UI framework…It would be a nightmare for them to use JSF.”
– Take look at

https://www.primefaces.org/rain/
https://www.primefaces.org/mirage/

JEE_Developer
0 7 / 0 8 / 2 0 2 3 AT 8 : 3 2 A M

And just to say:


@”JavaScript is an universal language whether your background is Java, C#, Golang,

https://ralph.blog.imixs.com/2022/09/04/are-you-crazy-still-using-jsf/ 6/7
2024. 04. 29. 7:33 Are You Crazy Still Using JSF! - Ralph's Open Source Blog

Python, Node.js.”
-You mean that the backend is actually a rest, right? FYI, JSF can also work with a REST
backend. You need to know things if you want to seriously discuss them

JEE_Developer
0 7 / 0 8 / 2 0 2 3 AT 3 : 0 8 P M

@Ralph, I think you are missed one of my comment….

Ralph Soika
0 7 / 0 8 / 2 0 2 3 AT 1 0 : 3 3 P M

@JEE_Developer, I agree with your comments in total.

And I also read about this trend, @querwurzel mentioned, that javascript is going back to
the server (for good reasons). We call this now “server driven ui frameworks”.

https://ralph.blog.imixs.com/2022/09/04/are-you-crazy-still-using-jsf/ 7/7

You might also like