Hello,
I tried to hunt a bug today and i want to know if this is expected
behaviour of datatable or a bug. Someone with deep knowledge of JSF
specs could answer me please?
A) If a JSF action is immediate (call to FacesContext.renderResponse()
durring apply request value phase), submitted values of "non immediate"
components are neither converted to localvalues, nor validated and
stored in model.
B) If a datatable has only valid childs and there is no error message,
during render response phase, it clears the datamodel and the rows saved
state
My problem is B, when no validation occured, B is assuming all childs
have sucessfully validated, which is *NOT* the case (validation phase
skipped). As a result, all input fields in datatable have their
submitted value reseted to null and, upon form redisplay, the fields are
back to backing bean values, whatever user had entered has been ignored.
My question are,
- in case this is the behaviour mandatored by JSF specs, is there a way
around it?
- if not, can we consider a bug of JSF?
extract from what i think is the cullprit code (UIData class):
/**
* Perform necessary actions when rendering of this component starts,
* before delegating to the inherited implementation which calls the
* associated renderer's encodeBegin method.
*/
public void encodeBegin(FacesContext context) throws IOException
{
_initialDescendantComponentState = null;
if (_isValidChilds && !hasErrorMessages(context))
{
// Clear the data model so that when rendering code calls
// getDataModel a fresh model is fetched from the backing
// bean via the value-binding.
_dataModelMap.clear();
// When the data model is cleared it is also necessary to
// clear the saved row state, as there is an implicit 1:1
// relation between objects in the _rowStates and the
// corresponding DataModel element.
_rowStates.clear();
}
super.encodeBegin(context);
}
solution could be to add, at the end of UIData.processDecodes(FacesContext):
// check if an immediate action forces the render response for
our data
if (context.getRenderResponse())
{
_isValidChilds = false; //validation phase will be skipped
}
another could be to default _isValidChilds to false until the begin of
processValidators()
any suggestion appreciated.
--
http://www.devlog.be (a belgian developer's logs)