File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
http://aspose.com/file-tools
The moose likes JSF and the fly likes Could we place the JSP content in xhtml to get the desired JSF view??? Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Android Security Essentials Live Lessons this week in the Android forum!
JavaRanch » Java Forums » Java » JSF
Bookmark "Could we place the JSP content in xhtml to get the desired JSF view???" Watch "Could we place the JSP content in xhtml to get the desired JSF view???" New topic
Author

Could we place the JSP content in xhtml to get the desired JSF view???

Sriram Sharma
Ranch Hand

Joined: Apr 12, 2006
Posts: 97
Hi,

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?
Please help!

Regards,
Sriram
Tim Holloway
Saloon Keeper

Joined: Jun 25, 2001
Posts: 15960
    
  19

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.


Customer surveys are for companies who didn't pay proper attention to begin with.
Sriram Sharma
Ranch Hand

Joined: Apr 12, 2006
Posts: 97
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?

Regards,
Sriram
Tim Holloway
Saloon Keeper

Joined: Jun 25, 2001
Posts: 15960
    
  19

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.
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: Could we place the JSP content in xhtml to get the desired JSF view???
 
Similar Threads
XHTML file throws illegalstate exception
Error:The XML page cannot be displayed Cannot view XML input using style sheet
<h:commandLink> is not working in JSF 2.0
test.jsf works test.jsp doesn't
Content-type without JSP directives