Foros del Web » Programación para mayores de 30 ;) » Java »

Como hacer HOLA MUNDO con JSF 2

Estas en el tema de Como hacer HOLA MUNDO con JSF 2 en el foro de Java en Foros del Web. Q tal amigos, Quiero iniciarme en JSF 2, y he intentado hacer un sencillo programa "Hola Mundo" pero no lo logro Trabajo con: - Ubuntu ...
  #1 (permalink)  
Antiguo 21/12/2011, 06:40
 
Fecha de Ingreso: diciembre-2007
Mensajes: 34
Antigüedad: 16 años, 4 meses
Puntos: 0
Pregunta Como hacer HOLA MUNDO con JSF 2

Q tal amigos,

Quiero iniciarme en JSF 2, y he intentado hacer un sencillo programa "Hola Mundo" pero no lo logro

Trabajo con:

- Ubuntu - Eclipse Indigo - Jboss 4.2


Quiero hacer:

- Un simple ejemplo usando Facelet (plantillas). Solo quiero mostrar un .xhtml donde cargue mi plantilla y listo.

Asi tengo mi proyecto en eclipse:

-HolaMundoFacelet
.
.
.
WebContent
.....index.html
.....test.xhtml
.....plantilla.xhtml
.....WEB-INF
..........lib
...............javax.faces-2.1.4.jar
..........web.xml

--------------------------------------------------------------

Les describo cada archivo:

+ index.html

<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<meta http-equiv="refresh" content="1;url=test.xhtml">
<title>Insert title here</title>
</head>
<body>
<h1>Bienvenido!!!</h1>
</body>
</html>

+ test.xhtml

<!DOCTYPE composition PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<ui:composition xmlns="http://www.w3.org/1999/xhtml"
xmlns:ui="http://java.sun.com/jsf/facelets"
xmlns:f="http://java.sun.com/jsf/core"
xmlns:h="http://java.sun.com/jsf/html"
template="plantilla.xhtml">

<ui:define name="contenido">
<h:form>
<div >
Este es el contenido
</div>
</h:form>
</ui:define>
</ui:composition>

+ plantilla.xhtml

<!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"
xml:lang="es" lang="es">

<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />
<title>Titulo plantilla</title>
</head>

<body>
Antes
<div id="contenido">
<ui:insert name="contenido"/>
</div>
Despues
</body>
</html>

+ web.xml

<?xml version="1.0" encoding="UTF-8"?>
<web-app xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns="http://java.sun.com/xml/ns/javaee" xmlns:web="http://java.sun.com/xml/ns/javaee/web-app_2_5.xsd" xsi:schemaLocation="http://java.sun.com/xml/ns/javaee http://java.sun.com/xml/ns/javaee/web-app_2_5.xsd" id="WebApp_ID" version="2.5">
<display-name>TestFacelet</display-name>
<context-param>
<param-name>javax.faces.STATE_SAVING_METHOD</param-name>
<param-value>client</param-value>
</context-param>

<context-param>
<param-name>javax.faces.PROJECT_STAGE</param-name>
<param-value>Production</param-value>
</context-param>

<context-param>
<param-name>com.sun.faces.resourceUpdateCheckPeriod</param-name>
<param-value>-1</param-value>
</context-param>

<context-param>
<param-name>javax.faces.FACELETS_LIBRARIES</param-name>
<param-value>/WEB-INF/jsf2.0.taglib.xml</param-value>
</context-param>

<context-param>
<description>
Set this flag to true if you want the JavaServer Faces
Reference Implementation to validate the XML in your
faces-config.xml resources against the DTD. Default
value is false.
</description>
<param-name>com.sun.faces.validateXml</param-name>
<param-value>true</param-value>
</context-param>

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

<servlet-mapping>
<servlet-name>FacesServlet</servlet-name>
<url-pattern>*.xhtml</url-pattern>
</servlet-mapping>

<welcome-file-list>
<welcome-file>index.html</welcome-file>
</welcome-file-list>
</web-app>


Como pueden ver al correr mi aplicacion deberia verse:

----------------------------------------------------------------
Antes
Este es el contenido
Despues

--------------------------------------------------------------

Pero NO aparece nada, es como si no insertara la plantilla

-----------------------------------------------------------



-----------------------------------------------------------


He probado una y otra vez, he visto varios temas in internet pero aun no puedo.


Ojala puedan probarlo y ver q pasa: Si necesito otra libreria, configural el web.xml, etc


Agradezco cualquier ayuda.

Etiquetas: jar, jsf, mundo, aplicaciones
Atención: Estás leyendo un tema que no tiene actividad desde hace más de 6 MESES, te recomendamos abrir un Nuevo tema en lugar de responder al actual.
Respuesta




La zona horaria es GMT -6. Ahora son las 15:56.