List of usage examples for javax.el MethodExpression invoke
public abstract Object invoke(ELContext context, Object[] params);
From source file:org.ajax4jsf.component.AjaxViewRoot.java
/** * Send notification to a view-scope phase listeners. * /* w w w . ja va 2s . co m*/ * @param context * @param phase * @param before */ protected void processPhaseListeners(FacesContext context, PhaseId phase, boolean before) { MethodExpression listenerExpression = before ? getBeforePhaseListener() : getAfterPhaseListener(); PhaseEvent event = null; if (null != listenerExpression) { event = createPhaseEvent(context, phase); listenerExpression.invoke(context.getELContext(), new Object[] { event }); } if (null != this.phaseListeners) { for (PhaseListener listener : phaseListeners) { PhaseId phaseId = listener.getPhaseId(); if (phaseId == phase || phaseId == PhaseId.ANY_PHASE) { if (null == event) { event = createPhaseEvent(context, phase); } if (before) { listener.beforePhase(event); } else { listener.afterPhase(event); } } } } }
From source file:org.richfaces.component.UICalendar.java
public void broadcast(FacesEvent event) throws AbortProcessingException { // TODO Auto-generated method stub if (event instanceof AjaxEvent) { FacesContext facesContext = FacesContext.getCurrentInstance(); AjaxContext ajaxContext = AjaxContext.getCurrentInstance(facesContext); ajaxContext.addRegionsFromComponent(this); if (getPreload() != null) { ajaxContext.setResponseData(getPreload()); }/*from w w w .j av a 2 s . com*/ } else { if (event instanceof CurrentDateChangeEvent) { FacesContext facesContext = getFacesContext(); CurrentDateChangeEvent dateChangeEvent = (CurrentDateChangeEvent) event; String currentDateString = dateChangeEvent.getCurrentDateString(); // if currentDateString is not null then event cames from // apply request phase try { // XXX nick - kaa - we should use datePattern // attribute-based converter only for selectedDate // current date string always has predefined format: m/y // review // org.richfaces.renderkit.CalendarRendererBase.convertCurrentDate(String) // method // for more // XX nick - kaa - throw exception and review resulting // message :) Date currentDate = getAsDate(getCurrentDate()); Date submittedCurrentDate = convertCurrentDate(currentDateString); dateChangeEvent.setCurrentDate(submittedCurrentDate); if (!submittedCurrentDate.equals(currentDate)) { updateCurrentDate(facesContext, submittedCurrentDate); MethodExpression methodExpression = getCurrentDateChangeListener(); if (methodExpression != null) { methodExpression.invoke(facesContext.getELContext(), new Object[] { dateChangeEvent }); } } } catch (Exception e) { // XXX nick - kaa - add log.debug(...) // XXX nick - kaa - we should stop processing on exc. // setValid(false) and then call // FacesContext.renderResponse(...) // update model phase shouldn't start if (log.isDebugEnabled()) { log.debug(" currentDate convertion fails with following exception: " + e.toString(), e); } setValid(false); String messageString = e.toString(); e.printStackTrace(); FacesMessage message = new FacesMessage(messageString); message.setSeverity(FacesMessage.SEVERITY_ERROR); facesContext.addMessage(getClientId(facesContext), message); facesContext.renderResponse(); } } else { super.broadcast(event); } } }
From source file:org.operamasks.faces.render.graph.ChartRenderer.java
protected void initChart(JFreeChart chart, UIChart comp) { setChartStyles(chart, comp);//from w ww.j av a 2s . com setLegendStyles(chart, comp); setChartTitles(chart, comp); setChartAxes(chart, comp); createCurveSeries(chart, comp); setSeriesStyles(chart, comp); addTextAnnotations(chart, comp); setToolTipGenerator(chart, comp); MethodExpression init = comp.getInit(); if (init != null) { ELContext context = FacesContext.getCurrentInstance().getELContext(); init.invoke(context, new Object[] { chart }); } }
From source file:com.googlecode.jsfFlex.component.ext.AbstractFlexUIDataGrid.java
private Boolean invokeFilterMethod(String currRowValue, String filterValue) { Boolean toFilter = false;/* w w w. j a v a 2s .c o m*/ MethodExpression userProvidedFilterMethod = getAsynchronousEventFilterGlueHandler(); if (userProvidedFilterMethod != null) { FacesContext context = FacesContext.getCurrentInstance(); toFilter = Boolean .valueOf( userProvidedFilterMethod .invoke(context.getELContext(), new Object[] { new AsynchronousFilterEvent(this, currRowValue, filterValue) }) .toString()); } else { toFilter = defaultFilterMethod(new AsynchronousFilterEvent(this, currRowValue, filterValue)); } return toFilter; }