ERLEDIGT
NEIN
NEIN
ANTWORTEN
0
0
ZUGRIFFE
1203
1203
EMPFEHLEN
-
Hallo liebe Community,
ich hoffe ihr könnt mir weiter helfen !! Und zwar hab jetzt anfangen mich ein bißchen in JSF einzuarbeiten ! Dafür hab ein JSF-Tutorial durchgelesen und als praktisches Beispiel eine einfache jsp-Seite mit einem kleinen Formular benutzt, die beim anklicken auf ein submitt-button auf eine andere Seite weiterführt !! Das sah am Anfang alles verständlich aus, nur beim anklicken auf dieses Button immer eine ViewExpiredException gefeuert wird !?...
Damit ihr mir folgen könnt hab ich mein Code zum nachprüfen
:
Die benutzten Bean-klassen:
NameBean.java:
Code :1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30
public class NameBean { private String firstName = ""; private String lastName = ""; public NameBean() { } public NameBean(String firstName, String lastName) { setFirstName(firstName); setLastName(lastName); } public String getFirstName() { return(firstName); } public void setFirstName(String newFirstName) { firstName = newFirstName; } public String getLastName() { return(lastName); } public void setLastName(String newLastName) { lastName = newLastName; } }
CompanyBean.java:
Code :1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26
public class CompanyBean { private String companyName=""; private String business=""; public CompanyBean(String companyName, String business) { setCompanyName(companyName); setBusiness(business); } public String getCompanyName() { return(companyName); } public void setCompanyName(String newCompanyName) { companyName = newCompanyName; } public void setBusiness(String newBusiness) { business = newBusiness; } public String getBusiness() { return(business); } }
EmployeeBean.java:
Code :1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40
public class EmployeeBean { private NameBean name; private CompanyBean company; public EmployeeBean(NameBean name, CompanyBean company) { setName(name); setCompany(company); } public EmployeeBean(){} public NameBean getName() { return(name); } public void setName(NameBean newName) { name = newName; } public CompanyBean getCompany() { return(company); } public void setCompany(CompanyBean newCompany) { company = newCompany; } public String processEmployee() { if (Math.random() < 0.5) { return("accept"); } else { return("reject"); } } }
web.xml:
Code :1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73
<?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>JSF_Sub_Project</display-name> <welcome-file-list> <welcome-file>index.html</welcome-file> <welcome-file>index.htm</welcome-file> <welcome-file>index.jsp</welcome-file> <welcome-file>default.html</welcome-file> <welcome-file>default.htm</welcome-file> <welcome-file>default.jsp</welcome-file> </welcome-file-list> <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> <context-param> <param-name>javax.servlet.jsp.jstl.fmt.localizationContext</param-name> <param-value>resources.application</param-value> </context-param> <context-param> <description>State saving method: 'client' or 'server' (=default). See JSF Specification 2.5.2</description> <param-name>javax.faces.STATE_SAVING_METHOD</param-name> <param-value>client</param-value> </context-param> <context-param> <param-name>facelets.BUILD_BEFORE_RESTORE</param-name> <param-value>true</param-value> </context-param> <context-param> <description> This parameter tells MyFaces if javascript code should be allowed in the rendered HTML output. If javascript is allowed, command_link anchors will have javascript code that submits the corresponding form. If javascript is not allowed, the state saving info and nested parameters will be added as url parameters. Default is 'true'</description> <param-name>org.apache.myfaces.ALLOW_JAVASCRIPT</param-name> <param-value>true</param-value> </context-param> <context-param> <description> If true, rendered HTML code will be formatted, so that it is 'human-readable' i.e. additional line separators and whitespace will be written, that do not influence the HTML code. Default is 'true'</description> <param-name>org.apache.myfaces.PRETTY_HTML</param-name> <param-value>true</param-value> </context-param> <context-param> <param-name>org.apache.myfaces.DETECT_JAVASCRIPT</param-name> <param-value>false</param-value> </context-param> <context-param> <description> If true, a javascript function will be rendered that is able to restore the former vertical scroll on every request. Convenient feature if you have pages with long lists and you do not want the browser page to always jump to the top if you trigger a link or button action that stays on the same page. Default is 'false' </description> <param-name>org.apache.myfaces.AUTO_SCROLL</param-name> <param-value>true</param-value> </context-param> <listener> <listener-class>org.apache.myfaces.webapp.StartupServletContextListener</listener-class> </listener> </web-app>
faces-config.xml:
Code :1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21
<?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>employee</managed-bean-name> <managed-bean-class>EmployeeBean</managed-bean-class> <managed-bean-scope>request</managed-bean-scope> </managed-bean> <navigation-rule> <from-view-id>/submitting.jsp</from-view-id> <navigation-case> <from-outcome>accept</from-outcome> <to-view-id>/accept.jsp</to-view-id> </navigation-case> <navigation-case> <from-outcome>reject</from-outcome> <to-view-id>/reject.jsp</to-view-id> </navigation-case> </navigation-rule> </faces-config>
Die jsp-Klassen:
submitting.jsp
Code :1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28
<%@ page language="java" contentType="text/html; charset=ISO-8859-1" pageEncoding="ISO-8859-1"%> <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"> <%@ taglib uri="http://java.sun.com/jsf/core" prefix="f" %> <%@ taglib uri="http://java.sun.com/jsf/html" prefix="h" %> <f:view> <html> <head> <meta http-equiv="Content-Type" content="text/html; charset=ISO-8859-1"> <title>Submitt</title> </head> <body> <TABLE BORDER=5 ALIGN="CENTER"> <TR><TH CLASS="TITLE">Submitting Bean Properties</TH></TR> </TABLE> <h:form> Your first name:<h:inputText value="#{employee.name.firstName}"/> <BR> Your last name:<h:inputText value="#{employee.name.lastName}"/> <BR> Name of your company:<h:inputText value="#{employee.company.companyName}"/> <BR> Business area of your company:<h:inputText value="#{employee.company.business}"/> <BR> <h:commandButton value="Process" action="#{employee.processEmployee}"/> </h:form> </body> </html> </f:view>
accept.jsp:
Code :1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24
<%@ page language="java" contentType="text/html; charset=ISO-8859-1" pageEncoding="ISO-8859-1"%> <!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"> <%@ taglib uri="http://java.sun.com/jsf/core" prefix="f" %> <%@ taglib uri="http://java.sun.com/jsf/html" prefix="h" %> <f:view> <html> <head> <meta http-equiv="Content-Type" content="text/html; charset=ISO-8859-1"> <title>Accepted</title> </head> <body> <TABLE BORDER=5 ALIGN="CENTER"> <TR><TH CLASS="TITLE">Employee accepted</TH></TR> </TABLE> <UL> <LI>Employee's first name:<h:outputText value="#{employee.name.firstName}"/> <LI>Employee's last name:<h:outputText value="#{employee.name.lastName}"/> <LI>Name of employee's company:<h:outputText value="#{employee.company.companyName}"/> <LI>Business area of employee's company:<h:outputText value="#{employee.company.business}"/> </UL> Congratulations! </BODY> </HTML> </f:view>
reject.jsp:
Code :1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24
<%@ page language="java" contentType="text/html; charset=ISO-8859-1" pageEncoding="ISO-8859-1"%> <!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"> <%@ taglib uri="http://java.sun.com/jsf/core" prefix="f" %> <%@ taglib uri="http://java.sun.com/jsf/html" prefix="h" %> <f:view> <html> <head> <meta http-equiv="Content-Type" content="text/html; charset=ISO-8859-1"> <title>Rejected</title> </head> <body> <TABLE BORDER=5 ALIGN="CENTER"> <TR><TH CLASS="TITLE">Employee rejected</TH></TR> </TABLE> <UL> <LI>Employee's first name:<h:outputText value="#{employee.name.firstName}"/> <LI>Employee's last name:<h:outputText value="#{employee.name.lastName}"/> <LI>Name of employee's company:<h:outputText value="#{employee.company.companyName}"/> <LI>Business area of employee's company:<h:outputText value="#{employee.company.business}"/> </UL> Go Away! </BODY> </HTML> </f:view>
Fehlermeldung:
Code :1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46
SCHWERWIEGEND: View State cannot be reconstructed javax.faces.FacesException: javax.faces.application.ViewExpiredException at org.apache.myfaces.shared_impl.util.StateUtils.decrypt(StateUtils.java:488) at org.apache.myfaces.shared_impl.util.StateUtils.reconstruct(StateUtils.java:376) at org.apache.myfaces.renderkit.html.HtmlResponseStateManager.getSavedState(HtmlResponseStateManager.java:187) at org.apache.myfaces.renderkit.html.HtmlResponseStateManager.getState(HtmlResponseStateManager.java:139) at org.apache.myfaces.application.jsp.JspStateManagerImpl.restoreView(JspStateManagerImpl.java:349) at org.apache.myfaces.application.jsp.JspViewHandlerImpl.restoreView(JspViewHandlerImpl.java:515) at org.apache.myfaces.lifecycle.RestoreViewExecutor.execute(RestoreViewExecutor.java:85) at org.apache.myfaces.lifecycle.LifecycleImpl.executePhase(LifecycleImpl.java:103) at org.apache.myfaces.lifecycle.LifecycleImpl.execute(LifecycleImpl.java:76) at javax.faces.webapp.FacesServlet.service(FacesServlet.java:183) at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:290) at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:206) at org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:233) at org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:191) at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:127) at org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:102) at org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:109) at org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:298) at org.apache.coyote.http11.Http11Processor.process(Http11Processor.java:857) at org.apache.coyote.http11.Http11Protocol$Http11ConnectionHandler.process(Http11Protocol.java:588) at org.apache.tomcat.util.net.JIoEndpoint$Worker.run(JIoEndpoint.java:489) at java.lang.Thread.run(Unknown Source) Caused by: javax.faces.application.ViewExpiredException at org.apache.myfaces.shared_impl.util.StateUtils.decrypt(StateUtils.java:481) ... 21 more 07.01.2011 11:30:16 javax.faces.webapp._ErrorPageWriter handleThrowable SCHWERWIEGEND: An exception occurred javax.faces.application.ViewExpiredException: /submitting.facesNo saved view state could be found for the view identifier: /submitting.faces at org.apache.myfaces.lifecycle.RestoreViewExecutor.execute(RestoreViewExecutor.java:88) at org.apache.myfaces.lifecycle.LifecycleImpl.executePhase(LifecycleImpl.java:103) at org.apache.myfaces.lifecycle.LifecycleImpl.execute(LifecycleImpl.java:76) at javax.faces.webapp.FacesServlet.service(FacesServlet.java:183) at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:290) at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:206) at org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:233) at org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:191) at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:127) at org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:102) at org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:109) at org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:298) at org.apache.coyote.http11.Http11Processor.process(Http11Processor.java:857) at org.apache.coyote.http11.Http11Protocol$Http11ConnectionHandler.process(Http11Protocol.java:588) at org.apache.tomcat.util.net.JIoEndpoint$Worker.run(JIoEndpoint.java:489) at java.lang.Thread.run(Unknown Source)
Ich wäre euch für jede Hilfe dankbar !!
LG, Crombix.
Ähnliche Themen
-
[RCP] View durch einen anderen View ersetzen
Von lowskilla im Forum Swing, Java2D/3D, SWT, JFaceAntworten: 2Letzter Beitrag: 11.09.09, 09:24 -
Doc/View mit Splitter. Wieso kennt keine View ihr Document?
Von Perdan im Forum C/C++Antworten: 0Letzter Beitrag: 13.10.08, 11:44 -
MFC Doc View / View Kopie
Von haemmer im Forum VisualStudio & MFCAntworten: 1Letzter Beitrag: 07.03.06, 08:19 -
Stammbaum in View, Objekte in View verschieben.
Von Ron-calli im Forum VisualStudio & MFCAntworten: 0Letzter Beitrag: 11.10.05, 18:01 -
360° view
Von snafe im Forum Flash PlattformAntworten: 3Letzter Beitrag: 07.09.02, 20:53





Zitieren
Login





