I have 2 JSF applications - Let me say A and B.
Application A uses JSP and Application B uses XHTML.
Now, I want Application B also get the same look and feel as Application A.
For this purpose, I have to recode the complete JSP page (of Application A) into XHTML (in Application B).
My question: Is there any better way, like reusing all the content of JSP in XHTML or something like that.
Could I replace the existing XHTML content with the JSP content with some minor modifications?
There are 2 types of "JSP" you might be referring to here.
One is the traditional form of JSP, that does not use JSF.
The other is the JSP form that served as a View Template in JSF version 1.
In JSF version 2, the second form of JSP is no longer supported. In JSF2, the View Template Language is xhtml format. Which means that regardless of what else you do, you should be coding xhtml for anything that your expect to keep working as JSF1 support dies. And since JSF2 has been the standard for several years now, JSF1 support is already not very widespread.
Traditional JSPs are still supported, as are traditional servlets, but they are not processed by the FacesServlet and therefore cannot use JSF tags or JSF-mode objects such as the FacesContext.
The best way to keep a set of websites consistent as far as appearance goes is to employ a standard set of CSS classes. That way, you can make xhtml, JSP and HTML output all look consistent. In the case where you have multiple apps all using the same CSS, it may actually be better to have a master webapp that's independent of the other webapps whose sole purpose is to contain CSS URLs. Since all it would contain is fixed content, it could even be a non-J2EE app, if your are using a frontend server such as Apache.
An IDE is no substitute for an Intelligent Developer.
Joined: Apr 12, 2006
Sounds good! Thanks for that quick reply.
As you have specified, my applications, both A and B have css files.
I have also found the content to be placed in the xhtml file.
I am going to use the same set of CSS files used by the application A in application B as well.
Now, the only question that I have is, would I be able to use tags like <table> <tr> <td> in my xhtml?
Would that be supported?
Yes, you can use raw HTML in an XHTML View Template.
I don't recommend doing it for things that JSF tags can do, especially tables, but there were certain HTML tags that JSF didn't used to have an equivalent form for (such as the HEAD and BODY tags). For tables, I recommend an actual dataTable when doing row/column data displays and panelGrid for fixed-content tabular layout. A 1x1 panelGrid is essentially the same thing as an HTML DIV.
Of course, there are also elitists who insisted that only barbarians use HTML tables anymore when you could do it all with DIVs and CSS, but that's their problem, not ours.
The reason I discourage mixing HTML and VDL (View Definition Language, also known as View Template Language, a/k/a "xhtml") is that JSF was designed to be an abstract MVC system where you could completely change media types by simply selecting a different view renderer plugin. But if you do that for non-HTML media, such as PDF, the HTML tags wouldn't be processed by JSF and you'd end up with a PDF document with visible HTML tags littering the pages.