XML作为结构+ JSF作为表示:这是一个好主意吗? [英] XML as structure + JSF as representation: is it a nice idea?

查看:49
本文介绍了XML作为结构+ JSF作为表示:这是一个好主意吗?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我还没有见过XML和JSF一起工作.我的意思是用XML定义结构和字典,并用JSF表示.很高兴听到您对此想法的意见.

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.

考虑创建一种project-info.xml.它可能包含以下内容:

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>

使用此文件,可以很容易地将网站的结构及其jsf组件表示形式分开.

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

使用XML支持国际化也很容易.

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?

推荐答案

只需使用 Facelets

Facelets 是JSF的一个库,它引入了模板化的概念.那正是您在这里所做的.请注意,JSF 2.0本身包含该库.

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.

关于国际化,Java和JSF已经为此提供了一些功能(我正在考虑messageBundles

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

这篇关于XML作为结构+ JSF作为表示:这是一个好主意吗?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