Java-EE: Cleaner and simpler alternatives to JSF [closed] - java

Closed. This question is opinion-based. It is not currently accepting answers.
Want to improve this question? Update the question so it can be answered with facts and citations by editing this post.
Closed 9 years ago.
Improve this question
We are starting to develop a web application using Java EE 6.
We got surprised with the complexity of the JSF's generated HTML. I mean even a simple link has some javascript handling code. and this is, in my opinion, a usability problem because browser's gestures (as "ctrl+click" over a link) simply doesn't work. Also, I'm suspecting this could get worse when we need to maintain that code or tweak the UI design with javascript frameworks like jQuery. it reassembles me: Webforms vs ASP.Net MVC. complexity against simplicity.
Anyway this is my first time with JSF. so I really would like to read your experiences with it.
Do you know a simpler rendering engine for Java EE?
How has your development experience with JSF been?
Have you developed a web app using JSF and lots of jQuery/Dojo/Script.aculo.us?

It is hard to define what "simple" means when you ask about a "simpler rendering engine". JSF is a very unique animal and I am afraid there isn't anything simpler that is also similar in the Java world.
My experience with JSF has been EXTREMELY positive, and this is coming from someone with years of experience developing under ASP.NET. The learning curve is still steep, and I can't imagine complex enterprise systems being possible without some form of custom Javascript and possibly even custom components, however in my opinion it is simpler than ASP.NET and much less heavy as well. They addressed a lot of the issues that made ASP.NET so difficult to work with, (Eg. simple client ids for the DOM, XHTML compliance).
I recently developed an application that will be going to production shortly using only Primefaces components, standard Mojarra facelets, one custom component, and a handful of Javascript/hidden input field workarounds for component framework bugs. It was stunningly easy aside from the few workarounds I needed to implement. I am extremely happy with the results, the stakeholders LOVE IT and I will absolutely use it again in my next project.
In formulating a team my real world experiences with it tell me that it is best to put a highly experienced web application developer as a lead on the project, someone with superb experience in Javascript, CSS and Java web technologies. The rest of team could be entry level developers with a modicum of guidance.

I've been working with JSF on a large project. I have experience of working with JQuery, normal HTML/css/javascript, GWT and Gxt. And I can tell you that JSF is the worst of the bunch. If you like your back-end code to be separate and independent of your front-end code then JSP is not the way to go. It littery ties your front-end to your back-end with no clear separation of concerns. The other problem with JSF is that it is very hard to get your head around. Creating great AJAX pages in using frontend technology (e.g. javascript, html and css) is very easy. My 14 year of son gets taught how to do it at school. Getting the same effect using JSF is incredibly complicated. Take a look at how to define as link: <h:commandLink value="New" immediate="true" action="#{projectUiService.showProjectCreate}" />. And there is no way to specify a form action url. You have to use the JSF managed beans and navigation semantics. It's a completely new front-end language. So even if you want to style up the front-end or add JQuery in you'll be stuffed.
Configuring your build and runtime environment is also a pain. There are so many inter-dependencies among jar files that if you don't have the right combination of JSF, Richfaces, and Spring Jars, then you have no hope of getting your application even out of the build build environment. If you want to get a hint at this then go to the maven search site and look for the class javax.faces.component.UIViewRoot. Everyone and their dog has it. Also take note at the javax.faces and com.sun.faces - what's the difference? Who knows, but they don't work together. And some version only work with specific version of RichFaces.
My advice - stay well clear. Give your app a spring back-end and a normal HTML front-end. There is no way you can write a decent large enterprise scale application in JSF. It would be just too complicated. You'll end up with a huge monolithic code base that would be almost impossible to maintain.

Do you actually need a component-based framework like JSF or are you looking for a more traditional web request-based MVC framework? If so, you may want to look into Apache Struts2 or Spring MVC. Spring MVC requires that you use the core Spring library.

I've been working with JSF for 3 years and I can say that the most powerful thing about it is that it abstracts the communication between browser (form input or actions) http request and Java.
There are rich libraries available for JSF, like: ICEfaces, RichFaces, ADF Faces, PrimeFaces, which gives you a big amount of rich components that may be enough for you.
JSF tries to make development of web applications more close to desktop applications. It addresses the most common tasks for a web application (no matter the technology) and automates them using its LifeCycle. However if you want in some cases a certain behaviour that's different from how a component works, you have to make some workarounds, or build your own components (which may be hard, except for composite components).
I have integrated JS successfully for tasks that didn't need to trigger some action in Java like select all checkboxes, hide/show some parts of the page, and so on.
JSF is very easy, yet very powerful, and requires a certain expertise for some tasks.
The last version of JSF, 2.0, addresses the common problems JSF had, because of its POST nature, so now I'm very happy with it.Regarding users gestures like ctrl+click, the way web applications in JSF work is a little different than normal ones, buttons Back, Forward, Refresh might not work as expected sometimes. But hey, great web applications have the same behaviour: Try Ctrl+Click in PayPal .. or try Back Button in Vodafone.ro
If you want full control over your HTML, use plain JSP. But when you have a huge web application, JSF is a good option for Rapid Application Development(RAD).

