@Override public boolean equals(Object obj) { return (obj instanceof ValueExpressionLiteral && this .equals((ValueExpressionLiteral) obj)); }
@Override public ValueExpression createValueExpression(Object instance, Class<?> expectedType) { if (expectedType == null) { throw new NullPointerException(MessageFactory .get("error.value.expectedType")); } return new ValueExpressionLiteral(instance, expectedType); } }
@Override public boolean isReadOnly(ELContext context) { context.notifyBeforeEvaluation(getExpressionString()); context.notifyAfterEvaluation(getExpressionString()); return true; }
@Override public ValueExpression createValueExpression(Object instance, Class<?> expectedType) { if (expectedType == null) { throw new NullPointerException(MESSAGES.errorNullType()); } return new ValueExpressionLiteral(instance, expectedType); } }
@Override public boolean isReadOnly(ELContext context) { context.notifyBeforeEvaluation(getExpressionString()); context.notifyAfterEvaluation(getExpressionString()); return true; }
@Override public ValueExpression createValueExpression(Object instance, Class<?> expectedType) { if (expectedType == null) { throw new NullPointerException(MessageFactory .get("error.value.expectedType")); } return new ValueExpressionLiteral(instance, expectedType); } }
@Override public boolean equals(Object obj) { return (obj instanceof ValueExpressionLiteral && this .equals((ValueExpressionLiteral) obj)); }
@Override public Class<?> getType(ELContext context) { context.notifyBeforeEvaluation(getExpressionString()); Class<?> result = (this.value != null) ? this.value.getClass() : null; context.notifyAfterEvaluation(getExpressionString()); return result; }
@Override public ValueExpression createValueExpression(Object instance, Class<?> expectedType) { if (expectedType == null) { throw new NullPointerException(MessageFactory .get("error.value.expectedType")); } return new ValueExpressionLiteral(instance, expectedType); }
@Override public boolean equals(Object obj) { return (obj instanceof ValueExpressionLiteral && this .equals((ValueExpressionLiteral) obj)); }
@Override public Class<?> getType(ELContext context) { context.notifyBeforeEvaluation(getExpressionString()); Class<?> result = (this.value != null) ? this.value.getClass() : null; context.notifyAfterEvaluation(getExpressionString()); return result; }
@Override public ValueExpression createValueExpression(Object instance, Class<?> expectedType) { if (expectedType == null) { throw new NullPointerException(MessageFactory .get("error.value.expectedType")); } return new ValueExpressionLiteral(instance, expectedType); }
@Override public boolean equals(Object obj) { return (obj instanceof ValueExpressionLiteral && this .equals((ValueExpressionLiteral) obj)); }
@Override public Object getValue(ELContext context) { context.notifyBeforeEvaluation(getExpressionString()); Object result; if (this.expectedType != null) { result = context.convertToType(this.value, this.expectedType); } else { result = this.value; } context.notifyAfterEvaluation(getExpressionString()); return result; }
public ValueExpression createValueExpression(Object instance, Class<?> expectedType) { if (expectedType == null) { throw new NullPointerException(MessageFactory .get("error.value.expectedType")); } return new ValueExpressionLiteral(instance, expectedType); } }
@Override public boolean equals(Object obj) { return (obj instanceof ValueExpressionLiteral && this .equals((ValueExpressionLiteral) obj)); }
@Override public Object getValue(ELContext context) { context.notifyBeforeEvaluation(getExpressionString()); Object result; if (this.expectedType != null) { result = context.convertToType(this.value, this.expectedType); } else { result = this.value; } context.notifyAfterEvaluation(getExpressionString()); return result; }
package cz.test; import javax.faces.application.FacesMessage; import javax.faces.component.UIComponent; import javax.faces.context.FacesContext; import javax.faces.validator.Validator; import javax.faces.validator.ValidatorException; import org.apache.el.ValueExpressionLiteral; public class RequiredValidator implements Validator { public void validate(FacesContext context, UIComponent component, Object value) throws ValidatorException { if (value == null || "".equals(value.toString().trim())) { FacesMessage message = new FacesMessage(); String messageStr = (String) component.getAttributes().get("message"); if (messageStr == null) { messageStr = "Please enter data"; } message.setDetail(messageStr); message.setSummary(messageStr); message.setSeverity(FacesMessage.SEVERITY_ERROR); component.setValueExpression("style", new ValueExpressionLiteral("background-color: yellow;", String.class)); throw new ValidatorException(message); } else { component.setValueExpression("style", new ValueExpressionLiteral("", String.class)); } } }
public boolean equals(Object obj) { return (obj instanceof ValueExpressionLiteral && this .equals((ValueExpressionLiteral) obj)); }
@Override public void setValue(ELContext context, Object value) { context.notifyBeforeEvaluation(getExpressionString()); throw new PropertyNotWritableException(MessageFactory.get( "error.value.literal.write", this.value)); }