@Override protected boolean processValidateWithVetoing(Object target, Object propertyValue, Errors errors) { if (propertyValue instanceof String && GrailsStringUtils.isBlank((String)propertyValue)) { if (!blank) { Object[] args = new Object[] { constraintPropertyName, constraintOwningClass }; rejectValue(target, errors, ConstrainedProperty.DEFAULT_BLANK_MESSAGE_CODE, ConstrainedProperty.BLANK_CONSTRAINT, args); // empty string is caught by 'blank' constraint, no addition validation needed return true; } } return false; } }
@Override protected void processValidate(Object target, Object propertyValue, Errors errors) { if (!email) { return; } EmailValidator emailValidator = EmailValidator.getInstance(); Object[] args = new Object[] { constraintPropertyName, constraintOwningClass, propertyValue }; String value = propertyValue.toString(); if (GrailsStringUtils.isBlank(value)) { return; } if (!emailValidator.isValid(value)) { rejectValue(target, errors, ConstrainedProperty.DEFAULT_INVALID_EMAIL_MESSAGE_CODE, ConstrainedProperty.EMAIL_CONSTRAINT + ConstrainedProperty.INVALID_SUFFIX, args); } } }
while (iterator.hasNext()) { Object it = iterator.next(); if (key == null && GrailsStringUtils.isBlank(var) && it != null) { key = GrailsNameUtils.getPropertyName(it.getClass());
public void validate(Object target, Object propertyValue, Errors errors) { checkState(); // Skip null values if desired. if (propertyValue == null && skipNullValues()) { return; } // Skip blank values if desired. if (skipBlankValues() && propertyValue instanceof String && GrailsStringUtils.isBlank((String) propertyValue)) { return; } // Do the validation for this constraint. processValidate(target, propertyValue, errors); }
@Override protected void doService(HttpServletRequest request, HttpServletResponse response) throws Exception { request.setAttribute(GrailsApplicationAttributes.REQUEST_SCOPE_ID, grailsAttributes); request.setAttribute(GroovyPagesServlet.SERVLET_INSTANCE, this); String pageName = (String)request.getAttribute(GrailsApplicationAttributes.GSP_TO_RENDER); if (GrailsStringUtils.isBlank(pageName)) { pageName = getCurrentRequestUri(request); } boolean isNotInclude = !WebUtils.isIncludeRequest(request) ; if (isNotInclude && isSecurePath(pageName)) { sendNotFound(response, pageName); } else { GroovyPageScriptSource scriptSource = groovyPagesTemplateEngine.findScriptSource(pageName); if (scriptSource == null) { scriptSource = findPageInBinaryPlugins(pageName); } if (scriptSource == null || (isNotInclude && !scriptSource.isPublic())) { sendNotFound(response, pageName); return; } renderPageWithEngine(groovyPagesTemplateEngine, request, response, scriptSource); } }
public void render(GrailsWebRequest webRequest, TemplateVariableBinding pageScope, Map<String, Object> attrs, Object body, Writer out) throws IOException { Assert.state(groovyPagesTemplateEngine != null, "Property [groovyPagesTemplateEngine] must be set!"); String templateName = getStringValue(attrs, "template"); if (GrailsStringUtils.isBlank(templateName)) { throw new GrailsTagException("Tag [render] is missing required attribute [template]"); } String uri = webRequest.getAttributes().getTemplateUri(templateName, webRequest.getRequest()); String contextPath = getStringValue(attrs, "contextPath"); String pluginName = getStringValue(attrs, "plugin"); final Object controller = webRequest.getAttribute(GrailsApplicationAttributes.CONTROLLER, GrailsWebRequest.SCOPE_REQUEST); Template t = findAndCacheTemplate(controller, pageScope, templateName, contextPath, pluginName, uri); if (t == null) { throw new GrailsTagException("Template not found for name [" + templateName + "] and path [" + uri + "]"); } makeTemplate(webRequest, t, attrs, body, out); }