Skip to Main Content

Java EE (Java Enterprise Edition) General Discussion

Announcement

For appeals, questions and feedback about Oracle Forums, please email oracle-forums-moderators_us@oracle.com. Technical questions should be asked in the appropriate category. Thank you!

Facelets template (J2EE6 Netbeans 6.8 glassfish v3) ui:composition issue

843844Jan 16 2010 — edited Aug 11 2010
Hello every body,

First please excuse my bad english maybe...
I'm ready to start a new project with Java EE 6 using netbeans 6.8 and glassfish v3.
For the Web Tiers, I want to use facelets and JSf 2, but I encounter an issue when I want to create and use a facelets template

Here are the steps to reproduce my problem (very simple..). Theses steps must be reproduced using Netbeans 6.8 :

A. Project creation

1. File > New Project > Java EE > Enterprise Application
2. Project Name : (no matter) : SampleEE (do not check Use dedicated folder....)
3. Server : Glassfish v3 Domain (provided with netbeans) / JavaEE Version : java EE 6.
4. Check Create EJB Module and Create Web Application Module (and do not change default names)
5. Do not check Create Application Client Module. Then Click Finish.

B. Add JSF 2 Framework to the Web project

1. In the project tab, right-clic the web project and clic Properties
2. Select Frameworks and clic the "add" button and Add Java Server Faces (do not change the default configuration. Make sure to use Facelets (not jsp) as prefered page language in the configuration tab)
3. Clic OK to confirm and close the window

C. Create a facelet template

1. In the web project node, right clic and select New > Other > JavaServer Faces > Facelets Template
2. File Name : template (and do not change anything else : use CSS and use the first and easiest template. Do Not specify folder). Click Finish

We get this template at the root of "Web Pages" (css is automatically generated in "resources/css"
<?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:ui="http://java.sun.com/jsf/facelets"
      xmlns:h="http://java.sun.com/jsf/html">
    
    <h:head>
        <meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />
        <link href="./resources/css/default.css" rel="stylesheet" type="text/css" />
        <link href="./resources/css/cssLayout.css" rel="stylesheet" type="text/css" />
        <title>Facelets Template</title>
    </h:head>
    
    <h:body>
        
        <div id="top" class="top">
            <ui:insert name="top">Top</ui:insert>
        </div>
        
        <div id="content" class="center_content">
            <ui:insert name="content">Content</ui:insert>
        </div>
        
    </h:body>
    
</html>
D. Create a template client

1. On the project node, right-clic and select New > Other > JavaServer Faces > Facelets Template Client
2. File Name : client (do not specify any folder)
3. Clic "browse" button to select a template, and select the template nammed "template"
4. Check <ui:composition>" for "generated root tag" value (note the problem occurs even if we check "html")

We get this file :

{code}<?xml version='1.0' encoding='UTF-8' ?>
<!DOCTYPE composition PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<ui:composition xmlns:ui="http://java.sun.com/jsf/facelets"
template="./template.xhtml">

<ui:define name="top">
top
</ui:define>

<ui:define name="content">
content
</ui:define>

</ui:composition>
{code}

E. Execute

Now just clean and build and Run the project.
1. Right Clic the project node and select Clean And Build
2. Right clic the project node and select Run
3. Wait for the web browser to open and go to the template url : http://localhost:8080/SampleEE-war/template.xhtml (we can see the template displays correctly, with the good CSS style automatically generated)
4. Now go to the client URL (http://localhost:8080/SampleEE-war/client.xhtml

There is a problem : tags are not interpreted and client.xhtml just returns a standard xml and no page is displayed. (if you check 'html' instead of <ui:composition> in the steps before, you can see the page, but it's not the correct page, display the page source and you will see all the facelets tags "<ui:composition..."> <ui:define> and so on...

I don't know what to do to solve this.
Please help me, i've been searching for so long hours now...

Note that the project as no faces-config.xml, since it's now optional... I would prefer not to use it.

Thank you in advance for your help.

Edited by: Hitsugaya-kun on Jan 16, 2010 5:14 AM
Comments
Locked Post
New comments cannot be posted to this locked post.
Post Details
Locked on Sep 8 2010
Added on Jan 16 2010
3 comments
113 views