schwarzenegger
Grünschnabel
Hallo,
ich bin Anfänger in JSF und probiere gerade ein Beispiel-Projekt aufzuziehen, aber das funktioniert leider überhaupt nicht.
Ich benutze JSF 1.2.
Was kann ich tun ?
Ich komme nicht weiter ?
Bekomme immer folgende Exception:
faces-config.xml:
web.xml:
Bean:
jsp:
build.xml:
Ordner-Struktur:
test_jsf (Projektname):
test_jsf/../WebContent
test_jsf/../WebContent/test_jsf.jsp
test_jsf/../WebContent/META-INF
test_jsf/../WebContent/WEB-INF
test_jsf/../WebContent/WEB-INF/lib
test_jsf/../WebContent/WEB-INF/faces-config.xml
test_jsf/../WebContent/WEB-INF/web.xml
test_jsf/../WebContent/WEB-INF/src
test_jsf/../WebContent/WEB-INF/classes
ich bin Anfänger in JSF und probiere gerade ein Beispiel-Projekt aufzuziehen, aber das funktioniert leider überhaupt nicht.
Ich benutze JSF 1.2.
Was kann ich tun ?
Ich komme nicht weiter ?
Bekomme immer folgende Exception:
Code:
org.apache.jasper.el.JspPropertyNotFoundException:
/test_jsf.jsp(16,2) '#{Test_jsf_bean.input}' Target Unreachable, identifier 'Test_jsf_bean' resolved to null
faces-config.xml:
Code:
<?xml version="1.0" encoding="UTF-8"?>
<faces-config version="1.2" xmlns="http://java.sun.com/xml/ns/javaee"
xmlns:xi="http://www.w3.org/2001/XInclude"
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-facesconfig_1_2.xsd">
<managed-bean>
<managed-bean-name>Test_jsf_bean</managed-bean-name>
<managed-bean-class>test_jsf_package.Test_jsf_bean</managed-bean-class>
<managed-bean-scope>session</managed-bean-scope>
</managed-bean>
</faces-config>
web.xml:
Code:
<?xml version="1.0"?>
<web-app version="2.5" 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_2_5.xsd">
<!-- Display Name -->
<display-name>test</display-name>
<!-- Context Name -->
<context-param>
<param-name>javax.faces.STATE_SAVING_METHOD</param-name>
<param-value>server</param-value>
</context-param>
<!-- Listener -->
<listener>
<listener-class>com.sun.faces.config.ConfigureListener</listener-class>
</listener>
<!-- Faces Servlet -->
<servlet>
<servlet-name>Faces Servlet</servlet-name>
<servlet-class>javax.faces.webapp.FacesServlet</servlet-class>
<load-on-startup>1</load-on-startup>
</servlet>
<!-- Faces Servlet Mapping -->
<servlet-mapping>
<servlet-name>Faces Servlet</servlet-name>
<url-pattern>*.jsf</url-pattern>
</servlet-mapping>
</web-app>
Bean:
Code:
package test_jsf_package;
import java.io.Serializable;
public class Test_jsf_bean implements Serializable{
private static final long serialVersionUID = 1L;
private String input = "Test";
private String output = "Test";
public Test_jsf_bean() {
super();
}
public void action() {
output = "Welcome at the JSF world, " + input;
}
public void test() {
}
public String getInput() {
return input;
}
public void setInput(String input) {
this.input = input;
}
public String getOutput() {
return output;
}
public void setOutput(String output) {
this.output = output;
}
}
jsp:
Code:
<%@ page language="java" contentType="text/html; charset=ISO-8859-1"
pageEncoding="ISO-8859-1"%>
<%@ taglib uri="http://java.sun.com/jsf/core" prefix="f"%>
<%@ taglib uri="http://java.sun.com/jsf/html" prefix="h"%>
<%@ taglib uri="http://java.sun.com/jsp/jstl/core" prefix="c" %>
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<f:view>
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=ISO-8859-1">
<title>Title</title>
</head>
<body>
<h:form>
<h:outputLabel value="Enter your name (input): " /> <!-- for="input" -->
<h:inputText id="input" value="#{Test_jsf_bean.input}" required="true" />
<h:commandButton value="submit" action="#{Test_jsf_bean.action}" />
<h:outputText value="#{Test_jsf_bean.output}" />
<h:messages />
</h:form>
</body>
</html>
</f:view>
build.xml:
Code:
<?xml version="1.0" encoding="UTF-8"?>
<project name="ear" default="deploy-local" basedir=".">
<property name="ear.name" value="test_jsf.ear" />
<property name="war.name.server" value="test_jsf.war" />
<property name="jar.name.server" value="test_jsf.jar" />
<property name="jar.name.client" value="test-client.jar" />
<property name="deploy.dir.local" value="C:/develop/jboss-5.1.0.GA/jboss-5.1.0.GA/server/default/deploy" />
<!-- <property name="src.dir.client" value="C:/Dokumente und Einstellungen/Administrator/workspace/ejb_project_testClient/ejbModule/" /> -->
<property name="ear.dir.build" value="${basedir}/build" />
<property name="ear.dir.name" value="${ear.dir.build}/${ear.name}" />
<property name="jboss.dir" value="C:/develop/jboss-5.1.0.GA/jboss-5.1.0.GA" />
<property name="ear.META-INF.dir" value="${basedir}/EarContent/META-INF/" />
<property name="ear.META-INF.dir.appxml" value="${basedir}/EarContent/META-INF/application.xml" />
<property name="war.WebContent.dir" value="C:/Dokumente und Einstellungen/Administrator/workspace/test_jsf/WebContent/" />
<property name="war.WEB-INF.dir" value="C:/Dokumente und Einstellungen/Administrator/workspace/test_jsf/WebContent/WEB-INF" />
<property name="war.WEB-INF.dir.lib" value="C:/Dokumente und Einstellungen/Administrator/workspace/test_jsf/WebContent/WEB-INF/lib" />
<property name="war.WEB-INF.dir.webxml" value="C:/Dokumente und Einstellungen/Administrator/workspace/test_jsf/WebContent/WEB-INF/web.xml" />
<property name="war.WEB-INF.dir.classes" value="C:/Dokumente und Einstellungen/Administrator/workspace/test_jsf/WebContent/WEB-INF/classes" />
<property name="war.WEB-INF.dir.src.package" value="C:/Dokumente und Einstellungen/Administrator/workspace/test_jsf/WebContent/WEB-INF/src/test_jsf_package/" />
<!-- Beliebig erweiterbar -->
<path id="compile.classpath.1">
<pathelement location="${jboss.dir}" />
<fileset dir="${jboss.dir}/client">
<include name="*.jar" />
</fileset>
</path>
<path id="compile.classpath.2">
<pathelement location="${war.WEB-INF.dir.lib}" />
<fileset dir="${war.WEB-INF.dir.lib}">
<include name="*.jar" />
</fileset>
</path>
<target name="init" description="Build the distribution build folder">
<tstamp />
<mkdir dir="build" />
</target>
<target name="compile" depends="init" description="Compile the Java source code">
<javac destdir="build" debug="on" optimize="on" debuglevel="lines,vars,source">
<!-- classpath="${jboss.dir}/client/jbossall-client.jar" -->
<src path="${war.WEB-INF.dir.src.package}" />
<classpath refid="compile.classpath.1" />
<classpath refid="compile.classpath.2" />
</javac>
</target>
<target name="jar" depends="compile" description="Build the distribution *.jar file">
<jar jarfile="build/${jar.name.server}">
<fileset dir="build">
<include name="**/*.class" />
<exclude name="test/*.class" />
</fileset>
</jar>
</target>
<target name="war" depends="compile" description="Build the distribution *.war file">
<war destfile="build/${war.name.server}" webxml="${war.WEB-INF.dir.webxml}">
<lib dir="${war.WEB-INF.dir.lib}" />
<classes dir="${war.WEB-INF.dir.classes}" />
<fileset dir="${war.WebContent.dir}">
<include name="**/*.jsp" />
<!-- <exclude name="WEB-INF/web.xml" /> -->
</fileset>
<fileset dir="${war.WEB-INF.dir}">
<include name="**/*.xml" />
</fileset>
</war>
</target>
<target name="ear" depends="jar, war" description="Build the distribution *.ear file">
<ear destfile="${ear.dir.name}" appxml="${ear.META-INF.dir.appxml}">
<metainf dir="${ear.META-INF.dir}" />
<fileset dir="${ear.dir.build}">
<include name="*.war" />
<include name="*.jar" />
</fileset>
</ear>
</target>
<target name="deploy-local" depends="ear" description="Deploys *.ear to local jboss folder">
<copy todir="${deploy.dir.local}">
<fileset dir="${ear.dir.build}">
<include name="*.ear" />
</fileset>
</copy>
</target>
<target name="clean" depends="ear" description="Delete all generated files and folders">
<delete dir="build" />
</target>
</project>
Ordner-Struktur:
test_jsf (Projektname):
test_jsf/../WebContent
test_jsf/../WebContent/test_jsf.jsp
test_jsf/../WebContent/META-INF
test_jsf/../WebContent/WEB-INF
test_jsf/../WebContent/WEB-INF/lib
test_jsf/../WebContent/WEB-INF/faces-config.xml
test_jsf/../WebContent/WEB-INF/web.xml
test_jsf/../WebContent/WEB-INF/src
test_jsf/../WebContent/WEB-INF/classes
Zuletzt bearbeitet: