Friday, March 29, 2013

Bean Validation customization questions

First of all i need to make MessageInterpolator decorator like that.

public class MessageInterpolatorDecorator implements MessageInterpolator {
    private final MessageInterpolator decorator;

    public MessageInterpolatorDecorator(MessageInterpolator decorator) {
        this.decorator = decorator;
    }

    @Override public String interpolate(String messageTemplate, Context context) {
        return decorator.interpolate(messageTemplate, context);
    }

    @Override public String interpolate(String messageTemplate, Context context, Locale locale) {
        return decorator.interpolate(messageTemplate, context, locale);
    }
}

It looks like correct, but can't be compiled.

The second requirement in my project is usage DI in custom ConstraintValidator. For example:

public class ExistingCustomsCodeValidator implements ConstraintValidator<ExistingCustomsCode, String> {
    @Inject private CustomsCodeService customsCodeService;
    @Inject private ProcessingCtx processingCtx;

    @Override public void initialize(ExistingCustomsCode constraintAnnotation) {}

    @Override public boolean isValid(String value, ConstraintValidatorContext context) {
        return customsCodeService.isValid(value, processingCtx.getDeclarationDateTime());
    }
}

It can be simply done at server side, but i haven't any idea how to do this on client side. Can somebody give me advice?

--
You received this message because you are subscribed to the Google Groups "Google Web Toolkit" group.
To unsubscribe from this group and stop receiving emails from it, send an email to google-web-toolkit+unsubscribe@googlegroups.com.
To post to this group, send email to google-web-toolkit@googlegroups.com.
Visit this group at http://groups.google.com/group/google-web-toolkit?hl=en.
For more options, visit https://groups.google.com/groups/opt_out.
 
 

No comments:

Post a Comment