public void updateModel(FacesContext facesContext) { if (facesContext == null) { throw new NullPointerException(); } if (!isValid() || !isLocalValueSet()) { return; } ValueExpression ve = getValueExpression("value"); if (ve == null) { return; } Throwable caught = null; FacesMessage message = null; try { ve.setValue(facesContext.getELContext(), getLocalValue()); setValue(null); setLocalValueSet(false); } catch (ELException e) { caught = e; String messageStr = e.getMessage(); Throwable result = e.getCause(); while (null != result && result.getClass().isAssignableFrom(ELException.class)) { messageStr = result.getMessage(); result = result.getCause(); } if (messageStr == null) { message = ServiceTracker.getService(MessageFactory.class) .createMessage( facesContext, FacesMessage.SEVERITY_ERROR, FacesMessages.UIINPUT_UPDATE, MessageUtil.getLabel(facesContext, this)); } else { message = new FacesMessage(FacesMessage.SEVERITY_ERROR, messageStr, messageStr); } setValid(false); } catch (Exception e) { caught = e; // message = MessageFactory.getMessage(facesContext, UPDATE_MESSAGE_ID, // MessageFactory.getHeader(facesContext, this)); setValid(false); } if (caught != null) { assert message != null; @SuppressWarnings({"ThrowableInstanceNeverThrown"}) UpdateModelException toQueue = new UpdateModelException(message, caught); ExceptionQueuedEventContext eventContext = new ExceptionQueuedEventContext(facesContext, toQueue, this, PhaseId.UPDATE_MODEL_VALUES); facesContext .getApplication() .publishEvent(facesContext, ExceptionQueuedEvent.class, eventContext); } }
@Override public Class getType(FacesContext context) throws EvaluationException, PropertyNotFoundException { ELContext ctx = context.getELContext(); try { return this.delegate.getType(ctx); } catch (javax.el.PropertyNotFoundException e) { throw new PropertyNotFoundException(e.getMessage(), e.getCause()); } catch (ELException e) { throw new EvaluationException(e.getMessage(), e.getCause()); } }
/** * @throws NullPointerException {@inheritDoc} * @throws ValidatorException {@inheritDoc} */ public void validate(FacesContext context, UIComponent component, Object value) throws ValidatorException { if ((context == null) || (component == null)) { throw new NullPointerException(); } if (value != null) { try { ELContext elContext = context.getELContext(); methodExpression.invoke(elContext, new Object[] {context, component, value}); } catch (ELException ee) { Throwable e = ee.getCause(); if (e instanceof ValidatorException) { throw (ValidatorException) e; } String errInfo = ee.getMessage(); FacesMessage message = new FacesMessage(FacesMessage.SEVERITY_ERROR, errInfo, errInfo); throw new ValidatorException(message, ee.getCause()); } } }
@Override public void setValue(FacesContext context, Object value) throws EvaluationException, PropertyNotFoundException { ELContext ctx = context.getELContext(); try { this.delegate.setValue(ctx, value); } catch (PropertyNotWritableException | javax.el.PropertyNotFoundException e) { throw new PropertyNotFoundException(e.getMessage(), e.getCause()); } catch (ELException e) { throw new EvaluationException(e.getMessage(), e.getCause()); } }
/** * <span class="changed_modified_2_0 changed_modified_2_2">Call</span> through to the {@link * MethodExpression} passed in our constructor. <span class="changed_added_2_0">First, try to * invoke the <code>MethodExpression</code> passed to the constructor of this instance, passing * the argument {@link ActionEvent} as the argument. If a {@link MethodNotFoundException} is * thrown, call to the zero argument <code>MethodExpression</code> derived from the <code> * MethodExpression</code> passed to the constructor of this instance. <span * class="changed_deleted_2_2">If that fails for any reason, throw an {@link * AbortProcessingException}, including the cause of the failure.</span></span> * * @throws NullPointerException {@inheritDoc} * @throws AbortProcessingException {@inheritDoc} */ @Override public void processAction(ActionEvent actionEvent) throws AbortProcessingException { if (actionEvent == null) { throw new NullPointerException(); } FacesContext context = FacesContext.getCurrentInstance(); ELContext elContext = context.getELContext(); try { try { methodExpressionOneArg.invoke(elContext, new Object[] {actionEvent}); } catch (MethodNotFoundException mnfe) { methodExpressionZeroArg.invoke(elContext, new Object[] {}); } } catch (ELException ee) { if (ee.getCause() instanceof AbortProcessingException) { throw (AbortProcessingException) ee.getCause(); } else { throw (ELException) ee; } } }
private void updateModel(int newPage) { FacesContext facesContext = getFacesContext(); UIComponent dataTable = getDataTable(); if (isRendered(dataTable)) { dataTable.getAttributes().put("first", (newPage - 1) * getRows(dataTable)); } Map<String, Object> attributes = dataTable.getAttributes(); attributes.put(dataTable.getClientId(facesContext) + SCROLLER_STATE_ATTRIBUTE, newPage); ValueExpression ve = getValueExpression("page"); if (ve != null) { try { ve.setValue(facesContext.getELContext(), newPage); attributes.remove(dataTable.getClientId(facesContext) + SCROLLER_STATE_ATTRIBUTE); } catch (ELException e) { String messageStr = e.getMessage(); Throwable result = e.getCause(); while (null != result && result.getClass().isAssignableFrom(ELException.class)) { messageStr = result.getMessage(); result = result.getCause(); } FacesMessage message; if (null == messageStr) { message = ServiceTracker.getService(MessageFactory.class) .createMessage( facesContext, FacesMessages.UIINPUT_UPDATE, MessageUtil.getLabel(facesContext, this)); } else { message = new FacesMessage(FacesMessage.SEVERITY_ERROR, messageStr, messageStr); } facesContext.getExternalContext().log(message.getSummary(), result); facesContext.addMessage(getClientId(facesContext), message); facesContext.renderResponse(); } catch (IllegalArgumentException e) { FacesMessage message = ServiceTracker.getService(MessageFactory.class) .createMessage( facesContext, FacesMessages.UIINPUT_UPDATE, MessageUtil.getLabel(facesContext, this)); facesContext.getExternalContext().log(message.getSummary(), e); facesContext.addMessage(getClientId(facesContext), message); facesContext.renderResponse(); } catch (Exception e) { FacesMessage message = ServiceTracker.getService(MessageFactory.class) .createMessage( facesContext, FacesMessages.UIINPUT_UPDATE, MessageUtil.getLabel(facesContext, this)); facesContext.getExternalContext().log(message.getSummary(), e); facesContext.addMessage(getClientId(facesContext), message); facesContext.renderResponse(); } } }