Pregunta

Estoy vinculado a crear mi propio mecanismo de plantilla para un sitio. He hecho 2 etiquetas personalizadas llamadas "TemplateInsert" y "Templatefor", una que las usaría así:

<prefix:insert templateFile="someFile>
    <prefix:for name="body">
        some content here
    </prefix:for>

    other prefix:for tags...

</prefix:insert>

Esto funciona perfectamente a menos que haya etiquetas JSF dentro de su "contenido". El servidor no parece analizarlos. alguien sabe como puedo arreglar esto?

¡salud!

¿Fue útil?

Solución

Esa es una de las razones por las cuales JSP ha sido sucedido por facelets según JSF 2.0 / Java EE 6. JSP ofrece muy pocas capacidades de plantilla. Sin embargo, puede usar FACELETS 1.x en JSF 1.x si lo instala por separado según su abarbook.

FACELETS ofrece exactamente su requisito funcional ya fuera de la caja. Un ejemplo:

template.xhtml

<!DOCTYPE html>
<html lang="en"
    xmlns="http://www.w3.org/1999/xhtml"
    xmlns:f="http://java.sun.com/jsf/core"
    xmlns:h="http://java.sun.com/jsf/html"
    xmlns:ui="http://java.sun.com/jsf/facelets"
>
    <head>
        <title><ui:insert name="title" /></title>
    </head>
    <body>
        <ui:insert name="body" />
    </body>  
</html>

page.xhtml

<ui:composition template="template.xhtml"
    xmlns:f="http://java.sun.com/jsf/core"
    xmlns:h="http://java.sun.com/jsf/html"
    xmlns:ui="http://java.sun.com/jsf/facelets"
>
    <ui:define name="title">Page title</ui:define>
    <ui:define name="body">
        <h:outputText value="JSF tags just work here." />
    </ui:define>
</ui:composition>

Diría que elija facelets como tecnología JSF View en lugar de reinventar una basada en JSP.

Licenciado bajo: CC-BY-SA con atribución
No afiliado a StackOverflow
scroll top