RichFaces namespace(s)
paul.dijou May 30, 2012 6:37 AMHi all,
There is currently two namespaces for RichFaces :
- xmlns:rich="http://richfaces.org/rich"
- xmlns:a4j="http://richfaces.org/a4j"
Don't ask me why, I have no idea, probably a long and old story behind that. With the incomming of new components based on Bootstrap, a new namespace has been created for the moment, and I guess it will be the same with jQuery UI based components when they will be here (I really believe in it). And because of all that stuff, I want to ask two questions.
How many?
Yes, how many namespace should there be? There is two clear choices IMO : only one to rule them all or several, one for each big group of components (that would mean 3 or 4). Both solutions have pros and cons.
One
- only one namespace to include in your XHTML pages, stop bothering adding them one by one depending on the components you need
- only one prefix to remember and to write
- autocomplete over all components at once
Several
- autocomplete only over the components of the group you are currently using (for example, only the RichFaces Bootstrap components)
- same name for different components in different groups but having the same purpose (for example, there is already a RichFaces "autocomplete" but Bootstrap has also an "autocomplete" on its own way)
Since RichFaces doesn't have hundreds of components yet, I would go with only one namespace, it makes RichFaces lighter (only one namepsace to add in XHTML page, only one prefix to use for all components).
How long?
Yes, how long should be the prefix of each namespace? Right now, if you look at RichFaces showcase, you will find "rich" and "a4j", so 3 or 4 caracters. I agree that you can put the prefix you want in your XHTML page (you could have written xmlns:richfacesIsAwesome="http://richfaces.org/rich") but, in practice, people take the same prefix as in the reference showcase since it's easier to copy/paste when needed. So, are the current prefix good enough?
When I look at JSF spec prefix, they are 1 caracter long ("h" and "f"). The Facelet one is 2 caracters long ("ui"). Other JSF libraries are mostly 1 caracter long ("p", "o", ...) or, sometime, 2 caracters ("pe"). So I think RichFaces is a bit an outsider in this area and my opinion is that core prefix should be 1 caracter long ("rich" -> "r" and "a4j" -> "a") because it's easier to write and more compliant with what is done by others actors. For "extension" group, I would be fine with 2 caracters (like "rb" for RichFaces Bootstrap and "rj" for RichFaces jQuery). Of course, if there is only one namespace, "r" is the best choise.
Backward compatibility
One point to keep in mind is that going with only one namespace will break backward compatibility of course. Is it really problematic? Well, people are never very happy to do refactoring but this is a very light refactoring here. It's just a "find&replace" from "<a4j:" to "<rich:" (or "<r:") so I'm fine with it but I guess it might no please everybody.
Feel free to add any argument in favor of one or another solution, I will add them in this post.