本文整理汇总了Java中net.sourceforge.stripes.validation.ValidationError类的典型用法代码示例。如果您正苦于以下问题:Java ValidationError类的具体用法?Java ValidationError怎么用?Java ValidationError使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
ValidationError类属于net.sourceforge.stripes.validation包,在下文中一共展示了ValidationError类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: convert
import net.sourceforge.stripes.validation.ValidationError; //导入依赖的package包/类
/**
* Attempt to parse the input string to an integer and look up the {@link Component} with that
* ID using a {@link ComponentManager}.
*
* @param input The input string to be parsed as the Component ID.
* @param targetType The type of object we're supposed to be returning.
* @param errors The validation errors for this request. If the input string cannot be parsed,
* then we will add a new {@link ValidationError} to this collection and return null.
*/
public Component convert(String input, Class<? extends Component> targetType,
Collection<ValidationError> errors) {
Component component = null;
try {
int id = Integer.valueOf(input);
ComponentManager componentManager = new ComponentManager();
component = componentManager.getComponent(id);
}
catch (NumberFormatException e) {
errors.add(new SimpleError("The number {0} is not a valid Component ID", input));
}
return component;
}
示例2: convert
import net.sourceforge.stripes.validation.ValidationError; //导入依赖的package包/类
/**
* Attempt to parse the input string to an integer and look up the {@link Bug} with that ID
* using a {@link BugManager}.
*
* @param input The input string to be parsed as the Bug ID.
* @param targetType The type of object we're supposed to be returning.
* @param errors The validation errors for this request. If the input string cannot be parsed,
* then we will add a new {@link ValidationError} to this collection and return null.
*/
public Bug convert(String input, Class<? extends Bug> targetType,
Collection<ValidationError> errors) {
Bug bug = null;
try {
int id = Integer.valueOf(input);
BugManager bugManager = new BugManager();
bug = bugManager.getBug(id);
}
catch (NumberFormatException e) {
errors.add(new SimpleError("The number {0} is not a valid Bug ID", input));
}
return bug;
}
示例3: convert
import net.sourceforge.stripes.validation.ValidationError; //导入依赖的package包/类
/**
* Attempt to parse the input string to an integer and look up the {@link Person} with that ID
* using a {@link PersonManager}.
*
* @param input The input string to be parsed as the Person ID.
* @param targetType The type of object we're supposed to be returning.
* @param errors The validation errors for this request. If the input string cannot be parsed,
* then we will add a new {@link ValidationError} to this collection and return null.
*/
public Person convert(String input, Class<? extends Person> targetType,
Collection<ValidationError> errors) {
Person person = null;
try {
int id = Integer.valueOf(input);
PersonManager personManager = new PersonManager();
person = personManager.getPerson(id);
}
catch (NumberFormatException e) {
errors.add(new SimpleError("The number {0} is not a valid Person ID", input));
}
return person;
}
示例4: doEndTag
import net.sourceforge.stripes.validation.ValidationError; //导入依赖的package包/类
/**
* Outputs the error for the current iteration of the parent ErrorsTag.
*
* @return EVAL_PAGE in all circumstances
*/
@Override
public int doEndTag() throws JspException {
Locale locale = getPageContext().getRequest().getLocale();
JspWriter writer = getPageContext().getOut();
ErrorsTag parentErrorsTag = getParentTag(ErrorsTag.class);
if (parentErrorsTag != null) {
// Mode: sub-tag inside an errors tag
try {
ValidationError error = parentErrorsTag.getCurrentError();
writer.write( error.getMessage(locale) );
}
catch (IOException ioe) {
JspException jspe = new JspException("IOException encountered while writing " +
"error tag to the JspWriter.", ioe);
log.warn(jspe);
throw jspe;
}
}
return EVAL_PAGE;
}
示例5: getVariableInfo
import net.sourceforge.stripes.validation.ValidationError; //导入依赖的package包/类
/** Returns an array of length two, for the variables exposed. */
@Override
public VariableInfo[] getVariableInfo(TagData data) {
VariableInfo[] scriptVars = new VariableInfo[2];
scriptVars[0] = new VariableInfo("index",
"java.lang.Number",
true,
VariableInfo.NESTED);
// TODO: ValidationError should expose properties like field name
scriptVars[1] = new VariableInfo("error",
ValidationError.class.getName(),
true,
VariableInfo.NESTED);
return scriptVars;
}
示例6: hasErrors
import net.sourceforge.stripes.validation.ValidationError; //导入依赖的package包/类
/** Indicates if validation errors exist for the given field of the given {@link ActionBean}. */
public static boolean hasErrors(ActionBean actionBean, String field) {
if (actionBean == null || field == null)
return false;
ActionBeanContext context = actionBean.getContext();
if (context == null)
return false;
ValidationErrors errors = context.getValidationErrors();
if (errors == null || errors.isEmpty())
return false;
List<ValidationError> fieldErrors = errors.get(field);
return fieldErrors != null && fieldErrors.size() > 0;
}
示例7: logValidationErrors
import net.sourceforge.stripes.validation.ValidationError; //导入依赖的package包/类
/** Log validation errors at DEBUG to help during development. */
public static final void logValidationErrors(ActionBeanContext context) {
StringBuilder buf = new StringBuilder("The following validation errors need to be fixed:");
for (List<ValidationError> list : context.getValidationErrors().values()) {
for (ValidationError error : list) {
String fieldName = error.getFieldName();
if (ValidationErrors.GLOBAL_ERROR.equals(fieldName))
fieldName = "GLOBAL";
String message;
try {
message = error.getMessage(Locale.getDefault());
}
catch (MissingResourceException e) {
message = "(missing resource)";
}
buf.append("\n -> [").append(fieldName).append("] ").append(message);
}
}
log.debug(buf);
}
示例8: convert
import net.sourceforge.stripes.validation.ValidationError; //导入依赖的package包/类
@Override
public DeploymentRun convert(String input, Class<? extends DeploymentRun> targetType,
Collection<ValidationError> errors) {
if (StringUtils.isBlank(input)) {
errors.add(new LocalizableError("deploymentrunnotfound"));
return null;
}
DeploymentRun obj = objRepository.findOne(input);
if (obj == null) {
errors.add(new LocalizableError("deploymentrunnotfound", input));
return null;
}
return obj;
}
示例9: convert
import net.sourceforge.stripes.validation.ValidationError; //导入依赖的package包/类
@Override
public UUID convert(String string,
Class<? extends UUID> type,
Collection<ValidationError> errors) {
UUID uuid;
Matcher matcher = PATTERN.matcher(string);
if (matcher.find()) {
try {
uuid = UUID.fromString(string);
if (uuid == null) {
errors.add(UUID_NOT_VALID_ERROR);
}
return uuid;
} catch (Exception exc) {
errors.add(UUID_NOT_VALID_ERROR);
return null;
}
} else {
errors.add(UUID_NOT_VALID_ERROR);
return null;
}
}
示例10: convert
import net.sourceforge.stripes.validation.ValidationError; //导入依赖的package包/类
@Override
public Product convert(String sProductId, Class<? extends Product> productClass,
Collection<ValidationError> conversionErrors) {
Product oProd = null;
AtrilSession oSes = null;
try {
oSes = DAO.getAdminSession("Products");
oProd = Products.seek(oSes, sProductId);
oSes.disconnect();
oSes.close();
oSes = null;
} catch (ElementNotFoundException enf) {
Log.out.error("No product with id "+sProductId+" was found");
conversionErrors.add(new SimpleError("No product with id "+sProductId+" was found"));
} catch (Exception exc) {
Log.out.error(exc.getClass().getName()+" Products.convert("+sProductId+") "+exc.getMessage());
conversionErrors.add(new SimpleError(exc.getMessage()));
} finally {
if (oSes!=null) {
if (oSes.isConnected()) oSes.disconnect();
if (oSes.isOpen()) oSes.close();
}
}
return oProd;
}
示例11: convert
import net.sourceforge.stripes.validation.ValidationError; //导入依赖的package包/类
@Override
public TicketThumbnail convert(String sId, Class<? extends TicketThumbnail> invThumbClass, Collection<ValidationError> conversionErrors) {
Log.out.debug("BillNoteThumbnail convert("+sId+")");
AtrilSession oSes = null;
TicketThumbnail oBln = null;
try {
oSes = DAO.getAdminSession("BillNoteThumbnailTypeConverter");
oBln = new TicketThumbnail(oSes.getDms(), sId);
} catch (ElementNotFoundException enfe) {
Log.out.error("Thumbnail "+sId+" not found "+enfe.getMessage(), enfe);
} catch (Exception xcpt) {
Log.out.error(xcpt.getClass().getName()+" "+xcpt.getMessage(), xcpt);
} finally {
if (oSes!=null) {
if (oSes.isConnected()) oSes.disconnect();
if (oSes.isOpen()) oSes.close();
}
}
return oBln;
}
示例12: convert
import net.sourceforge.stripes.validation.ValidationError; //导入依赖的package包/类
@Override
public Client convert(String sClientId, Class<? extends Client> clientClass,
Collection<ValidationError> conversionErrors) {
if (sClientId==null) return null;
if (sClientId.length()==0) return null;
try {
AtrilSession oSes = DAO.getAdminSession("Client");
Client oClnt = new Client(oSes.getDms(), sClientId);
oSes.disconnect();
oSes.close();
oSes = null;
if (null==oClnt) {
Log.out.error("No client with id "+sClientId+" was found");
conversionErrors.add(new SimpleError("No client with id "+sClientId+" was found"));
}
return oClnt;
} catch (Exception exc) {
Log.out.error(exc.getClass().getName()+" Client.convert("+sClientId+") "+exc.getMessage());
conversionErrors.add(new SimpleError(exc.getMessage()));
return null;
}
}
示例13: convert
import net.sourceforge.stripes.validation.ValidationError; //导入依赖的package包/类
@Override
public AccountingAccount convert(String sUuid, Class<? extends AccountingAccount> accountClass,
Collection<ValidationError> conversionErrors) {
try {
AccountingAccount oAacc = null;
AtrilSession oSes = DAO.getAdminSession("AccountingAccounts");
List<Document> oLst = oSes.getDms().query("AccountingAccount$account_uuid='"+sUuid+"'");
if (!oLst.isEmpty()) {
oAacc = new AccountingAccount(oSes.getDms(), oLst.get(0).id());
}
oSes.disconnect();
oSes.close();
oSes = null;
if (null==oAacc) {
Log.out.error("No accounting account with uuid "+sUuid+" was found");
conversionErrors.add(new SimpleError("No accounting account with uuid "+sUuid+" was found"));
}
return oAacc;
} catch (Exception exc) {
Log.out.error(exc.getClass().getName()+" AccountingAccount.convert("+sUuid+") "+exc.getMessage());
conversionErrors.add(new SimpleError(exc.getMessage()));
return null;
}
}
示例14: convert
import net.sourceforge.stripes.validation.ValidationError; //导入依赖的package包/类
@Override
public TaxPayer convert(String sTaxPayerId, Class<? extends TaxPayer> taxPayerClass,
Collection<ValidationError> conversionErrors) {
Log.out.debug("Begin TaxPayer.convert("+sTaxPayerId+")");
if (sTaxPayerId==null) return null;
if (sTaxPayerId.length()==0) return null;
TaxPayer oTxpr = null;
try {
AtrilSession oSes = DAO.getAdminSession("TaxPayer");
oTxpr = new TaxPayer(oSes.getDms(), sTaxPayerId);
oSes.disconnect();
oSes.close();
oSes = null;
if (null==oTxpr) {
Log.out.error("No tax payer with id "+sTaxPayerId+" was found");
conversionErrors.add(new SimpleError("No tax payer with id "+sTaxPayerId+" was found"));
}
} catch (Exception exc) {
Log.out.error(exc.getClass().getName()+" TaxPayer.convert("+sTaxPayerId+") "+exc.getMessage());
conversionErrors.add(new SimpleError(exc.getMessage()));
}
Log.out.debug("End TaxPayer.convert("+sTaxPayerId+") : " + oTxpr);
return oTxpr;
}
示例15: convert
import net.sourceforge.stripes.validation.ValidationError; //导入依赖的package包/类
@Override
public User convert(String sDocId, Class<? extends User> userClass,
Collection<ValidationError> conversionErrors) {
try {
AtrilSession oSes = DAO.getAdminSession("User");
User oUsr = new User(oSes, sDocId);
oSes.disconnect();
oSes.close();
oSes = null;
return oUsr;
} catch (Exception exc) {
Log.out.error(exc.getClass().getName()+" User.convert("+sDocId+") "+exc.getMessage());
conversionErrors.add(new SimpleError(exc.getMessage()));
return null;
}
}