本文整理汇总了Java中javax.faces.event.ExceptionQueuedEvent.getSource方法的典型用法代码示例。如果您正苦于以下问题:Java ExceptionQueuedEvent.getSource方法的具体用法?Java ExceptionQueuedEvent.getSource怎么用?Java ExceptionQueuedEvent.getSource使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类javax.faces.event.ExceptionQueuedEvent
的用法示例。
在下文中一共展示了ExceptionQueuedEvent.getSource方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: handle
import javax.faces.event.ExceptionQueuedEvent; //导入方法依赖的package包/类
@Override
public void handle() throws FacesException {
for (Iterator<ExceptionQueuedEvent> i = getUnhandledExceptionQueuedEvents().iterator(); i.hasNext();) {
ExceptionQueuedEvent event = i.next();
ExceptionQueuedEventContext context = (ExceptionQueuedEventContext) event.getSource();
Throwable t = context.getException();
if (t instanceof ViewExpiredException) {
FacesContext fc = FacesContext.getCurrentInstance();
NavigationHandler nav = fc.getApplication().getNavigationHandler();
try {
nav.handleNavigation(fc, null, "expired?faces-redirect=true&includeViewParams=true");
fc.renderResponse();
} finally {
i.remove();
}
}
}
// At this point, the queue will not contain any ViewExpiredEvents.
// Therefore, let the parent handle them.
getWrapped().handle();
}
示例2: handle
import javax.faces.event.ExceptionQueuedEvent; //导入方法依赖的package包/类
@Override
public void handle() throws FacesException {
for (Iterator<ExceptionQueuedEvent> i = getUnhandledExceptionQueuedEvents().iterator(); i.hasNext();) {
ExceptionQueuedEvent event = i.next();
ExceptionQueuedEventContext context = (ExceptionQueuedEventContext) event.getSource();
Throwable t = context.getException();
if (t instanceof ViewExpiredException) {
ViewExpiredException vee = (ViewExpiredException) t;
FacesContext facesContext = FacesContext.getCurrentInstance();
Map<String, Object> requestMap = facesContext.getExternalContext().getRequestMap();
NavigationHandler navigationHandler = facesContext.getApplication().getNavigationHandler();
try {
// Push some useful stuff to the request scope for use in the page
requestMap.put("currentViewId", vee.getViewId());
navigationHandler.handleNavigation(facesContext, null, "/viewExpired");
facesContext.renderResponse();
} finally {
i.remove();
}
}
}
// At this point, the queue will not contain any ViewExpiredEvents. Therefore, let the parent handle them.
getWrapped().handle();
}
示例3: handle
import javax.faces.event.ExceptionQueuedEvent; //导入方法依赖的package包/类
@Override
public void handle() throws FacesException {
Iterator<ExceptionQueuedEvent> events = getUnhandledExceptionQueuedEvents().iterator();
while (events.hasNext()) {
ExceptionQueuedEvent event = events.next();
ExceptionQueuedEventContext context = (ExceptionQueuedEventContext) event.getSource();
Throwable exception = context.getException();
try {
if (exception instanceof ViewExpiredException) {
HttpServletRequest request = (HttpServletRequest) FacesContext.getCurrentInstance().getExternalContext().getRequest();
FacesContext.getCurrentInstance().getExternalContext().redirect(request.getRequestURI()+"?viewExpired=true");
}
} catch (IOException ex) {
Logger.getLogger(JsfExceptionHandler.class.getName()).log(Level.SEVERE, null, ex);
} finally {
events.remove();
}
}
getWrapped().handle();
}
示例4: handle
import javax.faces.event.ExceptionQueuedEvent; //导入方法依赖的package包/类
@Override
public void handle() throws FacesException {
final Iterator iterator = getUnhandledExceptionQueuedEvents().iterator();
while (iterator.hasNext()) {
final ExceptionQueuedEvent event = (ExceptionQueuedEvent) iterator.next();
final ExceptionQueuedEventContext context = (ExceptionQueuedEventContext) event.getSource();
final Throwable throwable = context.getException();
final FacesContext fc = FacesContext.getCurrentInstance();
final ValueExpression valueExpression = fc.getApplication().getExpressionFactory()
.createValueExpression(fc.getELContext(), "#{delegatesInjector}", DelegatesInjector.class);
final DelegatesInjector delegatesInjector = (DelegatesInjector) valueExpression.getValue(fc.getELContext());
final Map<Class, ExceptionHandlerDelegate> delegatesMap = delegatesInjector.getDelegatesMap();
try {
if (delegateHandling(throwable, delegatesMap, fc)) {
iterator.remove();
} else {
getWrapped().handle();
}
} catch (IOException e) {
LOGGER.error("error while handling exception: " + throwable, e);
getWrapped().handle();
}
}
}
示例5: handle
import javax.faces.event.ExceptionQueuedEvent; //导入方法依赖的package包/类
public void handle() throws FacesException {
final Iterator<ExceptionQueuedEvent> i = getUnhandledExceptionQueuedEvents().iterator();
while (i.hasNext()) {
ExceptionQueuedEvent event = i.next();
ExceptionQueuedEventContext context = (ExceptionQueuedEventContext) event.getSource();
Throwable t = context.getException();
final FacesContext fc = FacesContext.getCurrentInstance();
final ExternalContext externalContext = fc.getExternalContext();
final ConfigurableNavigationHandler nav = (ConfigurableNavigationHandler) fc.getApplication().getNavigationHandler();
try {
log.error(t.getMessage(), t);
performRedirect(externalContext, "/error_service");
fc.renderResponse();
} finally {
i.remove();
}
}
getWrapped().handle();
}
示例6: handle
import javax.faces.event.ExceptionQueuedEvent; //导入方法依赖的package包/类
/**
* {@inheritDoc}
*/
@Override
public void handle() throws FacesException {
FacesContext fc = FacesContext.getCurrentInstance();
for ( Iterator<ExceptionQueuedEvent> i = this.getUnhandledExceptionQueuedEvents().iterator(); i.hasNext(); ) {
ExceptionQueuedEvent event = i.next();
ExceptionQueuedEventContext context = (ExceptionQueuedEventContext) event.getSource();
Throwable t = context.getException();
if ( fc.isProjectStage( ProjectStage.Development ) ) {
t.printStackTrace();
}
do {
if ( t instanceof AuthorizationException ) {
this.handleAuthorizationException( fc, (AuthorizationException) t, i );
return;
}
if ( t instanceof ViewExpiredException ) {
this.handleViewExpiredException( fc, (ViewExpiredException) t, i );
return;
}
t = t.getCause();
} while ( t != null );
this.handleGenericException( fc );
}
}
示例7: handle
import javax.faces.event.ExceptionQueuedEvent; //导入方法依赖的package包/类
@Override
public void handle() throws FacesException {
LOG.log(Level.INFO, "invoking custom ExceptionHandlder...");
Iterator<ExceptionQueuedEvent> events = getUnhandledExceptionQueuedEvents().iterator();
while (events.hasNext()) {
ExceptionQueuedEvent event = events.next();
ExceptionQueuedEventContext context = (ExceptionQueuedEventContext) event.getSource();
Throwable t = context.getException();
LOG.log(Level.INFO, "[email protected]" + t.getClass().getName());
LOG.log(Level.INFO, "ExceptionHandlder began.");
//t.printStackTrace();
if (t instanceof ViewExpiredException) {
try {
handleViewExpiredException((ViewExpiredException) t);
} finally {
events.remove();
}
} else if (t instanceof TaskNotFoundException) {
try {
handleNotFoundException((Exception) t);
} finally {
events.remove();
}
} else {
getWrapped().handle();
}
LOG.log(Level.INFO, "ExceptionHandlder end.");
}
}
示例8: handle
import javax.faces.event.ExceptionQueuedEvent; //导入方法依赖的package包/类
@Override
public void handle() throws FacesException {
LOG.log(Level.INFO, "invoking custom ExceptionHandlder...");
Iterator<ExceptionQueuedEvent> events = getUnhandledExceptionQueuedEvents().iterator();
while (events.hasNext()) {
ExceptionQueuedEvent event = events.next();
ExceptionQueuedEventContext context = (ExceptionQueuedEventContext) event.getSource();
Throwable t = context.getException();
LOG.log(Level.INFO, "[email protected]" + t.getClass().getName());
LOG.log(Level.INFO, "ExceptionHandlder began.");
LOG.log(Level.INFO, "t instanceof [email protected]" + (t instanceof FacesException));
// log.log(Level.INFO, "t instanceof [email protected]" + (t instanceof FacesFileNotFoundException));
t.printStackTrace();
if (t instanceof ViewExpiredException) {
try {
handleViewExpiredException((ViewExpiredException) t);
} finally {
events.remove();
}
} else if (t instanceof FacesFileNotFoundException) {
try {
handleNotFoundException((Exception) t);
} finally {
events.remove();
}
} else {
getWrapped().handle();
}
LOG.log(Level.INFO, "ExceptionHandlder end.");
}
}
示例9: handle
import javax.faces.event.ExceptionQueuedEvent; //导入方法依赖的package包/类
@Override
public void handle() throws FacesException {
Iterator<ExceptionQueuedEvent> it = getUnhandledExceptionQueuedEvents().iterator();
while (it.hasNext()) {
ExceptionQueuedEvent event = it.next();
ExceptionQueuedEventContext c = (ExceptionQueuedEventContext) event.getSource();
Throwable t = c.getException();
HttpServletRequest req =
(HttpServletRequest) c.getContext().getExternalContext().getRequest();
HttpServletResponse res =
(HttpServletResponse) c.getContext().getExternalContext().getResponse();
handleException(req, res, t);
}
}
示例10: handle
import javax.faces.event.ExceptionQueuedEvent; //导入方法依赖的package包/类
@Override
public void handle() throws FacesException {
for (Iterator<ExceptionQueuedEvent> i = getUnhandledExceptionQueuedEvents().iterator(); i.hasNext();) {
ExceptionQueuedEvent event = i.next();
ExceptionQueuedEventContext context = (ExceptionQueuedEventContext) event.getSource();
Throwable t = context.getException();
if (t instanceof ViewExpiredException) {
ViewExpiredException vee = (ViewExpiredException) t;
FacesContext fc = FacesContext.getCurrentInstance();
Map<String, Object> requestMap = fc.getExternalContext().getRequestMap();
NavigationHandler nav =
fc.getApplication().getNavigationHandler();
try {
// Push some useful stuff to the request scope for
// use in the page
requestMap.put("currentViewId", vee.getViewId());
nav.handleNavigation(fc, null, "viewExpired");
fc.renderResponse();
RequestContext.getCurrentInstance().execute("PF('expiredSessionDialog').show();");
} finally {
i.remove();
}
}
}
// At this point, the queue will not contain any ViewExpiredEvents.
// Therefore, let the parent handle them.
getWrapped().handle();
}
示例11: handle
import javax.faces.event.ExceptionQueuedEvent; //导入方法依赖的package包/类
@Override
public void handle() throws FacesException {
for (Iterator<ExceptionQueuedEvent> i = getUnhandledExceptionQueuedEvents().iterator(); i.hasNext();) {
ExceptionQueuedEvent event = i.next();
ExceptionQueuedEventContext context = (ExceptionQueuedEventContext) event.getSource();
Throwable t = context.getException();
if (t instanceof ViewExpiredException) {
ViewExpiredException vee = (ViewExpiredException) t;
LOG.log(Level.WARNING, "View Expired {0}", vee.getViewId());
FacesContext fc = FacesContext.getCurrentInstance();
NavigationHandler nav = fc.getApplication().getNavigationHandler();
try {
String navigation = vee.getViewId();
if ("jobs/index.xhtml".equals(vee.getViewId())){
navigation += "?faces-redirect=true";
}
nav.handleNavigation(fc, null, navigation);
fc.renderResponse();
} finally {
i.remove();
}
}
}
// At this point, the queue will not contain any ViewExpiredEvents.
// Therefore, let the parent handle them.
getWrapped().handle();
}
示例12: handle
import javax.faces.event.ExceptionQueuedEvent; //导入方法依赖的package包/类
@Override
public void handle() throws FacesException {
Iterator<ExceptionQueuedEvent> events = getUnhandledExceptionQueuedEvents().iterator();
while (events.hasNext()) {
ExceptionQueuedEvent event = events.next();
ExceptionQueuedEventContext context = (ExceptionQueuedEventContext) event.getSource();
Throwable exception = context.getException();
NegocioException negocioException = getNegocioException(exception);
boolean handled = false;
try {
if (exception instanceof ViewExpiredException) {
handled = true;
redirect("/");
} else if (negocioException != null) {
handled = true;
FacesUtil.addErrorMessage(negocioException.getMessage());
} else {
handled = true;
log.error("Erro de sistema: " + exception.getMessage(), exception);
redirect("/Erro.xhtml");
}
} finally {
if (handled) {
events.remove();
}
}
}
getWrapped().handle();
}
示例13: handle
import javax.faces.event.ExceptionQueuedEvent; //导入方法依赖的package包/类
@Override
public void handle() throws FacesException {
final Iterator<ExceptionQueuedEvent> iterator = getUnhandledExceptionQueuedEvents().iterator();
while (iterator.hasNext()) {
ExceptionQueuedEvent event = iterator.next();
ExceptionQueuedEventContext context = (ExceptionQueuedEventContext) event.getSource();
Throwable throwable = context.getException();
final FacesContext fc = FacesContext.getCurrentInstance();
try {
String message = throwable.getMessage();
logger.error(message, throwable);
WebHelper.setSessionAttribute(SessionKey.ERROR_MESSAGES.name(), Arrays.asList(message));
ServletRequest request = (ServletRequest) fc.getExternalContext().getRequest();
String url = UrlHelper.buildWebAppUrl(request, "error.xhtml");
WebHelper.sendRedirect(url);
fc.renderResponse();
} finally {
iterator.remove();
}
}
getWrapped().handle();
}
示例14: handle
import javax.faces.event.ExceptionQueuedEvent; //导入方法依赖的package包/类
@Override
public void handle() throws FacesException {
StringWriter sw = new StringWriter();
PrintWriter pw = new PrintWriter(sw);
final Iterator<ExceptionQueuedEvent> i = getUnhandledExceptionQueuedEvents().iterator();
while (i.hasNext()) {
ExceptionQueuedEvent event = i.next();
ExceptionQueuedEventContext context
= (ExceptionQueuedEventContext) event.getSource();
Throwable t = context.getException();
final FacesContext fc = FacesContext.getCurrentInstance();
final Map<String, Object> requestMap = fc.getExternalContext().getRequestMap();
final NavigationHandler nav = fc.getApplication().getNavigationHandler();
try {
log.log(Level.INFO, "Custom Exception Handler", t);
requestMap.put("exceptionMessage", t.getMessage());
t.printStackTrace(pw);
requestMap.put("exceptionTrace", sw.toString());
nav.handleNavigation(fc, null, "/error");
fc.renderResponse();
} finally {
i.remove();
}
}
getWrapped().handle();
}
示例15: handle
import javax.faces.event.ExceptionQueuedEvent; //导入方法依赖的package包/类
public void handle() throws FacesException {
final Iterator<ExceptionQueuedEvent> i = getUnhandledExceptionQueuedEvents().iterator();
while (i.hasNext()) {
ExceptionQueuedEvent event = i.next();
ExceptionQueuedEventContext context = (ExceptionQueuedEventContext) event.getSource();
Throwable t = context.getException();
final FacesContext fc = FacesContext.getCurrentInstance();
final ExternalContext externalContext = fc.getExternalContext();
final ConfigurableNavigationHandler nav = (ConfigurableNavigationHandler) fc.getApplication().getNavigationHandler();
try {
if (isSecurityException(t)) {
performRedirect(externalContext, "/login");
} else if (isConversationException(t)) {
log.error(t.getMessage(), t);
performRedirect(externalContext, "/conversation_error");
} else {
log.error(t.getMessage(), t);
performRedirect(externalContext, "/error");
}
fc.renderResponse();
} finally {
i.remove();
}
}
getWrapped().handle();
}