Наследование шаблонов JSF 2.0 Facelets - PullRequest
3 голосов
/ 13 апреля 2011

Это расширенный репост Наследование вложенных шаблонов Facelets JSF 2.0 , на который был свободно задан и формально дан ответ.

Вот мой простой вопрос:

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>

Как мне это сделать?

1 Ответ

3 голосов
/ 13 апреля 2011

Создайте шаблон 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>
Добро пожаловать на сайт PullRequest, где вы можете задавать вопросы и получать ответы от других членов сообщества.
...