JSF 2.0 Facelets模板继承 [英] JSF 2.0 Facelets template inheritance

查看:150
本文介绍了JSF 2.0 Facelets模板继承的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

这是 JSF 2.0 Facelets嵌套模板继承的扩展转贴,这是松散的问题并正式回答。

This is an extended repost of JSF 2.0 Facelets nested templates inheritance, which was loosely asked and formally answered.

这是我的easy_to_earn问题:

Here is my easy_to_earn question:

template_base .xhml

<html xmlns="http://www.w3.org/1999/xhtml"
            xmlns:h="http://java.sun.com/jsf/html"
            xmlns:ui="http://java.sun.com/jsf/facelets">
<h:head><!-- header stuff --></h:head>
<h:body>
    <!-- Lot of html here -->
    <div id="main">
        <ui:insert name="main_content"/>
    </div>
    <!-- Lot of html here -->
</h:body>
</html>

接下来,我想要另一个模板, form_wrapped.xhtml ,这将 extend base_template.xhml ,但 main_content 包裹在< h:form>

Next, I want another template, form_wrapped.xhtml, which would extend base_template.xhml but with main_content wrapped by <h:form>:

<div id="main">
    <h:form>
        <!-- "main_content" goes here -->
    </h:form>
</div>

页面本身:

<ui:composition template="/WEB-INF/templates/form_wrapped.xhtml">
    <ui:define name="main_content">
            <!-- this html is wrapped by form -->
    </ui:define>
</ui:composition>

我该怎么做?

推荐答案

像这样制作 form_wrapped 模板:

<ui:composition xmlns="http://www.w3.org/1999/xhtml"
    xmlns:h="http://java.sun.com/jsf/html"
    xmlns:ui="http://java.sun.com/jsf/facelets"
    template="/WEB-INF/templates/main_wrapped.xhtml">

    <ui:define name="main_content">
            <div id="main">
                <h:form>
                    <ui:insert name="form_content" />
                </h:form>
            </div>
    </ui:define>

</ui:composition>

这篇关于JSF 2.0 Facelets模板继承的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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