4 Replies Latest reply on May 26, 2007 12:52 AM by Dan Allen

    is xhtml a good choice for Facelets templates?

    Dan Allen Master

      There is a chance that this question is going to be perceived as heretical, but I feel that I either need to speak now or hold my peace.

      Is XHTML really a good choice for the file extension and doctype for Facelets templates?

      Consider my argument. When we use xhtml as a file extension and include the xhtml doctype, we are saying, "This file validates as XHTML." Well, with all those Facelets tags in there, it sure doesn't. If you use the "jsfc" attribute of Facelets to augment a file that really is XHTML, then maybe that small violation is not so bad. But when the root tag of the file is ui:composition, you are beginning to stray pretty far from the path.

      Let me make a suggestion. We can all agree that Facelets templates must be valid XML. JSPX is a valid XML syntax that we can use. But it is sort of verbose and again, we are mixing meanings. How about a new file extension, one that won't confuse the IDEs. How about (f)acelet (c)omposition (t)emplate (FCT)? But then again, should we tie ourselves to Facelets or have a "generic" page extension?

      I swear, I am not trying to stir the pot for no good reason. It just seems that calling files XHTML when they aren't isn't such a good idea.

        • 1. Re: is xhtml a good choice for Facelets templates?
          fhh Expert

           


          But when the root tag of the file is ui:composition, you are beginning to stray pretty far from the path.


          The X in XHTML is for eXtensible. You can add other namespace by declaring them in the root element of the file.

          Apart from that I find it hard to make a connection between the validity of the content of a file and the extension used.

          Regards

          Felix



          • 2. Re: is xhtml a good choice for Facelets templates?
            Gavin King Master

            .xhtml is just the default: you can use anything you like

            • 3. Re: is xhtml a good choice for Facelets templates?
              Jamie Cruise Newbie

              I guess that a lot of us are using facelets as building blocks in componentized user interfaces. In my current application, only the top level templates could rightly be called xhtml files i.e. they look something like:

              <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01//EN" "http://www.w3.org/TR/html4/strict.dtd">
              <html xmlns="http://www.w3.org/1999/xhtml"
               xmlns:ui="http://java.sun.com/jsf/facelets"
               xmlns:h="http://java.sun.com/jsf/html"
               xmlns:t="http://myfaces.apache.org/tomahawk"
               xmlns:f="http://java.sun.com/jsf/core"
               xmlns:s="http://jboss.com/products/seam/taglib"
               xmlns:a="https://ajax4jsf.dev.java.net/ajax">
              
              <head>
              <title><ui:insert name="pageTitle">
              ... stuff ...
              
              </xhtml>
              


              a lot of my other facelets look something like:

              <sl:gridPage xmlns:sl="http://mycompany.com/myapp" />
              


              which is not really xhtml, whatever way you spin it. But I'm a pragmatic sort of person and am not that bothered about changing file extensions for the sake of it.

              However, the "pondering facelets file extensions" thought process did lead me down another road which is sort of related. I got to wondering if I should actually move away from xml to specify facelets?

              In particular, my application has a very data driven, modular ui that has a lot of dynamic view building and depends heavily on the <c:> tags for the view tree building logic. In my xhtml files this is transparently interspersed with the uicomponent's themselves and a liberal dose of jsf render-time logic, which is bloody confusing to read and maintain.

              Apart from the top level templates there's not a lot of mixed content (which xml style markup handles gracefully).

              I am beginning to wonder if a groovy based dsl wouldn't be much more concise and expressive for building complex facelets composition component's.

              I want something that stays in the scripting domain, to avoid needing to redeploy during UI hacking.

              Has anybody done anything like this?

              Cheers
              J


              Oh, to stay on-topic with the original thread, I propose that these files should be known as Facelets User Composition Komponents, with an appropriate extension.

              • 4. Re: is xhtml a good choice for Facelets templates?
                Dan Allen Master

                 

                "gavin.king@jboss.com" wrote:
                .xhtml is just the default: you can use anything you like


                Well, yes. My point was more "should we" rather than "can we." I'll I am saying is that if we do use xhtml, and we are going to ask all the vendors to help us with tag completion and validation based on this extension (or a configurable extension), then they should actually validate to something. If the argument is that XHTML is meant for tags other than standard HTML, and as long as it is XML then scrap the DTD, then I guess we are on the right path.