What will be better view with JSF technology - jsf

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.

Related

Do I need to create a new taglib.xml file when migrating JSF 1.1 to JSF 2.0 while keeping JSP as view technology

Hi I have an application that needs to be migrated from jsf1.1 to jsf2.0. I have read the answers posted in Migrating from JSF 1.2 to JSF 2.0 by BalusC.
I have thought not to go ahead converting JSP to facelets.Retain the JSP2.x as the view technology.
I would request someone to clarify couple of my doubts.
As a part of migrating the custom components is it a must to create a new custom-taglib.xml file ? Can't I retain .tld files as it is.
Since JSF implementations like JSF 2.0 provides backward compatibility with older versions, Is it necessary to change the custom compoent code, for the deprecated methods and replace it with the appropriate methods from JSF 2.0? because we are not migrating it completely to facelets.
Do I need to create a new taglib.xml file when migrating JSF 1.1 to JSF 2.0 while keeping JSP as view technology?
No. The *.taglib.xml files are for Facelets what *.tld files are for JSP.

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

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.

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>.

Explain to me the different JSF component libraries relate

Even though i spend whole days developing a JSF application, i've never had any training on the matter and I have to admin I am a still confused how the whole JSF puzzle fits together. JSF just looks a bit thrown together to me.
jsf-api
jslt
facelets
myfaces
trinidad
tobago
jsp api
I'd be very grateful if anyone could give me a quick description of these components, which ones are standard, which ones can be left out, which ones can/need to be used together
JSP and JSTL
JSP has undergone many iterations, but this is the core Java EE dynamic page technology. This is a servicable API, but working with JSPs often means more manual management of code/resources.
JSTL is the JSP Standard Template Library. This is a set of standard JSP tags. Do not mix these tags with JSF tags; they belong to a different programming model.
JSF API
The JSF specification. This is the core of the JSF Model-View-Presenter framework. This specifies a simple set of core components and the core lifecycle artefacts. There are two widely known implementations: Mojarra (the open sourced Sun API) and Apache MyFaces. Part of Java EE 5 and above.
Facelets
A view technology designed for JSF. Use this instead of JSPs. You cannot use JSP tags in Facelets views. This is not standard in Java EE 5, but is standardized in JSF2 (and therefore the upcoming Java EE 6). The better templating provided by Facelets often means you can rely less on 3rd party libraries.
Facelets provides some tags that look like JSP JSTL tags, but don't share any code. These tags should generally be avoided too (see Facelets doc for advice).
Apache Trinidad and Tobago
These are JSF libraries that provide components and other facilities. Because the core set of controls is rather basic, it is common to use such libraries, especially if Facelets is not used. These are not part of the Java EE standard. Library compatibility varies. See also jsfmatrix.net.
jsf-api are the interfaces and classes in javax.faces
jstl is a standard set of tags (used primarily in JSP) - most of them are replaced with JSF-tags, btw
facelets is a presentation and templating framework (like jsp)
myfaces is an implementation of the JSF standard. The other possibility if JSF RI (reference implementation)
trinidad and tobago are component libraries - some goodies that aren't included in the default set of jsf components
jsp is the alternative to facelets (or vice versa), which is as well a presentation framework.
UEL - (you didn't ask, but it's important) - Unified Expression Language - the set of rules for your #{..} expressions

Resources