public AjaxResponse validateUsername(AjaxActionEvent event) {
String username = event.getParameters().get("username");
boolean exists = this.userService.checkUserAccount(username);
AjaxResponse response = new AjaxResponseImpl("UTF-8");
if (!exists) {
TaggedText msg = new TaggedText(
this.messageSource.getMessage("user.available.username", null, "Available", LocaleContextHolder.getLocale()),
TaggedText.Tag.SPAN);
msg.addAttribute("class", "okMessage");
ReplaceContentAction action = new ReplaceContentAction("username.validation", msg);
response.addAction(action);
} else {
TaggedText msg = new TaggedText(
this.messageSource.getMessage("user.unavailable.username", null, "Not Available", LocaleContextHolder.getLocale()),
TaggedText.Tag.SPAN);
msg.addAttribute("class", "warnMessage");
ReplaceContentAction action = new ReplaceContentAction("username.validation", msg);
response.addAction(action);
}