How to improve the UI of an existing Struts web application? - jsf

There is an existing web application created in Struts. There is a need to totally redo the UI. What is the best way to improve the UI? Will intrducing JSF components like PrimeFaces into the existing Struts code be a good idea? Or what are the options available?

It is hard to join Struts with JSF, since those are two different frameworks trying to do the same thing. So, in practice, you'll end-up rewriting your application. JSF pages and JSP (which are used by Struts) have different livecycle, JSF Beans are working in a different way then Struts Actions.
The point is to make use of that what you already have and make your JSP look better. I would choose good JavaScript UI library and rewrite JSP pages using it. ExtJS is a very good, if you want complete solution. If you want to create custom solution looke at jQuery, Backbone and Mustache templating engine.

Related

MVC with Java EE 6/7 JPA, JTA, EJB3, CDI

I like REST, JPA, JTA, EJB3, CDI & Co. And I like MVC web frameworks, but interesting ones like Play! are not Java EE.
So, just for fun, would it make sense at all to think about something like:
A servlet that accepts REST style URLs and dispatches to managed controllers that can inject EJBs and so on through CDI
The controllers forward/redirect to simple views that act as templates and can use responsive frameworks like Bootstrap
Or does Java EE imply JSF and really nothing else?
I had a look into this topic, wrote a simple JSF webapp and found some interesting resources.
This answer to a related stackoverflow question nicely explains how MVC maps to JSF: Understanding JSF as a MVC framework
Regarding REST style URLs, prettyfaces looks promising.
JSF has nice templating similar to Apache Tiles, and pages can be very simple using plain HTML and CSS with EL.
So, maybe no need to think about/look for something else than JSF and just use it?

Jsf component libraries with Spring MVC [duplicate]

This question already has answers here:
Using JSF as view technology of Spring MVC
(3 answers)
Closed 7 years ago.
Can I use jsf component libraries(primefaces) with spring mvc .I have problem with client side development so i want a simple way of creating user interfaces .And I dont like jsf life cycle .I need a way of using component libraries.
JSF and Spring MVC have completely different ideologies. The one is a component based MVC framework and the other is a request based MVC framework. Mixing this makes no sense. You normally choose the one or the other. A component based MVC framework has the advantage that it minimizes the HTML/CSS/JS boilerplate code and the server side request processing, but this brings the disadvantage back that you don't have fine grained control over the generated HTML/CSS/JS and the server side request processing. For that you'd need a request based MVC framework. But this has in turn the disadvantage that you need to write all that HTML/CSS/JS boilerplate and server side request processing yourself.
If you want to stick to Spring MVC and want a rich UI, I suggest to look at a JavaScript based UI library, such as jQuery UI.
See also:
What is the need of JSF, when UI can be achieved from CSS, HTML, JavaScript, jQuery?

JSF Adoption and Popularity

Just a general question, open for discussion...
I'm very much liking JSF so far, I'm new to it, but I prefer it to Struts. From a professionals standpoint, do you see a strong future for JSF ? Is it worth an investment as a young programmer to learn JSF 2.0 over Struts or another similar framework ? Should I stick to regular JSP ? Is Ajax really simpler through JQuery than JSF ?
I like new technologies and I like what I see so far from JSF but I want to be practical as well, and a lot Google searches turn up some bluntly critical comments about JSF 2.0.
Thoughts ?
Comparing JSF with Struts is like comparing apples with oranges. Struts is a request/action based MVC framework while JSF is a component based MVC framework. Struts is also aged. In the IT you're supposed to keep moving. Generally, a component based MVC framework is seen as a further evolution of a request/action based MVC framework.
JSF is currently already used very widely. It has indeed received a lot of critism before. You can read about most of them in the question What are the main disadvantages of JSF 2.0? The strength of JSF is mainly being a Java EE maintained standard and the availability of relatively a lot of 3rd party component libraries (PrimeFaces, RichFaces, IceFaces, OpenFaces, Tomahawk, etc). With JSF, it's very easy to develop CRUD applications and web forms with nice look'n'feel quickly.
However when it goes into the complex, JSF may cause some unforeseen surprises. Although the JSF specification and reference implementation (Mojarra) is pretty mature since the latest 1.2 builds, you may encounter some very specific behavioral problems which goes against your intuition. Some are just "by design" and can only be understood when you understand in detail how JSF works under the covers which in turn often boils down to the stateless nature of the HTTP protocol. JSF abstracts it in essence "too much" away that you don't see it anymore. Some are just bugs in the 3rd party component libraries used, but that's thus not strictly JSF-implementation-specific. Bug/issue handling is however pretty good in most of the major component libraries -if you report the bugs timely.
As to ajaxical stuff, JSF 2.0 indeed provides very little manual control over manually firing ajaxical requests and controlling the view tree in both server and client side. Simply because it's a component based MVC framework which keeps the tree state at the both sides. You've got to take the both sides into account when taking the ajaxical works in your own hands. If you really need more freedom in ajax/request based actions, then a component based MVC framework is simply the wrong choice. You should pick a request/action based MVC framework instead like Spring MVC, Struts or Stripes, along with a JS library like jQuery. You however have to write lot of HTML/CSS/JS boilerplate yourself instead.

jsf and page fragment caching

Does jsf 2.0 + facelets supports page fragment caching, something similar to aps page framgent caching
(example this tutorial http://quickstarts.asp.net/QuickStartv20/aspnet/doc/caching/fragment.aspx)
Regards
The answer on your question actually depends on the view technology in question. JSF is a component based MVC framework, not a view technology. JSF usually runs on either JSP or Facelets as view technology.
Both view technologies however doesn't provide an OutputCache like facility out of the box. You would need to create a custom tag/component for this. JBoss Seam has a similar component in the toolbox, the <s:cache>.

What will be better view with JSF technology

I am using Struts Tiles with JSF to have one header, menu and footer across application. Is there any other like struts to have one header, menu and footer. Is this feature available in faceslets and what viewing technology would be better for easy development.
For JSF you've only choice of two view technologies. The good old JSP and the improved and XHTML based Facelets. Facelets is much more suited to JSF than JSP. It is a view technology and template framework in one. It provides great templating capabilities and since JSF 2.0 also composite components, while JSP basically only offers the <jsp:include> for templating, so that you're forced to create custom components with raw Java code (which is a bit opaque and a lot of tedious work in JSF) when you want to replace a repeated group of components by a single component. If you can, I recommend to drop JSP and Tiles altogether and go for Facelets when you want to develop with JSF. If you're going for JSF 2.0 as well, it would already be a major step ahead as opposed to JSF 1.x.
Facelets is the first choice for JSF. Your task can be easily solved with Facelets.

Resources