in empire-db-jsf2/src/main/java/org/apache/empire/jsf2/utils/TagEncodingHelper.java [831:900]
public void setDataValue(Object value)
{
if (getRecord() != null)
{ // value
if (record instanceof Record)
{ getColumn();
/* special case
if (value==null && getColumn().isRequired())
{ // ((Record)record).isFieldRequired(column)==false
log.warn("Unable to set null for required field!");
return;
}
*/
if (mostRecentValue!=null && isDetectFieldChange())
{ // DetectFieldChange by comparing current and most recent value
Object currentValue = ((Record) record).get(column);
if (!ObjectUtils.compareEqual(currentValue, mostRecentValue))
{ // Value has been changed by someone else!
log.info("Concurrent data change for column {}. Current Value is \"{}\". Ignoring new value \"{}\"", column.getName(), currentValue, value);
return;
}
}
// check whether to skip validation
boolean reenableValidation = false;
if (skipValidation && (record instanceof DBRecordBase))
{ // Ignore read only values
if (this.isReadOnly())
return;
/* Why?
if (ObjectUtils.isEmpty(value) && ((Record) this.record).isFieldRequired(column))
return; // Cannot set required value to null
*/
// Disable Validation
reenableValidation = ((DBRecordBase)record).isValidateFieldValues();
if (reenableValidation)
((DBRecordBase)record).setValidateFieldValues(false);
// Validation skipped for
if (log.isDebugEnabled())
log.debug("Input Validation skipped for {}.", column.getName());
}
// Now, set the value
try {
((Record) record).set(column, value);
mostRecentValue = value;
} finally {
// re-enable validation
if (reenableValidation)
((DBRecordBase)record).setValidateFieldValues(true);
}
}
else if (record instanceof RecordData)
{ // a record
throw new PropertyReadOnlyException("record");
}
else
{ // a normal bean
String prop = getColumn().getBeanPropertyName();
setBeanPropertyValue(record, prop, value);
}
}
else
{ // Set Value attribute
ValueExpression ve = getValueExpression();
if (ve == null)
throw new PropertyReadOnlyException("value");
// set value
FacesContext ctx = FacesContext.getCurrentInstance();
ve.setValue(ctx.getELContext(), value);
}
}