Sorry, forgot to mention, the RI as well as MyFaces is correct in its
behavior as per the JSF 1.1 specification. According to the
specification (which sites the JavaDoc for UIInput's behavior) the
following is true:

1) if there is no submitted value, the component is not validated (as
per the validate function)
2) the required property is only checked in the validateValue function
(called from validate) and checks to see if the local value (not
submitted value) has been set (is not null).

Therefore, the validation of component values is only to determine if
the submitted value from the user is valid, not if the user sent a
value or not, nor if the current value (not meaning local or submitted
value) is valid. So the onus is on the backing bean developer to
ensure that all required values are not null on their beans (probably
best to enforce in the action method).

So, after looking at the spec and the behavior of the tab component,
the component probably should let the processValidators method to be
called on all child components, but the way it does it now could be
viewed as a performance feature since, according to the specification,
there should not be any validation errors from components that have no
submitted values.

On 6/12/07, Andrew Robinson <[EMAIL PROTECTED]> wrote:
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
>

Reply via email to