Do you know a simpler rendering engine for Java EE?
JSF IS the most powerful technology for presentation layer in the mainstream Java EE. That became true only after introduction of "Composite Components". However the less known HybridJava solution is non less powerful but yet simpler than JSF.

Related

Choosing between Thymeleaf and Angular for a new Spring MVC project [closed]

Closed. This question is opinion-based. It is not currently accepting answers.
Want to improve this question? Update the question so it can be answered with facts and citations by editing this post.
Closed 5 years ago.
Improve this question
I'm starting a new Spring Boot web application and I need to make a choice about how to implement front-end.
I'm really comfortable with Thymeleaf templating framework that I used in several projects, but I'm evaluating Angular (v2) as a possible alternative.
I'm quite new to client-side MVC frameworks and I'd like to understand if there are some guidelines to decide which option is the best for a web project.
I've read a lot of posts and tutorials about this, but they all seem to describe personal opinions or to be just coding experiments...
Are there some application requirements that objectively suggest to use a client-side approach instead of a server-side implementation?
Is it possible and effective to use both the technologies together?
Thymeleaf and AngularJS are not mutually exclusive. You can certainly use them together, depending on what you are trying to accomplish. If you are all in on writing a single-page dynamic web application, Thymeleaf is probably unnecessary.
Speaking to your question about client side frameworks vs. server-side ones, I'm an Enterprise Software Engineer, so I am not creating commercial software and my priority is less about how pretty it looks (a little Bootstrap does the trick) and more about stability, browser compatibility (even with older browsers), and maintainability. I personally avoid the single page, dynamic web applications because I find the code base more difficult to manage in non-trivial applications; a large Javascript code base can be a bear, in my opinion. Building up my pages primarily on the server side provides me with better debugging capabilities (Java is going to give you a lot of compile time help that you don't get with Javascript) and easier logging. I do use javascript (mostly just jquery) on the client side, but generally my web apps are built to degrade gracefully if the user has javascript turned off. Again, these are internal, utilitarian, applications to support the business. I don't have time to write a whole thesis on the subject and there are plenty of nuances that I'm not covering, but hopefully this is useful.
If you need your web app to act more like a mobile or desktop application, then single-page dynamic web app using a framework like AngularJS is one way to go.
The choice isn't whether to use one JavaScript library or Thymeleaf, that would be an artificial constraint you created, they are both different animals. Thymeleaf is for templating, JQuery is a client side library for making dynamic pages. It would make more sense to choose between templating libraries or choosing between JavaScript libraries, but both can go nicely together.
In general, your templating should not affect your JavaScript code, some people do template their Javascript code, but IMHO this is a terrible idea. Instead use Templating to replace tag attributes in HTML, and Javascript for making your website dynamic with whatever library you choose.
I'm not sure what you mean by
client-side approah instead of a server-side implementation
But what I see nowadays are 2 different approaches, creating Microservies VS Monolith web application. If you develop your website entirely in Thymeleaf you will not make it very reusable. Netflix, Amazon, Uber etc. all create services (sometimes called micro-services) which are reused throughout the organisation via a REST API.
If you only have a website implemented in Thymeleaf it will not be possible for another application (think mobile) to access any services created by your application, whereas if you create a REST API for your app then you can keep reusing your server back-end for when you need to make a mobile app, or another web app with similar requirements.
Of course if your services are not going to be re-used this might not matter to you and you might be very proficient in doing things a certain way albeit not being the most reusable, of course we are not always creating the next Amazon. But I still believe it is good idea to follow best practices, even if its just to get better at doing things a certain way.

upgrade to javaserver faces. Easy task?

