本文整理匯總了Java中org.apache.struts.action.ActionErrors類的典型用法代碼示例。如果您正苦於以下問題:Java ActionErrors類的具體用法?Java ActionErrors怎麽用?Java ActionErrors使用的例子?那麽, 這裏精選的類代碼示例或許可以為您提供幫助。
ActionErrors類屬於org.apache.struts.action包,在下文中一共展示了ActionErrors類的15個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。
示例1: validate
import org.apache.struts.action.ActionErrors; //導入依賴的package包/類
public ActionErrors validate(ActionMapping mapping, HttpServletRequest request) {
ActionErrors errors = new ActionErrors();
if(name==null || name.trim().length()==0)
errors.add("name", new ActionMessage("errors.required", ""));
else {
if ("Save".equals(op)) {
SolverParameterGroup gr = SolverParameterGroup.findByName(name);
if (gr!=null)
errors.add("name", new ActionMessage("errors.exists", name));
}
}
if(description==null || description.trim().length()==0)
errors.add("description", new ActionMessage("errors.required", ""));
return errors;
}
示例2: validateImageFile
import org.apache.struts.action.ActionErrors; //導入依賴的package包/類
/**
* Validate imageGallery item.
*
* @param itemForm
* @return
*/
private ActionErrors validateImageFile(AuthoringForm itemForm) {
ActionErrors errors = new ActionErrors();
// validate file size
FileValidatorUtil.validateFileSize(itemForm.getFile(), true, errors);
// for edit validate: file already exist
if (!itemForm.isHasFile()
&& ((itemForm.getFile() == null) || StringUtils.isEmpty(itemForm.getFile().getFileName()))) {
errors.add(ActionMessages.GLOBAL_MESSAGE, new ActionMessage(PixlrConstants.ERROR_MSG_FILE_BLANK));
}
// check for allowed format : gif, png, jpg
if (itemForm.getFile() != null) {
String contentType = itemForm.getFile().getContentType();
if (StringUtils.isEmpty(contentType) || !(contentType.equals("image/gif") || contentType.equals("image/png")
|| contentType.equals("image/jpg") || contentType.equals("image/jpeg")
|| contentType.equals("image/pjpeg"))) {
errors.add(ActionMessages.GLOBAL_MESSAGE,
new ActionMessage(PixlrConstants.ERROR_MSG_NOT_ALLOWED_FORMAT));
}
}
return errors;
}
示例3: validateMultipleImages
import org.apache.struts.action.ActionErrors; //導入依賴的package包/類
/**
* Validate imageGallery item.
*
* @param multipleForm
* @return
*/
public static ActionErrors validateMultipleImages(MultipleImagesForm multipleForm, boolean largeFile) {
ActionErrors errors = new ActionErrors();
List<FormFile> fileList = createFileListFromMultipleForm(multipleForm);
// validate files size
for (FormFile file : fileList) {
FileValidatorUtil.validateFileSize(file, largeFile, errors);
// check for allowed format : gif, png, jpg
String contentType = file.getContentType();
if (isContentTypeForbidden(contentType)) {
errors.add(ActionMessages.GLOBAL_MESSAGE,
new ActionMessage(ImageGalleryConstants.ERROR_MSG_NOT_ALLOWED_FORMAT_FOR, file.getFileName()));
}
}
return errors;
}
示例4: validate
import org.apache.struts.action.ActionErrors; //導入依賴的package包/類
/**
* The idea is to do minimal validation on inputs.
*/
public ActionErrors validate(ActionMapping mapping, HttpServletRequest request) {
ActionErrors errors = new ActionErrors();
//
boolean validName = false, validEmail = false;
try {
validName = ESAPI.validator().isValidInput("TestForm_name", name, "name", 20, false);
validEmail = ESAPI.validator().isValidInput("TestForm_email", email, "email", 45, false);
} catch (IntrusionException e) {
log.severe(e.getMessage());
}
if (!validName) errors.add("name", new ActionMessage("TestForm.name.invalid"));
if (!validEmail) errors.add("email", new ActionMessage("TestForm.email.invalid"));
return errors;
}
示例5: validateChildClassExistence
import org.apache.struts.action.ActionErrors; //導入依賴的package包/類
private void validateChildClassExistence(ActionErrors errors){
for(int index = 0 ; index < this.getClassIds().size(); index++){
if (Boolean.valueOf((String) this.getMustHaveChildClasses().get(index)).booleanValue()){
String classId = (String) this.getClassIds().get(index);
if ((index + 1) == this.getClassIds().size()){
errors.add("mustHaveChildClasses",
new ActionMessage("errors.generic", MSG.errorClassMustHaveChildClasses((String) this.getClassLabels().get(index))));
this.getClassHasErrors().set(index, new Boolean(true));
} else {
String parentOfNextClass = (String) this.getParentClassIds().get(index + 1);
if (parentOfNextClass == null || !parentOfNextClass.equals(classId)){
errors.add("mustHaveChildClasses",
new ActionMessage("errors.generic", MSG.errorClassMustHaveChildClasses((String) this.getClassLabels().get(index))));
this.getClassHasErrors().set(index, new Boolean(true));
}
}
}
}
}
示例6: validate
import org.apache.struts.action.ActionErrors; //導入依賴的package包/類
public ActionErrors validate(ActionMapping mapping, HttpServletRequest request) {
ActionErrors errors = new ActionErrors();
if (iExternalId ==null || iExternalId.trim().length()==0)
errors.add("externalId", new ActionMessage("errors.required", ""));
else if (!"Update".equals(getOp()) && User.findByExternalId(getExternalId())!=null) {
errors.add("externalId", new ActionMessage("errors.exists", iExternalId));
}
if (iName==null || iName.trim().length()==0)
errors.add("name", new ActionMessage("errors.required", ""));
else {
try {
User user = User.findByUserName(iName);
if (user!=null && !user.getExternalUniqueId().equals(iExternalId))
errors.add("name", new ActionMessage("errors.exists", iName));
} catch (Exception e) {
errors.add("name", new ActionMessage("errors.generic", e.getMessage()));
}
}
if (iPassword==null || iPassword.trim().length()==0)
errors.add("password", new ActionMessage("errors.required", ""));
return errors;
}
示例7: setHolidays
import org.apache.struts.action.ActionErrors; //導入依賴的package包/類
/**
*
*/
private void setHolidays(
HttpServletRequest request,
SessionEditForm sessionEditForm,
ActionErrors errors,
Session sessn) throws ParseException {
sessionEditForm.validateDates(errors);
if (errors.size()==0) {
setSessionData(request, sessionEditForm, sessn);
request.setAttribute("Sessions.holidays", sessn.getHolidaysHtml());
}
else
saveErrors(request, new ActionMessages(errors));
}
示例8: validateAdminForm
import org.apache.struts.action.ActionErrors; //導入依賴的package包/類
/**
* Validate ScratchieConfigItems.
*
* @param adminForm
* @return
*/
private ActionErrors validateAdminForm(AdminForm adminForm) {
ActionErrors errors = new ActionErrors();
String presetMarks = adminForm.getPresetMarks();
if (StringUtils.isNotBlank(presetMarks)) {
//it's not a comma separated numbers
if (!presetMarks.matches("[0-9]+(,[0-9]+)*")) {
errors.add(ActionMessages.GLOBAL_MESSAGE,
new ActionMessage(ScratchieConstants.ERROR_MSG_ENTERED_MARKS_NOT_COMMA_SEPARATED_INTEGERS));
}
} else {
errors.add(ActionMessages.GLOBAL_MESSAGE,
new ActionMessage(ScratchieConstants.ERROR_MSG_REQUIRED_FIELDS_MISSING));
}
return errors;
}
示例9: validate
import org.apache.struts.action.ActionErrors; //導入依賴的package包/類
/**
* Method validate
* @param mapping
* @param request
* @return ActionErrors
*/
public ActionErrors validate(
ActionMapping mapping,
HttpServletRequest request) {
ActionErrors errors = new ActionErrors();
if (deptSize != 1) {
if (deptCode== null || deptCode.equals("")) {
errors.add("dept",
new ActionMessage("errors.required", "Department"));
}
}
if(bldgId==null || bldgId.equalsIgnoreCase("")) {
errors.add("bldg",
new ActionMessage("errors.required", "Building") );
}
if(roomNum==null || roomNum.equalsIgnoreCase("")) {
errors.add("roomNum",
new ActionMessage("errors.required", "Room Number") );
}
return errors;
}
示例10: validateImageGalleryItem
import org.apache.struts.action.ActionErrors; //導入依賴的package包/類
/**
* Validate imageGallery item.
*
* @param itemForm
* @return
*/
public static ActionErrors validateImageGalleryItem(ImageGalleryItemForm itemForm, boolean largeFile) {
ActionErrors errors = new ActionErrors();
// validate file size
FileValidatorUtil.validateFileSize(itemForm.getFile(), largeFile, errors);
// for edit validate: file already exist
if (!itemForm.isHasFile()
&& ((itemForm.getFile() == null) || StringUtils.isEmpty(itemForm.getFile().getFileName()))) {
errors.add(ActionMessages.GLOBAL_MESSAGE, new ActionMessage(ImageGalleryConstants.ERROR_MSG_FILE_BLANK));
}
// check for allowed format : gif, png, jpg
if (itemForm.getFile() != null) {
String contentType = itemForm.getFile().getContentType();
if (isContentTypeForbidden(contentType)) {
errors.add(ActionMessages.GLOBAL_MESSAGE,
new ActionMessage(ImageGalleryConstants.ERROR_MSG_NOT_ALLOWED_FORMAT));
}
}
return errors;
}
示例11: validate
import org.apache.struts.action.ActionErrors; //導入依賴的package包/類
/**
* Validate the properties that have been set from this HTTP request,
* and return an <code>ActionErrors</code> object that encapsulates any
* validation errors that have been found. If no errors are found, return
* <code>null</code> or an <code>ActionErrors</code> object with no
* recorded error messages.
*
* @param mapping The mapping used to select this instance.
* @param request The servlet request we are processing.
* @return <code>ActionErrors</code> object that encapsulates any validation errors.
*/
public ActionErrors validate(ActionMapping mapping, HttpServletRequest request) {
this.setPageFromDynaProperty();
ServletContext application = getServlet().getServletContext();
ActionErrors errors = new ActionErrors();
String validationKey = getValidationKey(mapping, request);
Validator validator = Resources.initValidator(validationKey,
this,
application, request,
errors, page);
try {
validatorResults = validator.validate();
} catch (ValidatorException e) {
log.error(e.getMessage(), e);
}
return errors;
}
示例12: handleUpdateEntry
import org.apache.struts.action.ActionErrors; //導入依賴的package包/類
/**
* Update the edited values for the StatusEntry corresponding to "entryKey"
*
* @param mapping NOT YET DOCUMENTED
* @param form NOT YET DOCUMENTED
* @param request NOT YET DOCUMENTED
* @param response NOT YET DOCUMENTED
* @return NOT YET DOCUMENTED
* @exception Exception NOT YET DOCUMENTED
*/
private ActionForward handleUpdateEntry(ActionMapping mapping,
ActionForm form,
HttpServletRequest request,
HttpServletResponse response) throws Exception {
ActionErrors errors = new ActionErrors();
StatusForm statusForm = (StatusForm) form;
String entryKey = statusForm.getEntryKey();
String id = statusForm.getRecId();
DcsDataRecord dcsDataRecord = statusForm.getDcsDataRecord();
StatusEntry statusEntry = dcsDataRecord.getStatusEntry(entryKey);
if (statusEntry == null)
throw new Exception("status entry not found for " + entryKey);
statusEntry.setStatusNote(statusForm.getStatusNote());
dcsDataRecord.replaceStatusEntry(entryKey, statusEntry);
repositoryService.updateRecord(id);
dcsDataRecord.flushToDisk();
statusForm.setHash(entryKey);
statusForm.clear();
statusForm.setEntryKey("");
errors.add("message", new ActionError("generic.message", "status entry updated"));
saveErrors(request, errors);
return mapping.findForward("edit.status");
}
示例13: getAnswer
import org.apache.struts.action.ActionErrors; //導入依賴的package包/類
/**
* Get answer by special question.
*/
private ActionErrors getAnswer(HttpServletRequest request, AnswerDTO answerDto) {
ActionErrors errors = new ActionErrors();
// get sessionMap
String sessionMapID = request.getParameter(SurveyConstants.ATTR_SESSION_MAP_ID);
SessionMap<String, Object> sessionMap = (SessionMap<String, Object>) request.getSession()
.getAttribute(sessionMapID);
Long sessionID = (Long) sessionMap.get(AttributeNames.PARAM_TOOL_SESSION_ID);
SurveyAnswer answer = getAnswerFromPage(request, answerDto, sessionID);
answerDto.setAnswer(answer);
validateAnswers(request, answerDto, errors, answer);
if (!errors.isEmpty()) {
addErrors(request, errors);
}
return errors;
}
示例14: validate
import org.apache.struts.action.ActionErrors; //導入依賴的package包/類
public ActionErrors validate(ActionMapping mapping, HttpServletRequest request) {
ActionErrors errors = new ActionErrors();
if(iSetting==null || iSetting.intValue()<0)
errors.add("setting", new ActionMessage("errors.lookup.config.required", ""));
for (Iterator i=iParamValues.entrySet().iterator();i.hasNext();) {
Map.Entry entry = (Map.Entry)i.next();
Long parm = (Long)entry.getKey();
String val = (String)entry.getValue();
if (val==null || val.trim().length()==0)
errors.add("parameterValue["+parm+"]", new ActionMessage("errors.required", ""));
}
return errors;
}
示例15: validate
import org.apache.struts.action.ActionErrors; //導入依賴的package包/類
public ActionErrors validate(ActionMapping mapping, HttpServletRequest request) {
ActionErrors errors = new ActionErrors();
if(name==null || name.trim().length()==0)
errors.add("name", new ActionMessage("errors.required", ""));
else {
if ("Add New".equals(op)) {
SolverInfoDef info = SolverInfoDef.findByName(name);
if (info!=null)
errors.add("name", new ActionMessage("errors.exists", name));
}
}
if(description==null || description.trim().length()==0)
errors.add("description", new ActionMessage("errors.required", ""));
if(implementation==null || implementation.trim().length()==0)
errors.add("implementation", new ActionMessage("errors.required", ""));
return errors;
}