编程语言
首页 > 编程语言> > Java-JSF 2.0 Facelets模板继承

Java-JSF 2.0 Facelets模板继承

作者:互联网

这是JSF 2.0 Facelets nested templates inheritance的扩展重新发布,已被宽松要求并正式答复.

这是我的easy_to_earn问题:

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,它将扩展base_template.xhml,但main_content由< 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,jsf-2,java
来源: https://codeday.me/bug/20191208/2092095.html