I have the following question:
First of all, I know (and have some academic experience on) JSP and Struts but I know nothing at all about JSF.
There is a project that has its front-end already made using applets.
I was asked to look into to change/upgrade it to JSF.
So my question is, is this an easy or at least straightforward task?
I am asking this since i)I do not know the learning curve of JSF and ii)I have given up on learning applets long time ago (I presumed this technology dead)
Any input on this is highly welcome!
UPDATE: If it makes any difference, they want to leave applets due to the sandbox restrictions.
Thanks
Programming in JSF requires solid knowledge of the Servlet API and understanding of the ideology behind using a (component based) MVC framework on top of Servlet API. It also requires solid understanding of the "client side" and "server side" aspects in web development. If you lack any of those understandings, then the learning curve will indeed be pretty steep.
With JSF you basically end up with a JSP or XHTML (Facelets) page as View and an ordinary Javabean class as Model. You also need to realize that an applet is basically a piece of software which runs at the client machine and that JSF runs on webserver, generates HTML/CSS/JS which get sent to the webbrowser where it get interpreted/applied/executed. It doesn't run Java code at the webbrowser as an applet can do. It's a huge difference.
To get started with learning JSF, you need at least to have the minimum required skills for Java webdevelopment, then you can start with either of the following tutorials:
Java EE 6 tutorial - JSF 2.0
Coreservlets tutorials - JSF 2.0
Moving from Struts to JSF is a paradigm shift in the way you approach a problem (my opinion). Struts uses action based model while JSF uses component model (something like writing a desktop GUI application using Swing etc). And to make things even harder for developers, JSF comes with complex request processing life cycle backed up by a no-good-for real world problems implementation in JSF 1.1.
I've seen people moving from struts to JSF struggling a lot and thus producing a code base that is mix of both the worlds (action based and component based). This mixed code base is very hard to maintain and debug.
Having said that, JSF is still the spec and if you can use JSF 2.0 (or atleast JSF 1.2) with Facelets, then my suggestion is to do a simple proof of concept considering the below factors
Learn the basics JSF 2.0 or 1.2 with Facelets
Take up a complex use case (in terms
of dynamic UI) supported by the
current applet
Build it end to end covering validation, templating, listners, actions
Then do the same usecase in GWT or Vaadin. I am suggesting this because your users are currently used to thick clients using applets and GWT is meant for this
And if you finally happen to choose JSF 1.2 or 2.0 then I highly recommend using the PrimeFaces component suite. It is fast, simple and rich with components.
In general I don't think I'd call that an easy and straight forward conversion, because the environments are so different. With the applet the java code runs on the client system and communicates back to the server with some kind of protocol. JSF runs all the code in the server and can access your data directly. For planning purposes, I would not expect to be able to use any of the existing UI code.
There are libraries out that that take your Swing program and turns it into a web based application. I haven't used any of them, but I know people that have had good success. It would depend on which direction you want to take the application. JSF is gaining ground so the tools based on it will only get better.

Which Java technology should I use, if I want to build a website with thousands of users?

