0

I have imported a jsf project in my netbeans. I resolved all the resolution problems as the libraries have been stored in the ./lib folder.

When I run the project, one line of header is visible but the links are not visible in the browser. When I checked the html source in the browser, it is like this.

<?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:c="http://xmlns.jcp.org/jsp/jstl/core">
    <h:head>
        <title>Prototype of Engine</title>
        <link rel="stylesheet" type="text/css" href="../includes/style.css" />
    </h:head>
    <h:body>
        <h1>Prototype I of Engine</h1>
        <h3><h:link outcome="auto_cleanse" value="Start Auto Cleansing"></h:link></h3>
        <h3><h:link outcome="data_transfer" value="Verify data for visit details"></h:link></h3>
        <h3><h:link outcome="itemized_bill" value="Assign revenue codes to items in itemized bill"></h:link></h3>
        <h3><h:link outcome="todo" value="TO DO List"></h:link></h3>
    </h:body>
</html>

So the only thing rendered is

Prototype I of Engine

What possibly might have been wrong. Thanks in advanced.

Rajan
  • 1,501
  • 4
  • 21
  • 37

3 Answers3

2

If what you posted is the HTML source from your browser, then something is wrong since it still has the JSF tags associated with it (it still contains the <h:link> tag for instance). Basically, the server rendered the XHTML page back, not an HTML one. The JSF Servlet is the one that reads the XHTML page, and renders back an HTML one, so it's most likely that your request is bypassing the JSF Servlet altogether.

This can happen if JSF is not properly configured. Be sure to have this in your web.xml:

<servlet>
    <servlet-name>Faces Servlet</servlet-name>
    <servlet-class>javax.faces.webapp.FacesServlet</servlet-class>
</servlet>     

<servlet-mapping>
    <servlet-name>Faces Servlet</servlet-name>
    <url-pattern>*.jsf</url-pattern>
</servlet-mapping>
gonzaw
  • 771
  • 4
  • 17
  • I have
    
            Faces Servlet
            javax.faces.webapp.FacesServlet
            1
        
        
            Faces Servlet
            /faces/*
        
    
    – Rajan Nov 10 '13 at 04:08
  • I have xhtml view files. I have the above tags in my web.xml. When I change the url-pattern to *.xhtml, Its sending the same output – Rajan Nov 10 '13 at 04:21
  • Add a servlet mapping for *.jsf or *.xhtml (the one you use in your request). If you access the page with "http://..../test.jsf" add the *.jsf mapping, if you access it with "http://..../test.xhtml" add the *.xhtml mapping. – gonzaw Nov 10 '13 at 05:06
  • if you don't set the jsf mapping and call the page as jsp page, then you will get ERROR! no partial result. –  Nov 10 '13 at 08:38
  • Use `*.xhtml` as servlet mapping instead, so there's no need to change the suffix in each url. Related: http://stackoverflow.com/q/3008395/1065197 – Luiggi Mendoza Nov 10 '13 at 14:45
0

Your problem is that your request does not reach to faces servlet. So first thing is you need to make sure that all your configuration & coding is correct to send request to servlet.

If you have a mix of jsf pages & other pages then use /faces/*.xhtml else if all the pages are jsf pages then you can use /* as well.

JSF work as a form request so you need to add a form tag <h:link> element so that request can reach to faces servlet.

0

Ok, I followed up with my companions. The same code was working in their pc but not in mine. My netbeans was 7.1.1. I downloaded the latest 7.4 Java EE edition netbeans. It showed me some errors in the properties->libraries like jstl11 not in classpath which was not shown by the previous version of netbeans. I unchecked it. I also unchecked RichFaces from Frameworks section. Now it runs perfectly.

The above answers were helpful as they made me clear that code is not the problem. It had something to do with configuration and libraries etc.

Thanks for trying.

Arjan Tijms
  • 37,782
  • 12
  • 108
  • 140
Rajan
  • 1,501
  • 4
  • 21
  • 37