/** * Complete {@link ValidatorError} containing data including user related info. * * @param request request object * @param errors all validation errors */ protected void completeErrorData(final HttpServletRequest request, final List<ValidatorError> errors) { String localIp = userData.getLocalIp(request); String remoteIp = userData.getRemoteIp(request); String userName = userData.getUsername(request); String contextPath = request.getContextPath(); for (ValidatorError error : errors) { error.setLocalIp(localIp); error.setRemoteIp(remoteIp); error.setUserName(userName); // Include context path in the target String target = error.getTarget(); if (target != null && !target.startsWith(contextPath)) { target = request.getContextPath() + target; } else if (target == null) { target = request.getRequestURI(); } error.setTarget(target); } }
/** * Complete {@link ValidatorError} containing data including user related info. * * @param context request object * @param errors all validation errors */ protected void completeErrorData(final FacesContext context, final List<FacesValidatorError> errors) { HttpServletRequest request = (HttpServletRequest) context.getExternalContext().getRequest(); String localIp = userData.getLocalIp(request); String remoteIp = userData.getRemoteIp(request); String userName = userData.getUsername(request); String contextPath = request.getContextPath(); for (ValidatorError error : errors) { error.setLocalIp(localIp); error.setRemoteIp(remoteIp); error.setUserName(userName); // Include context path in the target String target = error.getTarget(); if (target != null && !target.startsWith(contextPath)) { target = request.getContextPath() + target; } else if (target == null) { target = request.getRequestURI(); } error.setTarget(target); } }