tags:

views:

36

answers:

1

Hi, I haven't met XML and JSF working together. I mean having structure and dictionaries defined in XML and representation in JSF. It will be nice to hear your opinion about this idea.

Consider creating a kind of project-info.xml. It could contain something like this:

<project-info>
    <project-name>My project</project-name>
    <menu-pages>
     <menu-page name="home" view-id="/home.xhtml" title="Home" />
     <menu-page name="compose-letter" view-id="/compose-letter.xhtml" title="Composing a letter" />
     <menu-page name="company" view-id="/company.xhtml" title="Our Company">
      <menu-pages>
       <menu-page name="colleagues" view-id="/colleagues.xhtml" title="Our Colleauges">
       <!-- etc. --> 
      </menu-pages>
     </menu-page>
     <!-- etc. -->
    </menu-pages>
</project-info>

Using this file it could be easy to separate the structure of the web-site and its jsf-components representation.

It is also easy to support internationalization using XML.

Do you think this concept is not so comfortable in some way? Or are there any other methods to achieve the same separation result?

+1  A: 

Simply use Facelets !

Facelets is a library for JSF that introduces the concept of templating. That's exactly what you are doing here. Note that JSF 2.0 includes natively this library.

Concerning the internationalization, Java and JSF already provide some functionalities for that (I am thinking about messageBundles <f:loadBundle/>).

romaintaz
Yes, I'm doing templating in some way. But XML offers higher level of abstraction comparing with JSF. To my mind, it is very convenient to define *structure* in XML. However, I suppose, my way of thinking comes from my XML-XSL background. I'd better adapt myself to JSF than JSF to me ). Thank you for your prompt about <f:loadBundle/>.
emanemos
Could you be more precise about this higher level of abstraction that you are talking about? Facelets uses XHTML, which is XML (ok, the XML used is JSF-related ;) ).
romaintaz