JSF Promotes a Semantic Web

Years ago I read a book called "Designing With Web Standards" by Jeffery Zeldman. One of the things it got me excited about was a semantic web, where the HTML in web pages describe the data or content, not the layout. The layout is completely removed from HTML, and done entirely with CSS. CSS Zen Garden is a great example of how a single HTML file can be rendered hundreds of completely different ways using CSS.

I think this is every web programmer's vision of perfection, but unfortunately it doesn't happen a lot. Tight schedules, lack of time to fiddle with CSS, differences between how browsers handle CSS, etc.

When I first started to work in JSF using JPS files, I was in for some culture shock. I was used to hand coding HTML, and using special tags for iterating through data in Struts. In some ways I felt like I lost control of my web pages and had to shoe horn my visual designs into the constraints of JSF. I've seen a lot of negative comments about this part of JSF from people.

It wasn't until I read Gavin King's Designers vs. Developers, Declaration vs. Procedure blog entry that I realized I haven't really learned to harness the power of JSF, and why JSF is the way it is. I haven't taken the time to learn how to use the various types of layout panels in JSF because I thought I should be in control of that using div tags etc. I didn't like the dataTable component because it output HTML tags in addition to the data I want to iterate though.

If I would have looked deeper at the attributes of these components I would have seen that there is much more to them. Gavin does a good job using the dataTable component as an example of how it actually simplifies your JSP and makes it declarative. You describe which collection of data you want to iterate through, the CSS style classes to use for things like odd/even rows, header and footer information, etc. I know this doesn't sound very convincing, but you should read Gavin's blog entry for a better explanation. I want to learn more about layout panels now. I wonder how they could simplify my life (balance my portfolio? :), and if they are actually flexible enough to describe the kinds of layouts I am given from web designers to work with.

That reminds me, Gavin says that we should create a semantic HTML document that has no layout, and let designers do the layout with CSS. In my work, the layout is handed to me from a designer. They do their work first. Am I supposed to then spend hours converting their HTML and CSS into JSF tags, generate the output and ask the designer to create CSS that works with the new file? This doesn't seem right.

An other comment I have is that in my experience, component sets brutally mess up my HTML output. I get a headache trying to read the raw output of my JSF web apps, and have given up on the idea of having beautiful HTML. Our PHP web guys think less of Java web development because they think I have less control over my HTML pages and it looks like they were generated by Frontpage 97. They also don't like that JSF seems to strip out all of my line breaks and white space, and that I have to redeploy (while losing my session data) every time I want to tweak a page or backing bean. I can understand their perspective. These are things that I have learned to live with.

I have read about facelets but not used them yet. I was wildly excited about Facelets when I first read about it, but haven't had a new project to test it out with. JSF 2.0 will be using something based on Facelets + JSFTemplating instead of JSP. I'm really looking forward to using JSF 2.0, and good IDE support like this Dreamweaver plugin. Anyway... enough late night rambling.

Comments (3)

Comments:

I am sorry, but, who the hell does semantic markup relate to the sematic web? JSF has no built-in way of semantically annotating your website to build a reference to some ontology somewhere.

Just because the view logic is more meaningful does not mean that the web page output that is produced has any semantics attached that can be read/understood by machines.

Posted by Sakuraba on October 30, 2007 at 03:26 AM EDT #

Thanks for the comment. I've always thought that the semantic web is where content is much more machine readable, and writable. Feeds such as RSS/Atom, comments, RDF, complete separation of layout from XHTML out into CSS, etc. If you strictly use JSF's built in tags for layouts and tables etc. then it sort of forces you to not focus on HTML, instead doing layouts entirely in CSS. Sure you can do that anyway, but a lot of people don't. Maybe I have the wrong idea of symantic web and am confused with part of "Web 2.0"?

Posted by Ryan de Laplante on October 30, 2007 at 08:51 AM EDT #

The semantic web is not just about separation of content and layout - that is severely oversimplifying. It is more about publishing data in a way that is globally meaningful. For example if multiple data sources publish price lists which define the price elements as conforming to some standard (i believe this is what ontologies are for) then that data can be manipulated in a meaningful way (compared, analysed, aggregated, etc). Otherwise, the only thing you can do with it is make it look pretty within the local context -- the computer can read it but does not 'understand' what it means.

Posted by james on November 06, 2007 at 01:04 PM EST #

Post a Comment:
Comments are closed for this entry.