As for the "Is it expected feature of validation or a bug in myfaces?"
comment, the JSF 1.1_02 source for UIInput.java has the same behavior
(there will be no validation errors if there is no submitted value):
public void validate(FacesContext context) {
if (context == null) {
throw new NullPointerException();
}
// Submitted value == null means "the component was not submitted
// at all"; validation should not continue
Object submittedValue = getSubmittedValue();
if (submittedValue == null) {
return;
}
Object newValue = null;
try {
newValue = getConvertedValue(context, submittedValue);
}
catch (ConverterException ce) {
addConversionErrorMessage(context, ce, submittedValue);
setValid(false);
}
validateValue(context, newValue);
// If our value is valid, store the new value, erase the
// "submitted" value, and emit a ValueChangeEvent if appropriate
if (isValid()) {
Object previous = getValue();
setValue(newValue);
setSubmittedValue(null);
if (compareValues(previous, newValue)) {
queueEvent(new ValueChangeEvent(this, previous, newValue));
}
}
}
On 6/12/07, David Delbecq <[EMAIL PROTECTED]> wrote:
Hello everyone
I did a bit of investigations on how to force validation of all tabs,
including those never yet rendered. It seems blocked by a characteristic
of validation: Validation will be completly bypassed on most components
if there has never been a _submittedValue for that component. This is
important because that mean the user behind his web browser has the
possibity to completly bypass validation of required fields. If you
require a valid client number for a message contact form, for example,
user can simply remove this field from DOM tree to ignore this (Note:
this is different to not filling entry).
Note: i could bypass without troubles validation there:
http://example.irian.at/example-simple-20070612/sample1.jsf
using this simple javascript command in url bar:
javascript:document.getElementById('form1').removeChild(document.getElementById('form1:number1'))
Is it expected feature of validation or a bug in myface?
If it's expected behaviour, then to ensure all tabs get validated we could
during decode of panel, scan tree below each non active tab, (stopping
at !isRendered() components to respect specs)
for each EditableValueHolder which does not have yet a submitted value,
set the submited value to the converted value of model (this is like
doing a encode/decode but all server side).
[EMAIL PROTECTED] wrote:
Hi,
submitted patch wouldn't break old apps (it has default of NOT
validating not-selected tabs).
But it has limitation:
it can validate only so far visited/rendered tabs (and only
visited/rendered subcomponents)
Limitation comes from the way TabbedPane is rendered:
it renders only active tab in server-side tabbing (lines 552-555 in
HtmlTabbedPaneRenderer).
This seems to be chosen for being less evil than messing with rendered
attribute in all tabs after change of selected tab [should be consulted
with original commiter].
Is there any method in MyFaces allowing to create component tree w/o
actually rendering it?
This would allow this kind of validation. (I fear that would require to
alter way rendering is functioning - decoupling rendering into creating
tree and actual rendering).
With regards,
Zdenek