Refine search
/** * Processes a SliderEvent. * * @param event the slider event */ public void processSlider(DataFilterSliderEvent event) { FacesContext context = FacesContext.getCurrentInstance(); sliderMethod.invoke(context, new Object[]{event}); }
@Override public String getExpressionString() { return methodBinding.getExpressionString(); }
public MethodInfo invoke() { return new MethodInfo(null, methodBinding.getType(facesContext), null); } });
String expr = binding.getExpressionString(); int idx = expr.indexOf('.'); String target = expr.substring(0, idx).substring(2); String method = t.substring(0, (t.length() - 1)); FacesContext context = FacesContext.getCurrentInstance(); ELContext elContext = context.getELContext(); MethodInfo controlInfo = methodExpression.getMethodInfo(elContext); if (!controlInfo.getName().equals(method)) { return false; ExpressionFactory factory = context.getApplication().getExpressionFactory(); ValueExpression ve = factory.createValueExpression(elContext, "#{" + target + '}', Class type = binding.getType(context); Method[] methods = result.getClass().getMethods(); for (Method meth : methods) { if (meth.getName().equals(method) && type.equals(controlInfo.getReturnType()) && Arrays.equals(meth.getParameterTypes(), controlInfo.getParamTypes())) { return true;
FacesContext facesContext = FacesContext.getCurrentInstance(); if (e.getCause() != null) { FacesMessage facesMessage = new FacesMessage(e.getCause().toString()); facesContext.addMessage(null, facesMessage); Application application = facesContext.getApplication(); MethodBinding binding = actionSource.getAction(); NavigationHandler navHandler = application.getNavigationHandler(); String navBinding = (null != binding) ? binding.getExpressionString() : null; navHandler.handleNavigation(facesContext, navBinding, errorOutcome);
public void broadcast(FacesEvent event) throws AbortProcessingException { super.broadcast(event); if (event instanceof ActionEvent) { FacesContext context = getFacesContext(); MethodBinding mb = getActionListener(); if (mb != null) { mb.invoke(context, new Object[] { event }); } ActionListener listener = context.getApplication() .getActionListener(); if (listener != null) { listener.processAction((ActionEvent) event); } } }
public Object invokeMethod(final FacesContext context, final String expression) throws ELException { MethodBinding methodBinding = context.getApplication().createMethodBinding(expression, null); return methodBinding.invoke(context, null); }
/** * @param event */ protected void broadcastToActionListener(ScrollerActionEvent event) { FacesContext context = getFacesContext(); MethodBinding actionListenerBinding = getActionListener(); if (actionListenerBinding != null) { try { actionListenerBinding.invoke(context, new Object[] {event}); } catch (EvaluationException e) { Throwable cause = e.getCause(); if (cause != null && cause instanceof AbortProcessingException) { throw (AbortProcessingException)cause; } throw e; } } ActionListener defaultActionListener = context.getApplication().getActionListener(); if (defaultActionListener != null) { defaultActionListener.processAction((ActionEvent)event); } }
/** * <p>Returns the "@managed-bean-name" the view controller is registered under. The * assumed mapping will be the same as in core Shale.</p> * * @param context faces context * @param viewId name of the page * @return default managed bean name associated with the view */ protected String getManagedBeanName(FacesContext context, String viewId) { String managedBeanName = null; Object mapper = context.getApplication().getVariableResolver() .resolveVariable(context, VIEW_MAPPER); // is there a view controller mapper if (mapper != null) { StringBuffer el = new StringBuffer(); el.append("#{").append(VIEW_MAPPER).append(".mapViewId").append("}"); MethodBinding mb = context.getApplication() .createMethodBinding(el.toString(), new Class[] {String.class}); managedBeanName = (String) mb.invoke(context, new Object[] {viewId}); } return managedBeanName; }
@SuppressWarnings("deprecation") private void invokeNavigationHandling(FacesContext context, UIComponent source, MethodBinding binding, String outcome) { NavigationHandler navHandler = context.getApplication().getNavigationHandler(); String toFlowDocumentId = (String) source.getAttributes().get(TO_FLOW_DOCUMENT_ID_ATTR_NAME); if (toFlowDocumentId == null) { navHandler.handleNavigation(context, binding != null ? binding.getExpressionString() : null, outcome); } else { navHandler.handleNavigation(context, binding != null ? binding.getExpressionString() : null, outcome, toFlowDocumentId); } }
/** * @throws NullPointerException {@inheritDoc} * @throws AbortProcessingException {@inheritDoc} */ public void processValueChange(ValueChangeEvent actionEvent) throws AbortProcessingException { if (actionEvent == null) { throw new NullPointerException(); } try { FacesContext context = FacesContext.getCurrentInstance(); methodBinding.invoke(context, new Object[] {actionEvent}); } catch (EvaluationException ee) { Throwable cause = this.getExpectedCause(AbortProcessingException.class, ee); if (cause instanceof AbortProcessingException) { throw ((AbortProcessingException) cause); } if (cause instanceof RuntimeException) { throw ((RuntimeException) cause); } throw new IllegalStateException(ee.getMessage()); } }
public void encodeAjax(FacesContext context, UIComponent uiComponent) throws IOException { String parentValue = (String) context.getExternalContext(). getRequestParameterMap().get("parentValue"); ServletResponse response = (ServletResponse) context.getExternalContext().getResponse(); PrintWriter writer = response.getWriter(); StringBuffer xml = new StringBuffer(); MethodBinding mb = ((AjaxChildComboBox) uiComponent).getAjaxSelectItemsMethod(); SelectItem[] options = (SelectItem[]) mb.invoke(context, new Object[]{parentValue}); xml.append("<?xml version=\"1.0\"?>\n"); xml.append("<response>\n"); for (int i = 0; i < options.length; i++) { xml.append(BEGIN_OPTION); xml.append(BEGIN_OPTION_TEXT).append(options[i].getLabel()).append(END_OPTION_TEXT); xml.append(BEGIN_OPTION_VALUE).append(options[i].getValue()).append(END_OPTION_VALUE); xml.append(END_OPTION); } xml.append("</response>"); writer.write(xml.toString()); }
/** * Invoke method binding expression for Shale <code>ActionState</code>. * Shale requires return type to be a <code>java.lang.String</code>. * * @param expr Method binding expression * @return String Method return value * @throws SCXMLExpressionException Re-throw potential Faces * exceptions as a SCXMLExpressionException. */ private String invokeShaleActionStateMethod(final String expr) throws SCXMLExpressionException { try { MethodBinding mb = context.getApplication(). createMethodBinding(expr, SIGNATURE); return (String) mb.invoke(context, PARAMETERS); //Rethrow any exception as SCXMLExpressionException instance } catch (ReferenceSyntaxException rse) { throw new SCXMLExpressionException(rse.getMessage(), rse); } catch (MethodNotFoundException mnfe) { throw new SCXMLExpressionException(mnfe.getMessage(), mnfe); } catch (EvaluationException ee) { throw new SCXMLExpressionException(ee.getMessage(), ee); } }
public Object invoke(final FacesContext facesContext, final Object[] objects) throws EvaluationException { if (LOG.isDebugEnabled()) { LOG.debug("MethodBinding invoke " + getExpressionString()); } // MethodBindings with a argument list would not be checked for authorisation if ((objects!=null && objects.length > 0) || AuthorizationUtils.isAuthorized(facesContext, getExpressionString())) { return methodBinding.invoke(facesContext, objects); } else { // TODO better message facesContext.addMessage(null, new FacesMessage("Not authorised")); return null; } }
public static String invoke(MethodBinding methodBinding, FacesContext context) { try { return (String) methodBinding.invoke(context, null); } catch (EvaluationException e) { Throwable cause = e.getCause(); if (cause != null && cause instanceof AbortProcessingException) { throw (AbortProcessingException) cause; } throw e; } } }
@SuppressWarnings("deprecation") private String getNavigationOutcome(FacesContext context, MethodBinding binding) { if (binding != null) { try { Object invokeResult; if ((invokeResult = binding.invoke(context, null)) != null) { return invokeResult.toString(); } // else, default to null, as returned at the end } catch (MethodNotFoundException e) { if (LOGGER.isLoggable(FINE)) { LOGGER.log(FINE, e.getMessage(), e); } throw new FacesException(binding.getExpressionString() + ": " + e.getMessage(), e); } catch (EvaluationException e) { if (LOGGER.isLoggable(FINE)) { LOGGER.log(FINE, e.getMessage(), e); } throw new FacesException(binding.getExpressionString() + ": " + e.getMessage(), e); } } return null; }
public Object invoke() { return methodBinding.invoke(facesContext, params); } });
public String getAsText() { Object value = getValue(); if (value instanceof MethodBinding) { if (value instanceof ConstantMethodBinding) { return (String) ((MethodBinding) value).invoke(null, null); // Hack to get the constant value } else { return ((MethodBinding) value).getExpressionString(); } } else if (value instanceof MethodExpression) { return ((MethodExpression) value).getExpressionString(); } return (value == null) ? "" : value.toString(); //NOI18N }
public void validate(FacesContext context, UIComponent component, Object value) throws ValidatorException { if (null == context || null == component) { throw new NullPointerException(); } try { methodBinding.invoke(context, new Object[] {context, component, value}); } catch (EvaluationException ee) { Throwable cause = this.getExpectedCause(ValidatorException.class, ee); if (cause instanceof ValidatorException) { throw ((ValidatorException) cause); } if (cause instanceof RuntimeException) { throw ((RuntimeException) cause); } throw new IllegalStateException(ee.getMessage()); } }
public Class getType(FacesContext context) throws MethodNotFoundException { if (original == null) { return null; } return original.getType(context); }