Win a copy of Five Lines of Code this week in the OO, Patterns, UML and Refactoring forum!
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Bear Bibeault
  • Ron McLeod
  • Jeanne Boyarsky
  • Paul Clapham
Sheriffs:
  • Tim Cooke
  • Liutauras Vilda
  • Junilu Lacar
Saloon Keepers:
  • Tim Moores
  • Stephan van Hulst
  • Tim Holloway
  • fred rosenberger
  • salvin francis
Bartenders:
  • Piet Souris
  • Frits Walraven
  • Carey Brown

Handling Exception/Runtime Exception in JSF

 
Greenhorn
Posts: 1
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi,

Any good pointers to documents describing proper error handling.

Not just navigation rules to an error.jsp file but also handling of runtime exceptions and exceptions in backing beans where you cannot use navigation rules (calling a method from JSF EL etc.).

I am developing jsr 168 portlets using jsf on websphere portal.

I can't get the error handling via web.xml to function and other places I can't manually make it go to an error.jsp in case of exceptions.
How to handle the runtime exception in JSF.

1. By including following tags in web.xml
<error-type>
<error-exception></error-exception>
<error-loaction>/error.jsp</error-loaction>
</error-type>

its not working.


2. If include the
<%@page errorPage="../error/GenericError.jsp" %>
in jsp page then
it is not forwading to error page giving asaertion failure exception

If we change the GenericError.jsp tag like

<f:view>
</f:view>
to
<f:subview>
</f:subview>

then it is going to error page but the
action inside the error page is not getting called its backing bean



Here is code of error.jsp

<%-- jsf:pagecode language="java" location="/JavaSource/pagecode/JSPs/ErrorPage1.java" --%><%-- /jsf:pagecode --%>
<%@taglib uri="http://java.sun.com/jsf/core"; prefix="f"%>
<%@taglib uri="http://java.sun.com/portlet"; prefix="portlet"%>
<%@taglib uri="http://java.sun.com/jsf/html"; prefix="h"%>
<%@ page isErrorPage="true" %>
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=ISO-8859-1">

</head>
<body>
<div class="errorMessage"><%= exception.getLocalizedMessage() %></div>
<f:subview id="name">
<h:commandButton action="#{OSPMTASecurityBean.cancel}" value="submit"/>


</f:subview>
</body>
</html>
 
Ranch Hand
Posts: 45
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I am also developing portlets. Check this entry for some alternatives:

http://www.newinstance.net/blog/2007/02/06/error-handling-with-jsfportlets-and-aop/
 
Politics is a circus designed to distract you from what is really going on. So is this tiny ad:
Building a Better World in your Backyard by Paul Wheaton and Shawn Klassen-Koop
https://coderanch.com/wiki/718759/books/Building-World-Backyard-Paul-Wheaton
    Bookmark Topic Watch Topic
  • New Topic