javax.faces.FacesException Java Examples
The following examples show how to use
javax.faces.FacesException.
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: ExceptionHandler.java From development with Apache License 2.0 | 6 votes |
/** * Convert a EJBException into FacesMessage which is presented to the user. * * @param ex * the EJBException to be analyzed */ public static void execute(EJBException ex) { if (ex != null && ex.getCause() instanceof Exception && ex.getCausedByException() instanceof AccessException) { handleOrganizationAuthoritiesException(); } else if (ex != null && isInvalidUserSession(ex)) { HttpServletRequest request = JSFUtils.getRequest(); request.getSession().removeAttribute(Constants.SESS_ATTR_USER); request.getSession().invalidate(); handleInvalidSession(); } else if (ex != null && isConnectionException(ex)) { handleMissingConnect(BaseBean.ERROR_DATABASE_NOT_AVAILABLE); } else { throw new FacesException(ex); } }
Example #2
Source File: RequestBean.java From yawl with GNU Lesser General Public License v3.0 | 6 votes |
/** * <p>This method is called when this bean is initially added to * request scope. Typically, this occurs as a result of evaluating * a value binding or method binding expression, which utilizes the * managed bean facility to instantiate this bean and store it into * request scope.</p> * * <p>You may customize this method to allocate resources that are required * for the lifetime of the current request.</p> */ public void init() { // Perform initializations inherited from our superclass super.init(); // Perform application initialization that must complete // *before* managed components are initialized // TODO - add your own initialiation code here // <editor-fold defaultstate="collapsed" desc="Creator-managed Component Initialization"> // Initialize automatically managed components // *Note* - this logic should NOT be modified try { _init(); } catch (Exception e) { log("RequestBean1 Initialization Failure", e); throw e instanceof FacesException ? (FacesException) e: new FacesException(e); } // </editor-fold> // Perform application initialization that must complete // *after* managed components are initialized // TODO - add your own initialization code here }
Example #3
Source File: SakaiViewHandlerWrapper.java From sakai with Educational Community License v2.0 | 6 votes |
public void renderView(FacesContext context, UIViewRoot root) throws IOException, FacesException { // SAK-20286 start // Get the request HttpServletRequest req = (HttpServletRequest) context.getExternalContext().getRequest(); String requestURI = req.getRequestURI(); // Make the attribute name unique to the request String attrName = "sakai.jsf.tool.URL.loopDetect.viewId-" + requestURI; // Try to fetch the attribute Object attribute = req.getAttribute(attrName); // If the attribute is null, this is the first request for this view if (attribute == null) { req.setAttribute(attrName, "true"); } else if ("true".equals(attribute)) { // A looping request is detected. HttpServletResponse res = (HttpServletResponse) context.getExternalContext().getResponse(); // Send a 404 res.sendError(404, "File not found: " + requestURI); } // SAK-20286 end getWrapped().renderView(context, root); }
Example #4
Source File: SakaiViewHandler.java From sakai with Educational Community License v2.0 | 6 votes |
public void renderView(FacesContext context, UIViewRoot root) throws IOException, FacesException { // SAK-20286 start // Get the request HttpServletRequest req = (HttpServletRequest) context.getExternalContext().getRequest(); String requestURI = req.getRequestURI(); // Make the attribute name unique to the request String attrName = "sakai.jsf.tool.URL.loopDetect.viewId-" + requestURI; // Try to fetch the attribute Object attribute = req.getAttribute(attrName); // If the attribute is null, this is the first request for this view if (attribute == null) { req.setAttribute(attrName, "true"); } else if ("true".equals(attribute)) { // A looping request is detected. HttpServletResponse res = (HttpServletResponse) context.getExternalContext().getResponse(); // Send a 404 res.sendError(404, "File not found: " + requestURI); } // SAK-20286 end m_wrapped.renderView(context, root); }
Example #5
Source File: SakaiViewHandlerWrapper.java From sakai with Educational Community License v2.0 | 6 votes |
public void renderView(FacesContext context, UIViewRoot root) throws IOException, FacesException { // SAK-20286 start // Get the request HttpServletRequest req = (HttpServletRequest) context.getExternalContext().getRequest(); String requestURI = req.getRequestURI(); // Make the attribute name unique to the request String attrName = "sakai.jsf.tool.URL.loopDetect.viewId-" + requestURI; // Try to fetch the attribute Object attribute = req.getAttribute(attrName); // If the attribute is null, this is the first request for this view if (attribute == null) { req.setAttribute(attrName, "true"); } else if ("true".equals(attribute)) { // A looping request is detected. HttpServletResponse res = (HttpServletResponse) context.getExternalContext().getResponse(); // Send a 404 res.sendError(404, "File not found: " + requestURI); } // SAK-20286 end getWrapped().renderView(context, root); }
Example #6
Source File: Captcha.java From ctsms with GNU Lesser General Public License v2.1 | 6 votes |
private String createPostParameters(FacesContext facesContext, Verification verification) throws UnsupportedEncodingException { String remoteAddress = ((HttpServletRequest) facesContext.getExternalContext().getRequest()).getRemoteAddr(); String privateKey = Settings.getString(SettingCodes.PRIVATE_CAPTCHA_KEY, Bundle.SETTINGS, DefaultSettings.PRIVATE_CAPTCHA_KEY); if (privateKey == null || privateKey.length() == 0) { throw new FacesException("Cannot find private key for catpcha, use PRIVATE_CAPTCHA_KEY property to define one"); } StringBuilder postParams = new StringBuilder(); if (ReCaptchaVersions.V1.equals(RECAPTCHA_VERSION)) { postParams.append("privatekey=").append(URLEncoder.encode(privateKey, "UTF-8")); postParams.append("&challenge=").append(URLEncoder.encode(verification.getChallenge(), "UTF-8")); postParams.append("&response=").append(URLEncoder.encode(verification.getAnswer(), "UTF-8")); } else if (ReCaptchaVersions.V2.equals(RECAPTCHA_VERSION)) { postParams.append("secret=").append(URLEncoder.encode(privateKey, "UTF-8")); postParams.append("&response=").append(URLEncoder.encode(verification.getToken(), "UTF-8")); } else { throw new FacesException("reCAPTCHA version not supported"); } postParams.append("&remoteip=").append(URLEncoder.encode(remoteAddress, "UTF-8")); return postParams.toString(); }
Example #7
Source File: UndefinedExceptionHandler.java From library with Apache License 2.0 | 6 votes |
/** * {@inheritDoc} * * @param context * @param exception */ @Override public void handle(FacesContext context, Throwable exception) { final HttpServletRequest request = (HttpServletRequest) context.getExternalContext().getRequest(); request.setAttribute(ERROR_EXCEPTION + "_stacktrace", exception); if (context.getCurrentPhaseId() == PhaseId.RENDER_RESPONSE) { throw new FacesException(exception); } request.setAttribute(ERROR_EXCEPTION_TYPE, exception.getClass().getName()); request.setAttribute(ERROR_MESSAGE, exception.getMessage()); request.setAttribute(ERROR_REQUEST_URI, request.getHeader("Referer")); request.setAttribute(ERROR_STATUS_CODE, HttpServletResponse.SC_INTERNAL_SERVER_ERROR); final String errorPage = this.getErrorPage(exception); context.getApplication().getNavigationHandler().handleNavigation(context, null, errorPage); context.renderResponse(); }
Example #8
Source File: FaceletsTaglibConfigProcessor.java From netbeans with Apache License 2.0 | 6 votes |
private void processSource(Element documentElement, Node source, TagLibraryImpl taglibrary, String name) { String docURI = documentElement.getOwnerDocument().getDocumentURI(); String s = getNodeText(source); //mfukala: fix possible NPE from the code below if <source> element is empty and the getNodeText() returns null if(s == null) { return ; //just ignre that entry } try { URL url = new URL(new URL(docURI), s); taglibrary.putUserTag(name, url); } catch (MalformedURLException e) { throw new FacesException(e); } }
Example #9
Source File: ConfigManager.java From netbeans with Apache License 2.0 | 6 votes |
/** * @return the results of the annotation scan task */ public static Map<Class<? extends Annotation>,Set<Class<?>>> getAnnotatedClasses(FacesContext ctx) { Map<String, Object> appMap = ctx.getExternalContext().getApplicationMap(); //noinspection unchecked Future<Map<Class<? extends Annotation>,Set<Class<?>>>> scanTask = (Future<Map<Class<? extends Annotation>,Set<Class<?>>>>) appMap.get(ANNOTATIONS_SCAN_TASK_KEY); try { return ((scanTask != null) ? scanTask.get() : Collections.<Class<? extends Annotation>,Set<Class<?>>>emptyMap()); } catch (Exception e) { throw new FacesException(e); } }
Example #10
Source File: UndefinedExceptionHandler.java From web-budget with GNU General Public License v3.0 | 6 votes |
/** * {@inheritDoc} * * @param context * @param exception */ @Override public void handle(FacesContext context, Throwable exception) { final HttpServletRequest request = (HttpServletRequest) context.getExternalContext().getRequest(); request.setAttribute(ERROR_EXCEPTION + "_stacktrace", exception); if (context.getCurrentPhaseId() == PhaseId.RENDER_RESPONSE) { throw new FacesException(exception); } request.setAttribute(ERROR_EXCEPTION_TYPE, exception.getClass().getName()); request.setAttribute(ERROR_MESSAGE, exception.getMessage()); request.setAttribute(ERROR_REQUEST_URI, request.getHeader("Referer")); request.setAttribute(ERROR_STATUS_CODE, HttpServletResponse.SC_INTERNAL_SERVER_ERROR); final String errorPage = this.getErrorPage(exception); context.getApplication().getNavigationHandler().handleNavigation(context, null, errorPage); context.renderResponse(); }
Example #11
Source File: ViewExpiredExceptionExceptionHandler.java From journaldev with MIT License | 6 votes |
@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(); }
Example #12
Source File: nonHumanMgt.java From yawl with GNU Lesser General Public License v3.0 | 5 votes |
public void init() { super.init(); try { _init(); } catch (Exception e) { log("NonHumanResource Management Initialization Failure", e); throw e instanceof FacesException ? (FacesException) e: new FacesException(e); } }
Example #13
Source File: dynForm.java From yawl with GNU Lesser General Public License v3.0 | 5 votes |
public void init() { super.init(); // *Note* - JSF requirement this block should NOT be modified try { _init(); } catch (Exception e) { log("dynForm Initialization Failure", e); throw e instanceof FacesException ? (FacesException) e: new FacesException(e); } }
Example #14
Source File: participantData.java From yawl with GNU Lesser General Public License v3.0 | 5 votes |
public void init() { super.init(); // *Note* - this code should NOT be modified try { _init(); } catch (Exception e) { log("participantData Initialization Failure", e); throw e instanceof FacesException ? (FacesException) e: new FacesException(e); } }
Example #15
Source File: customServices.java From yawl with GNU Lesser General Public License v3.0 | 5 votes |
public void init() { super.init(); try { _init(); } catch (Exception e) { log("customServices Initialization Failure", e); throw e instanceof FacesException ? (FacesException) e: new FacesException(e); } }
Example #16
Source File: externalClients.java From yawl with GNU Lesser General Public License v3.0 | 5 votes |
public void init() { super.init(); try { _init(); } catch (Exception e) { log("customServices Initialization Failure", e); throw e instanceof FacesException ? (FacesException) e: new FacesException(e); } }
Example #17
Source File: adminQueues.java From yawl with GNU Lesser General Public License v3.0 | 5 votes |
public void init() { super.init(); // *Note* - this logic should NOT be modified try { _init(); } catch (Exception e) { log("userWorkQueues Initialization Failure", e); throw e instanceof FacesException ? (FacesException) e: new FacesException(e); } }
Example #18
Source File: ApplicationBean.java From yawl with GNU Lesser General Public License v3.0 | 5 votes |
public void init() { super.init(); // Initialize automatically managed components - do not modify try { _init(); } catch (Exception e) { log("ApplicationBean Initialization Failure", e); throw e instanceof FacesException ? (FacesException) e : new FacesException(e); } // Add init code here that must complete *after* managed components are initialized _rm.registerJSFApplicationReference(this); }
Example #19
Source File: userWorkQueues.java From yawl with GNU Lesser General Public License v3.0 | 5 votes |
public void init() { super.init(); // *Note* - this logic should NOT be modified try { _init(); } catch (Exception e) { log("userWorkQueues Initialization Failure", e); throw e instanceof FacesException ? (FacesException) e : new FacesException(e); } }
Example #20
Source File: selectUser.java From yawl with GNU Lesser General Public License v3.0 | 5 votes |
public void init() { super.init(); // *Note* - this logic should NOT be modified try { _init(); } catch (Exception e) { log("selectUser Initialization Failure", e); throw e instanceof FacesException ? (FacesException) e: new FacesException(e); } }
Example #21
Source File: pfMenubar.java From yawl with GNU Lesser General Public License v3.0 | 5 votes |
public void init() { super.init(); // *Note* - this code should NOT be modified try { _init(); } catch (Exception e) { log("pfMenu Initialization Failure", e); throw e instanceof FacesException ? (FacesException) e: new FacesException(e); } }
Example #22
Source File: TemplateBaseListener.java From sakai with Educational Community License v2.0 | 5 votes |
/** * Helper method to look up template backing bean. * @param context the faces context * @return the backing bean * @throws FacesException */ protected TemplateBean lookupTemplateBean(FacesContext context) throws FacesException { TemplateBean templateBean; //FacesContext facesContext = FacesContext.getCurrentInstance(); ApplicationFactory factory = (ApplicationFactory) FactoryFinder.getFactory( FactoryFinder.APPLICATION_FACTORY); Application application = factory.getApplication(); templateBean = (TemplateBean) application.getVariableResolver().resolveVariable(context, "template"); return templateBean; }
Example #23
Source File: orgDataMgt.java From yawl with GNU Lesser General Public License v3.0 | 5 votes |
public void init() { super.init(); try { _init(); } catch (Exception e) { log("userWorkQueues Initialization Failure", e); throw e instanceof FacesException ? (FacesException) e: new FacesException(e); } }
Example #24
Source File: ExceptionHandler.java From development with Apache License 2.0 | 5 votes |
public static boolean execute(FacesException exc) { boolean handled = false; SaaSApplicationException saasE = getSaasApplicationException(exc); EJBException ejbException = getEJBException(exc); if (saasE != null) { execute(saasE); handled = true; } else if (ejbException != null) { execute(ejbException); handled = true; } return handled; }
Example #25
Source File: ApplicationBean.java From yawl with GNU Lesser General Public License v3.0 | 5 votes |
public void init() { super.init(); // Initialize automatically managed components - do not modify try { _init(); } catch (Exception e) { log("ApplicationBean Initialization Failure", e); throw e instanceof FacesException ? (FacesException) e: new FacesException(e); } // Add init code here that must complete *after* managed components are initialized }
Example #26
Source File: pfAddRemove.java From yawl with GNU Lesser General Public License v3.0 | 5 votes |
public void init() { super.init(); // *Note* - this logic should NOT be modified try { _init(); } catch (Exception e) { log("pfAddRemove Initialization Failure", e); throw e instanceof FacesException ? (FacesException) e: new FacesException(e); } }
Example #27
Source File: rssFormViewer.java From yawl with GNU Lesser General Public License v3.0 | 5 votes |
public void init() { super.init(); // *Note* - this code must not be modified try { _init(); } catch (Exception e) { log("Page1 Initialization Failure", e); throw e instanceof FacesException ? (FacesException) e: new FacesException(e); } }
Example #28
Source File: BusinessLogicExceptionHandler.java From web-budget with GNU General Public License v3.0 | 5 votes |
/** * {@inheritDoc} * * @param context * @param exception */ @Override public void handle(FacesContext context, BusinessLogicException exception) { if (context.getCurrentPhaseId() == PhaseId.RENDER_RESPONSE) { throw new FacesException(exception); } final String i18nMessage = MessageSource.get(exception.getMessage()); FacesUtils.clearMessages(context); Messages.add(FacesMessage.SEVERITY_ERROR, null, i18nMessage, exception.getParameters()); context.renderResponse(); }
Example #29
Source File: pfOrgData.java From yawl with GNU Lesser General Public License v3.0 | 5 votes |
public void init() { // Perform initializations inherited from our superclass super.init(); // *Note* - this logic should NOT be modified try { _init(); } catch (Exception e) { log("pfQueueUI Initialization Failure", e); throw e instanceof FacesException ? (FacesException) e: new FacesException(e); } }
Example #30
Source File: pfNHResources.java From yawl with GNU Lesser General Public License v3.0 | 5 votes |
public void init() { // Perform initializations inherited from our superclass super.init(); // *Note* - this logic should NOT be modified try { _init(); } catch (Exception e) { log("pfNHResources Initialization Failure", e); throw e instanceof FacesException ? (FacesException) e: new FacesException(e); } }