NuBuMu

Thursday, October 16, 2008

myFaces 1.2.3

Application Server: Tomcat 6.0.14

Librerias usadas:
commons-beanutils-1.7.0.jar
commons-codec-1.3.jar
commons-digester-1.8.jar
commons-discovery-0.4.jar
commons-el-1.0.jar
commons-logging-1.1.1.jar
jstl-1.2.jar
myfaces-api-1.2.3.jar
myfaces-impl-1.2.3.jar
tomahawk-1.1.6.jar (esta no se utiliza en esta prueba)

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>xMyFaces</display-name>
<welcome-file-list>
<welcome-file>index.html</welcome-file>
<welcome-file>/pages/index.jsp</welcome-file>
<welcome-file>index.jsp</welcome-file>

</welcome-file-list>
<context-param>
<param-name>javax.faces.STAGE_SAVING_METHOD</param-name>
<param-value>SERVER</param-value>
</context-param>

<!-- Listeners -->
<listener>
<listener-class>
org.apache.myfaces.webapp.StartupServletContextListener
</listener-class>
</listener>

<!-- Faces Servlet -->
<servlet>
<servlet-name>Faces Servlet</servlet-name>
<servlet-class>javax.faces.webapp.FacesServlet</servlet-class>
</servlet>
<!-- Faces Servlet Mapping -->
<servlet-mapping>
<servlet-name>Faces Servlet</servlet-name>
<url-pattern>*.jsf</url-pattern>
</servlet-mapping>

</web-app>

faces-config.xml

<faces-config>
<managed-bean>
<description>Test</description>
<managed-bean-name>test</managed-bean-name>
<managed-bean-class>uk.co.myfaces.test.Test</managed-bean-class>
<managed-bean-scope>session</managed-bean-scope>
</managed-bean>

<navigation-rule>
<from-view>index.jsp</from-view>
<navigation-case>
<from-outcoume>success</from-outcoume>
<to-view-id>/pages/welcome.jsp</to-view-id>
<redirect/>
</navigation-case>
</navigation-rule>
</faces-config>


index.jsp
<%@ page language="java" contentType="text/html; charset=ISO-8859-1" pageEncoding="ISO-8859-1"%>
<%@ taglib prefix="f" uri="http://java.sun.com/jsf/core"%>
<%@ taglib prefix="h" uri="http://java.sun.com/jsf/html"%>


<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=ISO-8859-1">
<title>MyFaces</title>
</head>
<body>
<f:view>
<h:form id="form">
<h:commandLink action="#{test.doTest}">Go to Welcome!</h:commandLink>
</h:form>
</f:view>
</body>
</html>

Welcome.jsp
<%@ page language="java" contentType="text/html; charset=ISO-8859-1" pageEncoding="ISO-8859-1"%>
<%@ taglib prefix="f" uri="http://java.sun.com/jsf/core"%>
<%@ taglib prefix="h" uri="http://java.sun.com/jsf/html"%>
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=ISO-8859-1">
<title>MyFaces</title>
</head>
<body>
<f:view>
<h:outputText value="Welcome to MyFaces!" />
</f:view>
</body>
</html>

Test.class
package uk.co.myfaces.test;

public class Test {

public String doTest(){
return "success";
}
}

0 Comments:

Post a Comment

<< Home