Sorry for asking this question, but I searched all Java-related questions, but I got more confused. I am still not clear what should I start with.
My main thing is building websites in Java, because someone told me that there are some machine learning or AI libraries available in Java which I can use in Java. So I decided to use that as it can reduce my work.
Now I don't know Java at all. Some people say the following are used to build websites, like:
Servlets alone can build a website
JSP alone can also build a website
Struts
Spring Framework with Hibernate
Seam
Java EE also for websites
I am confused. Where should I start from? Where does core Java fits in here?
I was thinking of perhaps learning Python as I know I have to learn Python only, not its variations.
So please guide me to one thing which can solve my basic purpose of using ready-made libraries of AI.
If I can do that with JSP then I will start with that.
But if I need to learn all of them, then it’s better if can start learning Python.
I have five months to finish the website.
I really don't know why there are many branches of Java for doing one thing.
To correct some misconceptions of yours:
servlets and JSP are Java EE
Seam and Struts can be used together with Hibernate as well
Spring MVC is a web framework. Spring as a dependency injection framework can be used together with any other framework.
there are many more options, like JSF, Tapestry, Click, Play, etc.
It depends on what will the site will be doing, but you can choose any.
Experience has shown that building complex HTML forms (especially validation) and Ajax functionality is hard to get right. You will most likely appreciate having a library to assist you with that. The same thing with database access.
Everything builds on servlets. Learn those in order to understand the libraries you will use.
I would suggest learning JavaServer Faces (JSF) with facelets. The easiest, while being powerful, is JSF 2 in Java EE 6. The easiest way to get started is to use NetBeans with GlassFish 3.
For static web pages, HTML alone is enough and if you want to make it more user-friendly and interactive, use JavaScript.
There are lot of frameworks you can use directly in JavaScript, like jQuery. Now if you want to make some more functionalities, like database interaction, then you will need either PHP, Java (JSP and Servlets) or .NET (there exist some more, but I’m aware of three only). Each of them have their library to interact with database.
Since you are interested in Java, go through Servlets, HTML, JavaScript, and JSP. Once this is done, you can look into JSF and EJB beans. So if you have knowledge of Java this will not take too much time, because the syntax is the same; the only difference is the concept.
So you will have a frontend (HTML, JS, and JSP) which will interact with the backend (Servlets and the database) which will be deployed in a Web container. To deploy, you can use an one of the available application servers, like Apache Tomcat, GlassFish, or WebSphere. To develop your application, you can use Eclipse as the IDE, which is one of the best IDEs I have used.
So decide your architecture and design, break it into components and start writing small applications first. Once you are experienced in small application, start writing an application where there are more things you have to care of, like load on database, availability, security, etc. For that, you can refer a very famous question on Stack Overflow, What technical details should a programmer of a web application consider before making the site public?.
The closest to core Java is servlets. No extra syntax, very minimal library, but no included functionality.
For building websites, the main thing is HTML and HTTP.
All technologies (including Enterprise Java or Server side Java) do the same—to understand an HTTP request and respond back with HTML. All that you mentioned do the same thing with a different level of sophistication.
Start with Wikipedia.org to know what technologies do what. If you are completely new to Java, go through the Sun tutorials, do sample programs, and get comfortable with Java packages, JVM and classes. (This might take a week or two).
To build websites using Java, you'll have to learn Java Servlets—everything else (JSP, Struts, JSF, and Spring(!)) are built on it. Get Head First books on Java and Servlets; they will be useful.
You can always build the page in Ruby or something that will give you a website very fast. For the AI stuff that analyzes the bought items for the recommendations, use something unrelated to the page that only takes the database to work with.
I would not mix the whole web page stuff with the AI computing. You can do the AI things that will take a long time and maybe should done on a different machine to have your webpage also responsive with C++ or Java in normal applications.
Choosing your front end technique because of later usage is a very dangerous thing. Using the whole Java EE concept and learning it from scratch will take you much longer than have a quick start with your page if you do it in Ruby or PHP.
You can then build the first version of the page and generate a user base. Start working on the AI stuff once you got some data with other technologies.
If your page has performance problems because your technology does not scale, you can always begin switching parts of the stuff out with a faster technology or maybe simply a bigger machine. Get your page running before you build it bulletproof for the thousand users you are expecting.
If you’re trying to build a website from scratch, with no prior knowledge, your best bet is to go with frameworks that provide a complete stack for web development.
If you aren't dead set on Java, you could probably start learning Ruby on Rails, which would be easier to start with (if so, go buy a Ruby on Rails tutorial which goes through all the necessary things for modern web development, from MVC to version control).
For Java, try:
Play Framework is very similar to Ruby on Rails. It will get you started very quickly, and hopefully (if you follow conventions) handle all of your peripheral needs.
Spring Roo is a very-fast-to-work-with framework, but it might get hard to maintain and extend later on.
These two are full web frameworks, that is, they handle database, MVC (presentation layer), configuration setting, etc... (I'll explain shortly). And could even ease your deployment process.
If you're going to go through any other route (using several frameworks together), you are probably not going to finish what you are doing in five months.
To understand why, and to clear some things you wrote in your question, you need to understand that modern web development (and enterprise development as a whole) is comprised of several different technologies:
Presentation: the term web frameworks has been more or less taken to mean frameworks that deal with this side of web development, i.e., how to create a web page (an HTML page). Most of the frameworks offer an MVC like approach (which you can read about elsewhere), and this is what most of the frameworks/technologies you gave sit in—JSP and Struts (which uses JSP) are examples of web frameworks. Servlets is a lower-level API that standardizes how to answer HTTP requests (which JSP and Struts sit on top of).
Persistence: being able to show a webpage doesn't mean squat these days if you can't save data to a database, and that is what the persistence frameworks do (they ease the way you can save data to the database). Hibernate is a persistence framework.
For Java there are also dependency injection (DI), which is what Spring DI is. It's tough to explain DI to people not familiar with the troubles of Java, so I won't try to explain it, but it's a very important part of modern Java development.
apart from these core technologies, there are also many items that you'll need to learn to actually deploy the application (unless your using services like Heroku or Google App Engine, which should simplify things), and troubleshoot it later (understanding how concurrency and HTTP works).
To address the other technologies you brought up:
I've never really touched Seam, so I'm not sure, but it looks like a collection of other frameworks (mainly EJB 3, which itself is a collection of APIs, and JSF).
Spring denotes a popular open source group (the SpringSource group) that provides various technologies, but most likely when you hear about it they refer to two things Spring's dependency injection (DI) and Spring's MVC (which is a web framework).
Java EE is merely a collection of high level APIs which other technologies implement (Hibernate implements JPA which is part of Java EE for instance).

I would like to build a Java Web Application. What's the quickest start?

I am a reasonably competent programmer, with about 11 years experience.
I particularly like Ruby/Rails and ActionScript.
And Java is easy enough, I've used it for ordinary applications, and mostly as ones that run on the server, just not web-based ones.
I'd like to develop a web application in Java in order to leverage things like BlazeDS and help tie front-ends together with my previously-written Java apps. i.e. use existing Java code but in a web context.
But I'm having trouble - and confused - looking for a smooth start. I don't want to use Grails, been there, thanks, I want to use Pure Java, with whatever Framework you can think of. Spring, Hibernate, etc.
Where do I start?
Play Framework lets you get started quickly. http://www.playframework.org/
Spring Roo is a RAD framework for web apps. It's similar to like Rails or Grails, but uses code generation instead of metaprogramming magic.
This thread contains useful pointers on starting Java web development
http://www.daniweb.com/forums/thread249070.html
Since your goal is "Pure Java," how about Wicket? Straight from their feature list:
Wicket does not mix markup with Java code and adds no special syntax to your markup files. The worlds of HTML and Java are parallel and associated only by Wicket ids, which are attributes in HTML and Component properties in Java. Since Wicket HTML is just HTML and Wicket Java is just Java, coders and designers can work independently to a large degree and without relying on any special tools.
If you want more info, there's a web page on why you should use Wicket.
I've really enjoyed working with Spring MVC. It took a while to ramp up with Spring, but the whole affair has just made since after investing the time.
I have found JavaServer Faces 2.0 using Facelets to be a good compromise between power and ease of use, plus it allows you to use a lot of extra libraries when you get more advanced.
For JBoss you need to include JSF in your web application. Download the 2.0.2 distribution and see the documentation in there.

Looking for a good, practical example how to use JQuery or YUI with Java web application [closed]

Closed. This question does not meet Stack Overflow guidelines. It is not currently accepting answers.
We don’t allow questions seeking recommendations for books, tools, software libraries, and more. You can edit the question so it can be answered with facts and citations.
Closed 8 years ago.
Improve this question
I am looking for an extensive example or, the most preferably, an open source project with a nice, modern, ajax-enabled user interface which is using JQuery or YUI on top of Java web application - it can be full Java EE application, JSF only, Spring MVC application, anything.
I would like to learn what are best practices to create such applications. In particular how to efficiently make use of the JavaScript library with a chosen Java web UI technology: JSP, JSF, Spring MVC, etc.
I am not particularly interested in simple demo examples, simple things I can figure out myself, I need something bigger so I would be able to investigate overall UI creation strategy, how clean the code is, how difficult were particular features to apply, etc.
You will find plenty of ways to build web apps, and I'm not sure there's a clear winner. In the end it is just a matter of personal taste or related to your knowledge background.
My advice anyway when you will look at them is to consider a clear separation between the frontend and the backend, and build a flexible UI (in the model of iGoogle or netvibes)
The frontend, presents the information in a human format. The browser code is JS, HTML and CSS. May be flash if you really want.
While the backend handle the authentication/security and the business logic and send or receive only JSON or XML messages.
I did that before with SAP serving XML and the browser rendering it with XSLT and Javascript.
And now in my current project Erlang serving JSON and the browser rendering it with a JS template engine and JS.
In both cases, this is giving really responsive web apps. As you optimise the network usage.
And finally about the flexible UI. I mean think in widgets instead of a monolithic app. It is not easy to get, but once it runs it is an amazing way of building web apps.
Here is a small video we just released to highlight this.
My personal favorite is jQuery on top of Spring-MVC. SpringSource.org has put together many great sample applications demonstrating the Spring-MVC framework, and the "mvc-ajax" project includes some great jQuery examples of how to generate ajax requests to the server that returns json to the browser.
The subversion repository for these projects is here.
Many jQuery components are actually being wrapped inside different components from jsf libs (like RichFaces).
As I understand (I only worked for few months with jsf and so I'm still a newbie) it's counted a bad practice to mix jQuery UI with clear jsf (with components) ui.
I can only guess that if you want to use jQuery UI with your jsf then you probably need to create custom jsf component and wrap chosen jQuery component.
The best example i can give you is GOOGLE.
They use all the stuff you talked about.
Unfortunatly GOOGLE will not give any part ot their code.

Categories