JSF Facelet Templating

Diskutiere Facelet Templating im Web Tier Forum; Ich versuche mich gerade an Templates und habe probeweise ein simples Template erstellt und versuche es in der index.xhtml zu nutzen. Dabei...

  1. Manuba
    Manuba Neues Mitglied
    Ich versuche mich gerade an Templates und habe probeweise ein simples Template erstellt und versuche es in der index.xhtml zu nutzen. Dabei bekomme ich beim Laden der Seite Fehler, die ich nicht zuordnen kann.
    Als Pfad für das Template habe ich sowohl "WEB-INF/templates/master.xhtml" als auch "/WEB-INF/templates/master.xhtml" versucht.
    Das Template lieg in WEB-INF/templates/master.xhtml:
    Code (Text):
    <?xml version='1.0' encoding='UTF-8' ?>
    <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
    <html xmlns="http://www.w3.org/1999/xhtml"
          xmlns:h="http://xmlns.jcp.org/jsf/html"
          xmlns:ui="http://java.sun.com/jsf/facelets">
        <h:head>
            <title><ui:insert name="title">Project Documents Tutorial</ui:insert></title>
            <h:outputStylesheet library="css" name="" />
        </h:head>
        <h:body>
            <div id="wrapper">
                <div id="top">
                    <ui:insert name="top">Standard Top</ui:insert>
                </div>
               
                <div id="content">
                    <ui:insert name="content">Standard Content</ui:insert>
                </div>
               
                <div id="footer">
                    <ui:insert name="footer">Standard Bottom</ui:insert>
                </div>
            </div>
        </h:body>
    </html>
     
    die index.xhtml liegt im root Verzeichnis für Web Pages:
    Code (Text):
    <?xml version='1.0' encoding='UTF-8' ?>
    <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
    <html xmlns="http://www.w3.org/1999/xhtml"
          xmlns:h="http://xmlns.jcp.org/jsf/html"
          xmlns:ui="http://java.sun.com/jsf/facelets">
        <h:head>
            <title>Persistence Test</title>
        </h:head>
        ...
        <h:body>
            <ui:composition template="WEB-INF/templates/master.xhtml">
                <ui:define name="content">
                Custom Content
                </ui:define>
            </ui:composition>
        </h:body>
    </html>
     
    Die Fehlermeldungen:
    Code (Text):
    Warnung:   JSF1091: Für Datei  konnte kein Mime-Typ gefunden werden.  Fügen Sie eine Mime-Typ-Zuordnung zur web.xml der Anwendung hinzu, um dies aufzulösen.
    Schwerwiegend:   Error Rendering View[/index.xhtml]
    java.lang.StringIndexOutOfBoundsException: String index out of range: 0
        at java.lang.String.charAt(String.java:658)
        at com.sun.faces.application.resource.ResourceManager.trimLeadingSlash(ResourceManager.java:369)
        at com.sun.faces.application.resource.ResourceManager.getResourceInfo(ResourceManager.java:314)
        at com.sun.faces.application.resource.ResourceManager.doLookup(ResourceManager.java:285)
        at com.sun.faces.application.resource.ResourceManager.findResource(ResourceManager.java:214)
        at com.sun.faces.application.resource.ResourceManager.findResource(ResourceManager.java:179)
        at com.sun.faces.application.resource.ResourceHandlerImpl.createResource(ResourceHandlerImpl.java:201)
        at com.sun.faces.application.resource.ResourceHandlerImpl.createResource(ResourceHandlerImpl.java:181)
        at javax.faces.application.ResourceHandlerWrapper.createResource(ResourceHandlerWrapper.java:112)
        at org.primefaces.application.PrimeResourceHandler.createResource(PrimeResourceHandler.java:57)
        at com.sun.faces.renderkit.html_basic.StylesheetRenderer.encodeEnd(StylesheetRenderer.java:100)
        at javax.faces.component.UIComponentBase.encodeEnd(UIComponentBase.java:920)
        at javax.faces.component.UIComponent.encodeAll(UIComponent.java:1863)
        at org.primefaces.renderkit.HeadRenderer.encodeBegin(HeadRenderer.java:84)
        at javax.faces.component.UIComponentBase.encodeBegin(UIComponentBase.java:865)
        at javax.faces.component.UIComponent.encodeAll(UIComponent.java:1854)
        at javax.faces.component.UIComponent.encodeAll(UIComponent.java:1859)
        at com.sun.faces.application.view.FaceletViewHandlingStrategy.renderView(FaceletViewHandlingStrategy.java:458)
        at com.sun.faces.application.view.MultiViewHandler.renderView(MultiViewHandler.java:134)
        at javax.faces.application.ViewHandlerWrapper.renderView(ViewHandlerWrapper.java:337)
        at com.sun.faces.lifecycle.RenderResponsePhase.execute(RenderResponsePhase.java:120)
        at com.sun.faces.lifecycle.Phase.doPhase(Phase.java:101)
        at com.sun.faces.lifecycle.LifecycleImpl.render(LifecycleImpl.java:219)
        at javax.faces.webapp.FacesServlet.service(FacesServlet.java:659)
        at org.apache.catalina.core.StandardWrapper.service(StandardWrapper.java:1682)
        at org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:318)
        at org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:160)
        at org.apache.catalina.core.StandardPipeline.doInvoke(StandardPipeline.java:734)
        at org.apache.catalina.core.StandardPipeline.invoke(StandardPipeline.java:673)
        at com.sun.enterprise.web.WebPipeline.invoke(WebPipeline.java:99)
        at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:174)
        at org.apache.catalina.connector.CoyoteAdapter.doService(CoyoteAdapter.java:416)
        at org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:283)
        at com.sun.enterprise.v3.services.impl.ContainerMapper$HttpHandlerCallable.call(ContainerMapper.java:459)
        at com.sun.enterprise.v3.services.impl.ContainerMapper.service(ContainerMapper.java:167)
        at org.glassfish.grizzly.http.server.HttpHandler.runService(HttpHandler.java:206)
        at org.glassfish.grizzly.http.server.HttpHandler.doHandle(HttpHandler.java:180)
        at org.glassfish.grizzly.http.server.HttpServerFilter.handleRead(HttpServerFilter.java:235)
        at org.glassfish.grizzly.filterchain.ExecutorResolver$9.execute(ExecutorResolver.java:119)
        at org.glassfish.grizzly.filterchain.DefaultFilterChain.executeFilter(DefaultFilterChain.java:283)
        at org.glassfish.grizzly.filterchain.DefaultFilterChain.executeChainPart(DefaultFilterChain.java:200)
        at org.glassfish.grizzly.filterchain.DefaultFilterChain.execute(DefaultFilterChain.java:132)
        at org.glassfish.grizzly.filterchain.DefaultFilterChain.process(DefaultFilterChain.java:111)
        at org.glassfish.grizzly.ProcessorExecutor.execute(ProcessorExecutor.java:77)
        at org.glassfish.grizzly.nio.transport.TCPNIOTransport.fireIOEvent(TCPNIOTransport.java:536)
        at org.glassfish.grizzly.strategies.AbstractIOStrategy.fireIOEvent(AbstractIOStrategy.java:112)
        at org.glassfish.grizzly.strategies.WorkerThreadIOStrategy.run0(WorkerThreadIOStrategy.java:117)
        at org.glassfish.grizzly.strategies.WorkerThreadIOStrategy.access$100(WorkerThreadIOStrategy.java:56)
        at org.glassfish.grizzly.strategies.WorkerThreadIOStrategy$WorkerThreadRunnable.run(WorkerThreadIOStrategy.java:137)
        at org.glassfish.grizzly.threadpool.AbstractThreadPool$Worker.doWork(AbstractThreadPool.java:591)
        at org.glassfish.grizzly.threadpool.AbstractThreadPool$Worker.run(AbstractThreadPool.java:571)
        at java.lang.Thread.run(Thread.java:745)

    FATAL:   JSF1073: java.lang.StringIndexOutOfBoundsException erfasst während Verarbeitung von RENDER_RESPONSE 6 : UIComponent-ClientId=, Message=String index out of range: 0
    FATAL:   String index out of range: 0
    java.lang.StringIndexOutOfBoundsException: String index out of range: 0
        at java.lang.String.charAt(String.java:658)
        at com.sun.faces.application.resource.ResourceManager.trimLeadingSlash(ResourceManager.java:369)
        at com.sun.faces.application.resource.ResourceManager.getResourceInfo(ResourceManager.java:314)
        at com.sun.faces.application.resource.ResourceManager.doLookup(ResourceManager.java:285)
        at com.sun.faces.application.resource.ResourceManager.findResource(ResourceManager.java:214)
        at com.sun.faces.application.resource.ResourceManager.findResource(ResourceManager.java:179)
        at com.sun.faces.application.resource.ResourceHandlerImpl.createResource(ResourceHandlerImpl.java:201)
        at com.sun.faces.application.resource.ResourceHandlerImpl.createResource(ResourceHandlerImpl.java:181)
        at javax.faces.application.ResourceHandlerWrapper.createResource(ResourceHandlerWrapper.java:112)
        at org.primefaces.application.PrimeResourceHandler.createResource(PrimeResourceHandler.java:57)
        at com.sun.faces.renderkit.html_basic.StylesheetRenderer.encodeEnd(StylesheetRenderer.java:100)
        at javax.faces.component.UIComponentBase.encodeEnd(UIComponentBase.java:920)
        at javax.faces.component.UIComponent.encodeAll(UIComponent.java:1863)
        at org.primefaces.renderkit.HeadRenderer.encodeBegin(HeadRenderer.java:84)
        at javax.faces.component.UIComponentBase.encodeBegin(UIComponentBase.java:865)
        at javax.faces.component.UIComponent.encodeAll(UIComponent.java:1854)
        at javax.faces.component.UIComponent.encodeAll(UIComponent.java:1859)
        at com.sun.faces.application.view.FaceletViewHandlingStrategy.renderView(FaceletViewHandlingStrategy.java:458)
        at com.sun.faces.application.view.MultiViewHandler.renderView(MultiViewHandler.java:134)
        at javax.faces.application.ViewHandlerWrapper.renderView(ViewHandlerWrapper.java:337)
        at com.sun.faces.lifecycle.RenderResponsePhase.execute(RenderResponsePhase.java:120)
        at com.sun.faces.lifecycle.Phase.doPhase(Phase.java:101)
        at com.sun.faces.lifecycle.LifecycleImpl.render(LifecycleImpl.java:219)
        at javax.faces.webapp.FacesServlet.service(FacesServlet.java:659)
        at org.apache.catalina.core.StandardWrapper.service(StandardWrapper.java:1682)
        at org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:318)
        at org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:160)
        at org.apache.catalina.core.StandardPipeline.doInvoke(StandardPipeline.java:734)
        at org.apache.catalina.core.StandardPipeline.invoke(StandardPipeline.java:673)
        at com.sun.enterprise.web.WebPipeline.invoke(WebPipeline.java:99)
        at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:174)
        at org.apache.catalina.connector.CoyoteAdapter.doService(CoyoteAdapter.java:416)
        at org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:283)
        at com.sun.enterprise.v3.services.impl.ContainerMapper$HttpHandlerCallable.call(ContainerMapper.java:459)
        at com.sun.enterprise.v3.services.impl.ContainerMapper.service(ContainerMapper.java:167)
        at org.glassfish.grizzly.http.server.HttpHandler.runService(HttpHandler.java:206)
        at org.glassfish.grizzly.http.server.HttpHandler.doHandle(HttpHandler.java:180)
        at org.glassfish.grizzly.http.server.HttpServerFilter.handleRead(HttpServerFilter.java:235)
        at org.glassfish.grizzly.filterchain.ExecutorResolver$9.execute(ExecutorResolver.java:119)
        at org.glassfish.grizzly.filterchain.DefaultFilterChain.executeFilter(DefaultFilterChain.java:283)
        at org.glassfish.grizzly.filterchain.DefaultFilterChain.executeChainPart(DefaultFilterChain.java:200)
        at org.glassfish.grizzly.filterchain.DefaultFilterChain.execute(DefaultFilterChain.java:132)
        at org.glassfish.grizzly.filterchain.DefaultFilterChain.process(DefaultFilterChain.java:111)
        at org.glassfish.grizzly.ProcessorExecutor.execute(ProcessorExecutor.java:77)
        at org.glassfish.grizzly.nio.transport.TCPNIOTransport.fireIOEvent(TCPNIOTransport.java:536)
        at org.glassfish.grizzly.strategies.AbstractIOStrategy.fireIOEvent(AbstractIOStrategy.java:112)
        at org.glassfish.grizzly.strategies.WorkerThreadIOStrategy.run0(WorkerThreadIOStrategy.java:117)
        at org.glassfish.grizzly.strategies.WorkerThreadIOStrategy.access$100(WorkerThreadIOStrategy.java:56)
        at org.glassfish.grizzly.strategies.WorkerThreadIOStrategy$WorkerThreadRunnable.run(WorkerThreadIOStrategy.java:137)
        at org.glassfish.grizzly.threadpool.AbstractThreadPool$Worker.doWork(AbstractThreadPool.java:591)
        at org.glassfish.grizzly.threadpool.AbstractThreadPool$Worker.run(AbstractThreadPool.java:571)
        at java.lang.Thread.run(Thread.java:745)
     
     
  2. Vielleicht hilft dir dieser Kurs hier weiter --> (hier klicken)
  3. redJava99
    redJava99 Mitglied
    Du brauchst keinen <h:body> oder dergleichen wenn das bereits im template vorhanden ist.

    index.xhtml:
    Code (Text):

    <?xml version='1.0' encoding='UTF-8' ?>
    <ui:composition
          template="WEB-INF/templates/master.xhtml"
          xmlns= [...]
          xmlns:h=[...]
          xmlns:ui= [...]>
       <ui:define name="title">Persistence Test</ui:define>
       <ui:define name="content">Custom Content</ui:define>
    </ui:composition>
     
  4. Manuba
    Manuba Neues Mitglied
    Aber was um den composition Tag steht wird doch nicht gerendert und hat dadurch auch keine Auswirkung, oder?
    Ich habe das so wie vorgeschlagen versucht, erhalte aber immernoch die Fehlermeldung.
     
  5. Manuba
    Manuba Neues Mitglied
    Die Fehlermeldungen liegen daran, dass ich in der master.xhtml keine css Datei angegeben habe.
     
Die Seite wird geladen...

Facelet Templating - Ähnliche Themen

Konvertierung JSF -> facelets (templating)
Konvertierung JSF -> facelets (templating) im Forum Allgemeines EE
Facelets integriert in JSF ?
Facelets integriert in JSF ? im Forum Web Tier
Facelets Include Rendered Problem
Facelets Include Rendered Problem im Forum Netzwerkprogrammierung
Tobago und Facelets
Tobago und Facelets im Forum Web Tier
Facelets javascript compiler problem
Facelets javascript compiler problem im Forum Web Tier
Thema: Facelet Templating

Besucher kamen mit folgenden Begriffen auf unsere Seite:

  1. Mime-Typ-Zuordnung web.xml