Bonjour,

je souhaite avoir une master page à la façon ASP.NET je me suis donc renseigner et j'ai opté pour les templates (facelets).

J'ai donc :

- template.jspx : mon template
- index.jspx : ma page client du template

template.jspx
Code : Sélectionner tout - Visualiser dans une fenêtre à part
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
 
<?xml version="1.0" encoding="UTF-8"?>
<!-- 
    Document   : template
    Created on : 14 déc. 2010, 15:16:08
    Author     : NameX
-->
<jsp:root xmlns:jsp="http://java.sun.com/JSP/Page" version="2.0"
          xmlns:ui="http://java.sun.com/jsf/facelets"
           xmlns:f="http://java.sun.com/jsf/core"
           xmlns:h="http://java.sun.com/jsf/html">
 
    <jsp:directive.page contentType="text/html" pageEncoding="UTF-8"/>
 
    <!-- any content can be specified here, e.g.: -->
    <jsp:element name="text">
        <jsp:attribute name="lang">EN</jsp:attribute>
        <jsp:body>
            <f:view>
              <div id="div_ban">
               <ui:insert name="banniere">
                    <h:graphicImage value="image/banniere.png" />
               </ui:insert>
              </div>
              <div>
                <ui:insert name="menu" />
              </div>
            <p>
             <ui:insert name="contenu" />
            </p>
         </f:view>
    </jsp:body>
    </jsp:element>
 
</jsp:root>
index.jspx
Code : Sélectionner tout - Visualiser dans une fenêtre à part
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
 
<?xml version="1.0" encoding="UTF-8"?>
<!-- 
    Document   : index
    Created on : 14 déc. 2010, 15:15:33
    Author     : NameX
-->
<jsp:root xmlns:jsp="http://java.sun.com/JSP/Page" version="2.0"
          xmlns:ui="http://java.sun.com/jsf/facelets"
           xmlns:f="http://java.sun.com/jsf/core"
           xmlns:h="http://java.sun.com/jsf/html">
 
    <jsp:directive.page contentType="text/html" pageEncoding="UTF-8"/>
 
    <!-- any content can be specified here, e.g.: -->
    <jsp:element name="text">
        <jsp:attribute name="lang">EN</jsp:attribute>
        <jsp:body>
            <f:view>
             <ui:composition template="template.jspx">
 
                <ui:define name="menu">
                    <h:outputText value="FAQ" />
                    <h:outputText value="Tutoriels" ></h:outputText>
                    <h:outputText value="Forums" ></h:outputText>
                </ui:define>
	<ui:define name="contenu">
  	<h:outputText value="Les FAQs Java" ></h:outputText>
</ui:define>
</ui:composition>
        </f:view>
        </jsp:body>
    </jsp:element>
 
</jsp:root>
Donc la je pense que c'est bon, je souhaite avoir m'a banniere par default et remplir menu et conteneur.

Mais je reçois l'erreur suivante :
Code : Sélectionner tout - Visualiser dans une fenêtre à part
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
 
HTTP Status 500 -
 
type Exception report
 
message
 
descriptionThe server encountered an internal error () that prevented it from fulfilling this request.
 
exception
 
org.apache.jasper.JasperException: java.lang.RuntimeException: Cannot find FacesContext
root cause
 
java.lang.RuntimeException: Cannot find FacesContext
note The full stack traces of the exception and its root causes are available in the Sun GlassFish Enterprise Server v2.1.1 logs.
 
Sun GlassFish Enterprise Server v2.1.1
J'ai donc fait des recherches sur internet et j'ai cru comprendre que cela viendrai de mon web.xml ou du facesconfig donc je vous donne les 2 :

web.xml
Code : Sélectionner tout - Visualiser dans une fenêtre à part
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
 
<?xml version="1.0" encoding="UTF-8"?>
<web-app version="2.5" xmlns="http://java.sun.com/xml/ns/javaee" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://java.sun.com/xml/ns/javaee http://java.sun.com/xml/ns/javaee/web-app_2_5.xsd">
    <context-param>
	<param-name>javax.faces.DEFAULT_SUFFIX</param-name>
	<param-value>.jspx</param-value>
  </context-param>
    <servlet>
        <servlet-name>Faces Servlet</servlet-name>
        <servlet-class>javax.faces.webapp.FacesServlet</servlet-class>
        <load-on-startup>1</load-on-startup>
    </servlet>
    <servlet-mapping>
        <servlet-name>Faces Servlet</servlet-name>
        <url-pattern>/faces/*</url-pattern>
    </servlet-mapping>
    <session-config>
        <session-timeout>
            30
        </session-timeout>
    </session-config>
    <welcome-file-list>
        <welcome-file>index.jspx</welcome-file>
        <welcome-file>faces/index.jspx</welcome-file>
    </welcome-file-list>
</web-app>
(Si je met pas le "<welcome-file>index.jspx</welcome-file>" tout court il ne trouve pas la ressource)

faceconfig
Code : Sélectionner tout - Visualiser dans une fenêtre à part
1
2
3
4
5
6
7
8
9
10
11
12
13
14
 
<?xml version='1.0' encoding='UTF-8'?>
 
<!-- =========== FULL CONFIGURATION FILE ================================== -->
 
<faces-config version="1.2" 
    xmlns="http://java.sun.com/xml/ns/javaee" 
    xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" 
    xsi:schemaLocation="http://java.sun.com/xml/ns/javaee http://java.sun.com/xml/ns/javaee/web-facesconfig_1_2.xsd">
 
<application>
    <view-handler>com.sun.facelets.FaceletViewHandler</view-handler>
 </application>
</faces-config>
Voilà donc j'espère que quelqu'un pourra me venir en aide. Merci