Need Hello world code

UI Components for JSF
Post Reply
vikas v
Posts: 21
Joined: 23 Mar 2011, 14:24

28 Mar 2011, 08:59

Hi,

Am new to prime faces. There are many resources providing simple Hello world code but none seems to work.

Am using JSF 2.0 in Eclipse Helios. Have included primefaces-2.2.RC2.jar ...

Anyone pls share code for jsp file, faces-config.xml, web.xml.


Thanks,

User avatar
bumble.bee
Posts: 723
Joined: 29 Sep 2010, 21:39
Location: United States

29 Mar 2011, 15:13

What version of PrimeFaces are you trying to use? PrimeFaces version 2.x and up only work with Facelets (i.e. you can't use JSP).

healeyb
Posts: 365
Joined: 07 Apr 2010, 16:05

29 Mar 2011, 15:29

Welcome to the PrimeFaces forum, if you have problems don't forget to
post up any information in your server log etc...

Code courtesy of NetBeans, with a couple of minor changes. Why are you
using RC2? I'd go for 2.2.1 personally.

web.xml

Code: Select all

<?xml version="1.0" encoding="UTF-8"?>
<web-app version="3.0" 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_3_0.xsd">
    <context-param>
        <param-name>javax.faces.PROJECT_STAGE</param-name>
        <param-value>Development</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>faces/index.xhtml</welcome-file>
    </welcome-file-list>
</web-app>
index.xhtml

Code: Select all

<?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:p="http://primefaces.prime.com.tr/ui"
      xmlns:h="http://java.sun.com/jsf/html"
      xmlns:f="http://java.sun.com/jsf/core">
    <f:view contentType="text/html">
        <h:head>
            <meta http-equiv="content-type" content="text/html; charset=UTF-8"/>
            <title>Facelet Title</title>
        </h:head>
        <h:body>
            <h:outputText value="Hello, World!"/>
            <br/>
        </h:body>
    </f:view>
</html>
p.s. If I was getting started with JSF right now I'd be thinking about getting
myself one of those ruggedized laptops, you know, one that's designed to
operate in harsh environments like a building site. I've thrown one though
a window and another across the room. You could save in the long term.

Post Reply

Return to “PrimeFaces”

  • Information
  • Who is online

    Users browsing this forum: No registered users and 63 guests