5 Replies Latest reply on Feb 1, 2013 3:57 AM by bleathem

    RichFaces namespace(s)


      Hi all,


      There is currently two namespaces for RichFaces :


      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.


      • 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


      • 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.

        • 1. Re: RichFaces namespace(s)

          I agree with having a single namespace to rule them all. It will become easier to use and configure.

          • 2. Re: RichFaces namespace(s)

            I agree that for developer it's most convenient to use just one namespace,




            Disadvantage of one namespace:


            Each of the widget suites bears specific resources (richfaces-packed.js/css, bootstrap.js/css, jqueryui.js/css),

            in fact, combining widget suites can lead in bad performing pages.


            So from the architectonical point of view, people should use the components from same widget suites,

            combining suites only in corner cases.


            The separated namespaces can then play as natural mind-block when using several widget suites.




            How long?


            I completely agree, using short prefixes can also increase readability of the code.





            Distribution of components among several namespaces

            Another problem is distribution of components among namespaces,

            since rich namespace currently contains some components like rich:hotKey, rich:element, rich:component, etc.


            which are pretty handy in case of all widget components sets.

            • 3. Re: RichFaces namespace(s)

              Sandbox components will always have there own, seperate namespace.  Once a component "graduates" from the sandbox, it will land in a component set.  Right now we have only one component set, but I'm envisioning more as various sandbox components mature.


              So what we have to in fact figure out is how we want to package the components.  I then suggest one namespace per artifact.


              One proposal would be the following artifacts and namespaces:

              * non-visual components (a: )

              * current visual richfaces components (rich: )

              * new component set (r: ) or (rb: ) if we want to be specific for richfaces bootstrap components

              • 4. Re: RichFaces namespace(s)

                We have discussed current problems with namespaces:



                I have created issue in JBoss Tools project for support of automatic completion of namespaces:


                • 5. Re: RichFaces namespace(s)

                  For the sake of clarity, I'd like to summarize in this thread numerous conversations on this topic.


                  With RichFaces 5 we plan to collapse the "rich:" and "a4j:" namespaced into a single namespace.  In our examples and sample code we'll switch to the shorter "r:" prefix, but keep in mind the prefix is user-defined, and one can continue to use the longer prefix in one's own code samples.


                  The goal is to make the framework comopnents easier to consume, particularly for new users who don't understand the history behind the rich/a4j split.