本文整理汇总了Java中play.data.validation.Validation.addError方法的典型用法代码示例。如果您正苦于以下问题:Java Validation.addError方法的具体用法?Java Validation.addError怎么用?Java Validation.addError使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类play.data.validation.Validation
的用法示例。
在下文中一共展示了Validation.addError方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: bindBean
import play.data.validation.Validation; //导入方法依赖的package包/类
/**
* Invokes the plugins before using the internal bindBean.
*/
public static void bindBean(RootParamNode rootParamNode, String name, Object bean) {
// Let a chance to plugins to bind this object
Object result = Play.pluginCollection.bindBean(rootParamNode, name, bean);
if (result != null) {
return;
}
ParamNode paramNode = rootParamNode.getChild(name);
try {
internalBindBean(paramNode, bean, new BindingAnnotations());
} catch (Exception e) {
Validation.addError(paramNode.getOriginalKey(), "validation.invalid");
}
}
示例2: get
import play.data.validation.Validation; //导入方法依赖的package包/类
@SuppressWarnings("unchecked")
public <T> T get(String key, Class<T> type) {
try {
checkAndParse();
// TODO: This is used by the test, but this is not the most convenient.
return (T) Binder.bind(getRootParamNode(), key, type, type, null);
} catch (Exception e) {
Validation.addError(key, "validation.invalid");
return null;
}
}
示例3: processField
import play.data.validation.Validation; //导入方法依赖的package包/类
private static void processField(Field field, ParamNode paramNode, List<RemovedNode> removedNodesList, Object o) {
NoSqlEntityManager em = NoSql.em();
MetaLayer meta = em.getMeta();
boolean isEntity = false;
Class<?> relation = null;
boolean multiple = false;
//
if (field.isAnnotationPresent(NoSqlOneToOne.class) || field.isAnnotationPresent(NoSqlManyToOne.class)) {
isEntity = true;
relation = field.getType();
} else if (field.isAnnotationPresent(NoSqlOneToMany.class) || field.isAnnotationPresent(NoSqlManyToMany.class)) {
ParameterizedType p = (ParameterizedType) field.getGenericType();
relation = (Class<?>) p.getActualTypeArguments()[0];
if(field.getType().equals(Map.class)) {
relation = (Class<?>) p.getActualTypeArguments()[1];
}
isEntity = true;
multiple = true;
}
if (!isEntity)
return;
else if(multiple)
return; //we don't do multiple collections yet(like editing in a table)
ParamNode fieldParamNode = paramNode.getChild(field.getName(), true);
String keyName = meta.getKeyFieldName(relation);
ParamNode idChild = fieldParamNode.getChild(keyName, true);
String theIdStr = retrieveValue(idChild);
if (theIdStr != null) {
Object theId = meta.convertIdFromString(relation, theIdStr);
Object to = em.find(relation, theId);
if(to != null) {
edit(paramNode, field.getName(), to, field.getAnnotations());
// Remove it to prevent us from finding it again later
paramNode.removeChild( field.getName(), removedNodesList);
set(field, o, to);
return;
}
Validation.addError(fieldParamNode.getOriginalKey(), "validation.notFound", theIdStr);
// Remove only the key to prevent us from finding it again later
// This how the old impl does it..
fieldParamNode.removeChild(keyName, removedNodesList);
if (fieldParamNode.getAllChildren().size()==0) {
// remove the whole node..
paramNode.removeChild( field.getName(), removedNodesList);
}
} else {
set(field, o, null);
// Remove the key to prevent us from finding it again later
fieldParamNode.removeChild(keyName, removedNodesList);
}
}
示例4: internalBind
import play.data.validation.Validation; //导入方法依赖的package包/类
protected static Object internalBind(ParamNode paramNode, Class<?> clazz, Type type, BindingAnnotations bindingAnnotations) {
if (paramNode == null) {
return MISSING;
}
if (paramNode.getValues() == null && paramNode.getAllChildren().size() == 0) {
return MISSING;
}
if (bindingAnnotations.checkNoBinding()) {
return NO_BINDING;
}
try {
if (Enum.class.isAssignableFrom(clazz)) {
return bindEnum(clazz, paramNode);
}
if (Map.class.isAssignableFrom(clazz)) {
return bindMap(clazz, type, paramNode, bindingAnnotations);
}
if (Collection.class.isAssignableFrom(clazz)) {
return bindCollection(clazz, type, paramNode, bindingAnnotations);
}
if (clazz.isArray()) {
return bindArray(clazz, paramNode, bindingAnnotations);
}
if (!paramNode.getAllChildren().isEmpty()) {
return internalBindBean(clazz, paramNode, bindingAnnotations);
}
return directBind(paramNode.getOriginalKey(), bindingAnnotations.annotations, paramNode.getFirstValue(clazz), clazz, type);
} catch (Exception e) {
Validation.addError(paramNode.getOriginalKey(), "validation.invalid");
}
return MISSING;
}