protected final void processTargetComponentAfterViolation()

in validation-modules/property-validation/src/main/java/org/apache/myfaces/extensions/validator/crossval/strategy/AbstractCompareStrategy.java [121:186]


    protected final void processTargetComponentAfterViolation(
            CrossValidationStorageEntry entryOfSource,
            CrossValidationStorageEntry entryOfTarget)
    {
        if (!handleTargetViolation(entryOfSource, entryOfTarget))
        {
            //no target - because there is no target component - value was validated against the model
            if(entryOfTarget == null)
            {
                processTargetComponentAsSourceComponentAfterViolation(entryOfSource);
                return;
            }

            return;
        }

        //get validation error messages for the target component
        String summary = getErrorMessageSummary((A)entryOfSource.getMetaDataEntry().getValue(), true);
        String details = getErrorMessageDetail((A)entryOfSource.getMetaDataEntry().getValue(), true);

        //validation target isn't bound to a component withing the current page 
        //(see validateFoundEntry, tryToValidateLocally and tryToValidateBindingOnly)
        if (entryOfTarget == null)
        {
            entryOfTarget = entryOfSource;
        }

        FacesMessage message;
        if (entryOfTarget.getMetaDataEntry() != null)
        {
            message = getTargetComponentErrorMessage((A)entryOfTarget.getMetaDataEntry().getValue(), summary, details);
        }
        else
        {
            //TODO document possible side effects
            //due to a missing target annotation (see: tryToValidateLocally)
            message = getTargetComponentErrorMessage((A)entryOfSource.getMetaDataEntry().getValue(), summary, details);
        }

        if ((message.getSummary() != null || message.getDetail() != null) &&
            entryOfSource.getClientId() != null && !entryOfSource.getClientId().equals(entryOfTarget.getClientId()))
        {
            ValidatorException validatorException = new ValidatorException(message);

            boolean isSourceMetaDataUsed = false;

            if(entryOfTarget.getMetaDataEntry() == null)
            {
                prepareTargetMetaDataForSeverityAwareInterception(entryOfSource, entryOfTarget);
                isSourceMetaDataUsed = true;
            }
            
            if(ExtValUtils.executeAfterThrowingInterceptors(
                    entryOfTarget.getComponent(), entryOfTarget.getMetaDataEntry(),
                    entryOfTarget.getConvertedObject(), validatorException, this))
            {
                ExtValUtils.tryToAddViolationMessageForComponentId(entryOfTarget.getClientId(),
                        ExtValUtils.convertFacesMessage(validatorException.getFacesMessage()));
            }

            if(isSourceMetaDataUsed)
            {
                resetTargetMetaData(entryOfTarget);
            }
        }
    }