use of com.servoy.j2db.server.headlessclient.WebForm in project servoy-client by Servoy.
the class RecordItemModel method getValue.
/**
* Gets the value for dataProviderID in the context of this record and the form determined using given component. The component is only used for getting the
* form, otherwise it does not affect the returned value.
*
* @param component the component used to determine the form (in case of global or form variables).
* @param dataProviderID the data provider id pointing to a data provider in the record, a form or a global variable.
* @return the value.
*/
public Object getValue(Component component, String dataProviderID) {
Object value = null;
WebForm webForm = component.findParent(WebForm.class);
if (webForm == null) {
// component.toString() may cause stackoverflow here
// $NON-NLS-1$//$NON-NLS-2$//$NON-NLS-3$
Debug.error(// $NON-NLS-1$//$NON-NLS-2$//$NON-NLS-3$
"Component " + component.getClass() + " with dp: " + dataProviderID + " already removed from its parent form.", new RuntimeException());
return null;
}
FormScope fs = webForm.getController().getFormScope();
IRecord record = (IRecord) RecordItemModel.this.getObject();
if (ScopesUtils.isVariableScope(dataProviderID)) {
value = webForm.getController().getApplication().getScriptEngine().getSolutionScope().getScopesScope().get(null, dataProviderID);
} else if (record != null) {
value = record.getValue(dataProviderID);
}
if (value == Scriptable.NOT_FOUND && fs != null && fs.has(dataProviderID, fs)) {
value = fs.get(dataProviderID);
}
if (value instanceof DbIdentValue) {
value = ((DbIdentValue) value).getPkValue();
}
if (value == Scriptable.NOT_FOUND) {
value = null;
} else if (!(record instanceof FindState)) {
// use UI converter to convert from record value to UI value
value = ComponentFormat.applyUIConverterToObject(component, value, dataProviderID, webForm.getController().getApplication().getFoundSetManager());
}
return value;
}
Aggregations