Example usage for javax.el ValueExpression isReadOnly

List of usage examples for javax.el ValueExpression isReadOnly

Introduction

In this page you can find the example usage for javax.el ValueExpression isReadOnly.

Prototype

public abstract boolean isReadOnly(ELContext context);

Source Link

Usage

From source file:org.ajax4jsf.component.UIDataAdaptor.java

/**
 * @return current state of this component.
 *//*  ww  w .  j a v  a 2 s. co 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.apache.myfaces.component.html.ext.AbstractHtmlDataTable.java

private void updateModelFromPreservedDataModel(FacesContext context) {
    ValueExpression vb = getValueExpression("value");
    if (vb != null && !vb.isReadOnly(context.getELContext())) {
        DataModel qdm = getDataModel();//w  w  w  . ja v a 2s  . c  om
        if (qdm instanceof _SerializableDataModel) {
            _SerializableDataModel dm = (_SerializableDataModel) qdm;
            Class type = (getValueType() == null) ? vb.getType(context.getELContext())
                    : ClassUtils.simpleClassForName(getValueType());
            Class dmType = dm.getClass();
            if (DataModel.class.isAssignableFrom(type)) {
                vb.setValue(context.getELContext(), dm);
            } else if (List.class.isAssignableFrom(type)
                    || _SerializableListDataModel.class.isAssignableFrom(dmType)) {
                vb.setValue(context.getELContext(), dm.getWrappedData());
            } else if (OBJECT_ARRAY_CLASS.isAssignableFrom(type)) {
                List lst = (List) dm.getWrappedData();
                vb.setValue(context.getELContext(), lst.toArray(new Object[lst.size()]));
            } else if (ResultSet.class.isAssignableFrom(type)) {
                throw new UnsupportedOperationException(
                        this.getClass().getName() + " UnsupportedOperationException");
            } else {
                //Assume scalar data model
                List lst = (List) dm.getWrappedData();
                if (lst != null && lst.size() > 0) {
                    vb.setValue(context.getELContext(), lst.get(0));
                } else {
                    vb.setValue(context.getELContext(), null);
                }
            }
        }
    }
    _preservedDataModel = null;
}

From source file:org.apache.myfaces.component.html.ext.AbstractHtmlDataTable.java

public void restoreState(FacesContext context, Object state) {
    if (state == null) {
        return;/*  w  ww  .  ja  va 2 s  .  c o  m*/
    }

    Object[] values = (Object[]) state;
    super.restoreState(context, values[0]);
    if (isPreserveDataModel()) {
        _preservedDataModel = (_SerializableDataModel) restoreAttachedState(context, values[1]);
    } else {
        _preservedDataModel = null;
    }

    if (isPreserveSort()) {
        String sortColumn = (String) values[2];
        Boolean sortAscending = (Boolean) values[3];
        if (sortColumn != null && sortAscending != null) {
            ValueExpression vb = getValueExpression("sortColumn");
            if (vb != null && !vb.isReadOnly(context.getELContext())) {
                vb.setValue(context.getELContext(), sortColumn);
            }

            vb = getValueExpression("sortAscending");
            if (vb != null && !vb.isReadOnly(context.getELContext())) {
                vb.setValue(context.getELContext(), sortAscending);
            }
        }
    }

    //_expandedNodes = (Map) values[4];
}