errorMessageElement.setAttribute("key", this.getErrorMessageKey()); if (null != this.getErrorMessage() && this.getErrorMessage().trim().length() > 0) { CDATA label = new CDATA(this.getErrorMessage()); errorMessageElement.addContent(label);
errorMessageElement.setAttribute("key", this.getErrorMessageKey()); if (null != this.getErrorMessage() && this.getErrorMessage().trim().length() > 0) { CDATA label = new CDATA(this.getErrorMessage()); errorMessageElement.addContent(label);
public AttributeFieldError validate(AttributeInterface attribute, AttributeTracer tracer, ILangManager langManager) { AttributeFieldError error = null; String expression = this.getExpression(); if (null == expression || expression.trim().length() == 0) { return null; } if (this.isEvalExpressionOnValuedAttribute() && attribute.getStatus().equals(AttributeInterface.Status.EMPTY)) { return null; } try { Object expr = Ognl.parseExpression(expression); OgnlContext ctx = this.createContextForExpressionValidation(attribute, tracer, langManager); Boolean value = (Boolean) Ognl.getValue(expr, ctx, attribute, Boolean.class); if (!value) { error = new AttributeFieldError(attribute, AttributeFieldError.OGNL_VALIDATION, tracer); error.setMessage(this.getErrorMessage()); error.setMessageKey(this.getErrorMessageKey()); } } catch (OgnlException oe) { _logger.error("Error on evaluation of expression : {}", expression, oe); } catch (Throwable t) { _logger.error("Generic Error on evaluation Ognl Expression : {}", expression, t); throw new RuntimeException("Generic Error on evaluation Ognl Expression", t); } return error; }
public EntityTypeAttributeOgnlValidationDto(OgnlValidationRule ognlValidationRule) { this.setApplyOnlyToFilledAttr(ognlValidationRule.isEvalExpressionOnValuedAttribute()); this.setErrorMessage(ognlValidationRule.getErrorMessage()); this.setHelpMessage(ognlValidationRule.getHelpMessage()); this.setKeyForErrorMessage(ognlValidationRule.getErrorMessageKey()); this.setKeyForHelpMessage(ognlValidationRule.getHelpMessageKey()); this.setOgnlExpression(ognlValidationRule.getExpression()); }
@Override protected OgnlValidationRule clone() { OgnlValidationRule clone = new OgnlValidationRule(); clone.setErrorMessage(this.getErrorMessage()); clone.setErrorMessageKey(this.getErrorMessageKey()); clone.setEvalExpressionOnValuedAttribute(this.isEvalExpressionOnValuedAttribute()); clone.setExpression(this.getExpression()); clone.setHelpMessage(this.getHelpMessage()); clone.setHelpMessageKey(this.getHelpMessageKey()); return clone; }
protected OgnlValidationRule clone() { OgnlValidationRule clone = new OgnlValidationRule(); clone.setErrorMessage(this.getErrorMessage()); clone.setErrorMessageKey(this.getErrorMessageKey()); clone.setEvalExpressionOnValuedAttribute(this.isEvalExpressionOnValuedAttribute()); clone.setExpression(this.getExpression()); clone.setHelpMessage(this.getHelpMessage()); clone.setHelpMessageKey(this.getHelpMessageKey()); return clone; }
public AttributeFieldError validate(AttributeInterface attribute, AttributeTracer tracer, ILangManager langManager) { AttributeFieldError error = null; String expression = this.getExpression(); if (null == expression || expression.trim().length() == 0) { return null; } if (this.isEvalExpressionOnValuedAttribute() && attribute.getStatus().equals(AttributeInterface.Status.EMPTY)) { return null; } try { Object expr = Ognl.parseExpression(expression); OgnlContext ctx = this.createContextForExpressionValidation(attribute, tracer, langManager); Boolean value = (Boolean) Ognl.getValue(expr, ctx, attribute, Boolean.class); if (!value) { error = new AttributeFieldError(attribute, AttributeFieldError.OGNL_VALIDATION, tracer); error.setMessage(this.getErrorMessage()); error.setMessageKey(this.getErrorMessageKey()); } } catch (OgnlException oe) { ApsSystemUtils.logThrowable(oe, this, "checkExpression", "Error on evaluation of expression : " + expression); } catch (Throwable t) { ApsSystemUtils.logThrowable(t, this, "checkExpression"); throw new RuntimeException("Generic Error on evaluation Ognl Expression", t); } return error; }