/ / JSF 2.0 Dedičstvo šablón facelets - java, jsf, jsf-2

JSF 2.0 Facelets šablóna dedičnosti - java, jsf, jsf-2

Toto je rozšírená repost JSF 2.0 Facelets vnorené šablóny dedičstva, ktorá bola voľne položená a formálne zodpovedaná.

Tu je moja otázka typu 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>

Ďalej chcem inú šablónu, form_wrapped.xhtml, čo by predĺžiť base_template.xhml ale s main_content zabalené <h:form>:

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

A samotná stránka:

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

Ako to urobím?

odpovede:

2 pre odpoveď č. 1

Urob svoj form_wrapped šablóna takto:

<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>