List of usage examples for javax.el ValueExpression getValue
public abstract Object getValue(ELContext context);
From source file:com.flexive.faces.renderer.FxSelectRenderer.java
/** * Convert SelectManys value to the correct value classes * * @param context faces context//from w ww .j ava2 s.com * @param uiSelectMany the select many component * @param newValues the new values to convert * @return converted values * @throws ConverterException on errors */ public Object convertSelectManyValue(FacesContext context, UISelectMany uiSelectMany, String[] newValues) throws ConverterException { // if we have no local value, try to get the valueExpression. ValueExpression valueExpression = uiSelectMany.getValueExpression("value"); Object result = newValues; // default case, set local value boolean throwException = false; // If we have a ValueExpression if (null != valueExpression) { Class modelType = valueExpression.getType(context.getELContext()); // Does the valueExpression resolve properly to something with // a type? if (modelType != null) result = convertSelectManyValuesForModel(context, uiSelectMany, modelType, newValues); // If it could not be converted, as a fall back try the type of // the valueExpression's current value covering some edge cases such // as where the current value came from a Map. if (result == null) { Object value = valueExpression.getValue(context.getELContext()); if (value != null) result = convertSelectManyValuesForModel(context, uiSelectMany, value.getClass(), newValues); } if (result == null) throwException = true; } else { // No ValueExpression, just use Object array. result = convertSelectManyValues(context, uiSelectMany, Object[].class, newValues); } if (throwException) { StringBuffer values = new StringBuffer(); if (null != newValues) { for (int i = 0; i < newValues.length; i++) { if (i == 0) values.append(newValues[i]); else values.append(' ').append(newValues[i]); } } throw new ConverterException("Error converting expression [" + valueExpression.getExpressionString() + "] of " + String.valueOf(values)); } return result; }
From source file:org.ajax4jsf.component.UIDataAdaptor.java
@SuppressWarnings("unchecked") public Set<Object> getAjaxKeys() { Set<Object> keys = null; if (this._ajaxKeys != null) { keys = (this._ajaxKeys); } else {/*from w w w .j a va2 s . c o m*/ ValueExpression vb = getValueExpression("ajaxKeys"); if (vb != null) { keys = (Set<Object>) (vb.getValue(getFacesContext().getELContext())); } else if (null != _ajaxRowKey) { // If none of above exist , use row with submitted AjaxComponent keys = new HashSet<Object>(1); keys.add(_ajaxRowKey); } } return keys; }
From source file:org.ajax4jsf.component.UIDataAdaptor.java
/** * @return the rowKeyConverter/*from ww w. ja v a2 s. c o m*/ */ public Converter getRowKeyConverter() { Converter converter = _rowKeyConverter; if (null == converter) { ValueExpression ve = getValueExpression("rowKeyConverter"); if (null != ve) { converter = (Converter) ve.getValue(getFacesContext().getELContext()); } } return converter; }
From source file:org.openfaces.component.table.impl.TableDataModel.java
private int requestNonPagedRowCount() { AbstractTable table = getTable();// w ww .j a va 2 s . c o m setFilteringCriteriaToRequestVariable(); if (!table.getRowsDecodingRequired()) { return table.getTotalRowCount() == null ? 0 : table.getTotalRowCount(); } ValueExpression valueExpression = table.getValueExpression("totalRowCount"); if (valueExpression == null) throw new IllegalStateException( "totalRowCount must be defined for pagination with custom data providing to work. table id = " + table.getClientId(FacesContext.getCurrentInstance())); Object value = valueExpression.getValue(FacesContext.getCurrentInstance().getELContext()); Components.restoreRequestVariable(VAR_FILTER_CRITERIA); if (!(value instanceof Integer)) throw new IllegalStateException("totalRowCount must return an int (or Integer) number, but returned: " + (value != null ? value.getClass().getName() : "null") + "; table id = " + table.getClientId(FacesContext.getCurrentInstance())); return (Integer) value; }
From source file:org.jbuilt.components.html.raw.base.AbstractInputComponent.java
@Override public boolean isImmediate() { if (this.immediate != null) { return this.immediate; }// ww w . j a v a 2 s . c om ValueExpression ve = getValueExpression("immediate"); if (ve != null) { try { return Boolean.TRUE.equals(ve.getValue(getFacesContext().getELContext())); } catch (ELException e) { throw new FacesException(e); } } else { return false; } }
From source file:com.lassitercg.faces.components.sheet.Sheet.java
public String getComment(FacesContext context, Object rowKey, int col) { RowColIndex index = new RowColIndex(rowKey, col); if (!comments.containsKey(index)) { final Column column = getColumns().get(col); ValueExpression valueExpression = column.getValueExpression("comment"); return (valueExpression == null) ? null : (String) valueExpression.getValue(context.getELContext()); }/*from ww w .j av a 2s. co m*/ return comments.get(index); }
From source file:org.ajax4jsf.component.UIDataAdaptor.java
/** * @return current state of this component. *//*from w w w .j av a2s . c o m*/ public DataComponentState getComponentState() { DataComponentState state = null; if (this._currentState == null) { // Check for binding state to user bean. ValueExpression valueBinding = getValueExpression(UIDataAdaptor.COMPONENT_STATE_ATTRIBUTE); FacesContext facesContext = getFacesContext(); ELContext elContext = facesContext.getELContext(); if (null != valueBinding) { state = (DataComponentState) valueBinding.getValue(elContext); if (null == state) { // Create default state state = createComponentState(); if (!valueBinding.isReadOnly(elContext)) { // Store created state in user bean. valueBinding.setValue(elContext, state); } } } else { // Check for stored state in map for parent iterations String baseClientId = getBaseClientId(facesContext); state = (DataComponentState) this._statesMap.get(baseClientId); if (null == state) { // Create default component state state = createComponentState(); this._statesMap.put(baseClientId, state); } this._currentState = state; } } else { state = this._currentState; } return state; }
From source file:org.openfaces.component.table.AbstractTable.java
protected void updateSortingFromBindings() { TableDataModel model = getModel();/* w w w .j av a 2 s. co m*/ model.startUpdate(); try { FacesContext facesContext = getFacesContext(); ValueExpression sortAscendingExpression = getValueExpression("sortAscending"); ELContext elContext = facesContext.getELContext(); if (sortAscendingExpression != null) { Object sortAscendingObj = sortAscendingExpression.getValue(elContext); if (!(sortAscendingObj instanceof Boolean)) throw new IllegalArgumentException( "Illegal value returned from the 'sortAscending' attribute binding of DataTable orTreeTable with client-id (" + getClientId(facesContext) + "). " + "It should be an instance of java.lang.Boolean, but was: " + (sortAscendingObj != null ? sortAscendingObj.getClass().getName() : "null")); boolean newSortAscending = (Boolean) sortAscendingObj; if (isSortAscending() != newSortAscending) setSortAscending(newSortAscending); } ValueExpression sortColumnIdExpression = getValueExpression("sortColumnId"); if (sortColumnIdExpression != null) { Object sortColumnIdObj = sortColumnIdExpression.getValue(elContext); if (sortColumnIdObj != null && !(sortColumnIdObj instanceof String)) throw new IllegalArgumentException( "Illegal value returned from the 'sortColumnId' attribute binding of DataTable or TreeTable with client-id (" + getClientId(facesContext) + "). " + "It should be an instance of java.lang.String, but was: " + sortColumnIdObj.getClass().getName()); String newSortColumnId = (String) sortColumnIdObj; String oldSortColumnId = getSortColumnId(); if (((newSortColumnId == null) != (oldSortColumnId == null)) || (newSortColumnId != null && !newSortColumnId.equals(oldSortColumnId))) setSortColumnId(newSortColumnId); } } finally { model.endUpdate(); } }
From source file:org.openfaces.component.table.AbstractTable.java
protected Comparator<Object> createRuleComparator(final FacesContext facesContext, SortingRule rule) { String sortedColumnId = rule.getSortColumnId(); if (sortedColumnId == null) return null; List<BaseColumn> allColumns = getAllColumns(); BaseColumn column = findColumnById(allColumns, sortedColumnId); boolean ordinaryColumn = column instanceof Column; if (column == null || !(ordinaryColumn || column instanceof CheckboxColumn || column instanceof SelectionColumn)) return null; ValueExpression sortingExpression;/*from w ww. ja v a2s. c o m*/ if (ordinaryColumn) { Column tableColumn = (Column) column; sortingExpression = tableColumn.getSortingExpression(); } else { sortingExpression = itemSelectedExpressionForColumn(column); } if (sortingExpression == null) return null; ValueExpression sortingComparatorBinding = ordinaryColumn ? ((Column) column).getSortingComparatorBinding() : null; Comparator<Object> comparator = sortingComparatorBinding != null ? (Comparator<Object>) sortingComparatorBinding.getValue(facesContext.getELContext()) : null; Map<String, Object> requestMap = facesContext.getExternalContext().getRequestMap(); boolean sortAscending = rule.isSortAscending(); return createRowComparator(facesContext, sortingExpression, comparator, requestMap, sortAscending); }
From source file:com.lassitercg.faces.components.sheet.Sheet.java
/** * Gets the rowKey for the current row/*from www . ja v a 2s. c o m*/ * <p> * @param context * the faces context * @return a row key value or null if the expression is not set */ protected Object getRowKeyValue(FacesContext context) { ValueExpression veRowKey = getValueExpression(PropertyKeys.rowKey.name()); if (veRowKey == null) throw new RuntimeException("RowKey required on sheet!"); Object value = veRowKey.getValue(context.getELContext()); if (value == null) throw new RuntimeException("RowKey must resolve to non-null valkue for updates to work properly"); return value; }