本文整理匯總了Java中org.apache.struts.action.ActionErrors.size方法的典型用法代碼示例。如果您正苦於以下問題:Java ActionErrors.size方法的具體用法?Java ActionErrors.size怎麽用?Java ActionErrors.size使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類org.apache.struts.action.ActionErrors
的用法示例。
在下文中一共展示了ActionErrors.size方法的7個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。
示例1: handleSaveRequest
import org.apache.struts.action.ActionErrors; //導入方法依賴的package包/類
/**
*
*
*@param mapping Description of the Parameter
*@param form Description of the Parameter
*@param request Description of the Parameter
*@param response Description of the Parameter
*@param validator Description of the Parameter
*@return Description of the Return Value
*@exception ServletException Description of the Exception
*@exception MissingLockException Description of the Exception
*/
protected ActionForward handleSaveRequest(ActionMapping mapping,
ActionForm form,
HttpServletRequest request,
HttpServletResponse response,
SchemEditValidator validator)
throws ServletException, MissingLockException {
prtln ("Stand allone handleSaveRequest()");
ActionErrors errors = saveRecord (mapping, form, request, response, validator);
if (errors.size() == 0) {
errors.add("message",
new ActionError("save.confirmation"));
}
saveErrors(request, errors);
return getEditorMapping(mapping);
}
示例2: 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));
}
示例3: 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 (op.equals(MSG.actionLookupInstructor())) {
if ( (fname==null || fname.trim().length()==0)
&& (lname==null || lname.trim().length()==0)
&& (careerAcct==null || careerAcct.trim().length()==0) ) {
errors.add("fname",
new ActionMessage("errors.generic", MSG.errorSupplyInfoForInstructorLookup()) );
}
return errors;
}
if (!screenName.equalsIgnoreCase("instructorPref") ) {
if (lname == null || lname.trim().equals("")) {
errors.add("Last Name",
new ActionMessage("errors.generic", MSG.errorRequiredLastName()) );
}
}
if (errors.size() == 0) {
return super.validate(mapping, request);
} else {
return errors;
}
}
示例4: doAddNewMetadataFileDir
import org.apache.struts.action.ActionErrors; //導入方法依賴的package包/類
private ActionForward doAddNewMetadataFileDir(ActionErrors errors,
ActionMapping mapping,
RepositoryManager rm,
HttpServletRequest req,
RepositoryAdminForm raf,
MetadataDirectoryInfoForm addMetadataDirsForm) {
prtln("name is: " + addMetadataDirsForm.getDirPath());
String dirPath = (String) addMetadataDirsForm.getDirPath();
dirPath = dirPath.trim();
String dirMetadataFormat = (String) addMetadataDirsForm.getDirMetadataFormat();
String dirNickname = (String) addMetadataDirsForm.getDirNickname();
String metadataNamespace = (String) addMetadataDirsForm.getMetadataNamespace();
String metadataSchema = (String) addMetadataDirsForm.getMetadataSchema();
if(dirPath == null || dirPath.length() == 0)
errors.add("error", new ActionError("generic.error", "The directory was not specified"));
if(errors.size() == 0) {
prtln("Adding metadata file dir: " + dirNickname + " " + dirMetadataFormat + " " + dirPath + " " + metadataNamespace + " " + metadataSchema);
try {
// Make an arbitray set spec to use as a placeholder
String setSpec = Long.toString(System.currentTimeMillis());
SetInfo newSet = new SetInfo(dirNickname,
setSpec,
"",
"true",
dirPath,
dirMetadataFormat,
setSpec);
// Add the set
rm.addSetInfo(newSet);
// Put the sets in the bean for display...
raf.setSets(rm.getSetInfos());
// Set the metadata schema and namespace info
setNamespaceAndSchemaDefs(rm, dirMetadataFormat, metadataNamespace, metadataSchema);
// Begin the iindexer
rm.indexCollection(setSpec, new SimpleFileIndexingObserver("Indexer for '" + dirNickname + "'", "Starting indexing"), true);
errors.add("showIndexMessagingLink", new ActionError("generic.message", ""));
errors.add("message", new ActionError("generic.message", "Directory '" + newSet.getName() + "' was added and is being indexed"));
} catch (Throwable t) {
errors.add("error", new ActionError("generic.error", "There was an error adding the directory: " + t.getMessage()));
if (t instanceof NullPointerException)
t.printStackTrace();
}
}
saveErrors(req, errors);
return mapping.findForward("display.repository.settings");
}
示例5: handleDeleteCollection
import org.apache.struts.action.ActionErrors; //導入方法依賴的package包/類
/**
* Delete a collection from the repository
*
* @param mapping the mapping object
* @param form the form object
* @param response the response
* @param request the request
* @return forward to manage.collections page
* @exception Exception if collection could not be deleted
*/
private ActionForward handleDeleteCollection(
ActionMapping mapping,
ActionForm form,
HttpServletRequest request,
HttpServletResponse response)
throws Exception {
ActionErrors errors = new ActionErrors();
CollectionServicesForm csForm = (CollectionServicesForm) form;
SessionBean sessionBean = this.getSessionBean(request);
User sessionUser = this.getSessionUser(request);
String collection = request.getParameter("collection");
SetInfo setInfo = SchemEditUtils.getSetInfo(collection, repositoryManager);
if (setInfo == null) {
errors.add("message", new ActionError("collection.not.found", collection));
saveErrors(request, errors);
return mapping.findForward("manage.collections");
}
String id = setInfo.getId();
if (!sessionBean.getLock(id)) {
errors.add("recordLocked", new ActionError("lock.not.obtained.error", id));
saveErrors(request, errors);
return mapping.findForward("manage.collections");
}
RecordList records = repositoryService.getCollectionItemRecords(collection);
if (!sessionBean.getBatchLocks(records)) {
errors.add("error", new ActionError("batch.lock.not.obtained", "Delete Collection"));
saveErrors(request, errors);
return mapping.findForward("manage.collections");
}
// reaper removes item records and unhooks from vocab, collectionRegistry and idManager.
try {
/*
do NOT delete the collection from the NDR without getting express written
consent from the user. There should be a dialog to clarify user's intentions
and also offer an alternative (later) way of deleting from the ndr ...
*/
/* CollectionConfig config = this.collectionRegistry.getCollectionConfig(collection);
if (config.isNDRCollection()) {
// we used to delete automatically from NDR, but no more ...
} */
repositoryService.deleteCollection(collection);
csForm.setSets(repositoryService.getAuthorizedSets(sessionUser, this.requiredRole));
} catch (Exception e) {
errors.add("error", new ActionError("generic.error", e.getMessage()));
}
if (errors.size() > 1) {
saveErrors(request, errors);
return mapping.findForward("manage.collections");
}
errors.add("message", new ActionError("delete.collection.confirm", setInfo.getName(), id));
saveErrors(request, errors);
return mapping.findForward("manage.collections");
}
示例6: handleSubmit
import org.apache.struts.action.ActionErrors; //導入方法依賴的package包/類
/**
* NOT YET DOCUMENTED
*
* @param carForm NOT YET DOCUMENTED
* @param framework NOT YET DOCUMENTED
* @param mapping NOT YET DOCUMENTED
* @param request NOT YET DOCUMENTED
* @param response NOT YET DOCUMENTED
* @return NOT YET DOCUMENTED
*/
protected ActionForward handleSubmit(CreateADNRecordForm carForm,
MetaDataFramework framework,
ActionMapping mapping,
HttpServletRequest request,
HttpServletResponse response) {
prtln("submit\n\tprimaryUrl: " + carForm.getPrimaryUrl() +
"\n\tvalidatedUrl: " + carForm.getValidatedUrl());
ActionErrors errors = validateForm(request, carForm, framework);
prtln("validation found " + errors.size() + " errors");
if (errors.size() > 0) {
carForm.setValidatedUrl(null);
errors.add("error",
new ActionError("edit.errors.found"));
saveErrors(request, errors);
return this.getCreateForward(mapping);
}
// are we concerned with testing for similar and duplicate values?
if (framework.getUniqueUrlPath() != null) {
/*
1 - if we have not seen this url (primaryUrl) before we need to check for sims.
validatedUrl is set to preserve a url that is valid, but which also has sims
- note: validatedUrl is set below, so it was set in the previous call to handleSubmit)
case A) if validatedUrl is null, then we have not tested for sims and must do so now. if sim(s)
are found, then we will preserve the primaryUrl value as "validatedUrl" and present a
confirmation message to user (this has sims, do you really want to save?).
case B) if primaryUrl is not equal to validatedUrl, then the user has changed the
previous url and we have to evaluate again for sims (setting validatedUrl
if sims are found, etc)
2 - if validatedUrl and primaryUrl are the same, then user has confirmed that the
primaryUrl is to be used (even though it is similar), and we can perform the submit
operation
*/
if (carForm.getValidatedUrl() == null ||
!carForm.getPrimaryUrl().equals(carForm.getValidatedUrl())) {
prtln("checking sims");
List sims = repositoryService.getSims(carForm.getPrimaryUrl(), carForm.getCollection());
if (sims.size() > 0) {
prtln(sims.size() + " similar urls found");
carForm.setValidatedUrl(carForm.getPrimaryUrl());
carForm.setSims(sims);
errors.add("message",
new ActionError("similar.urls.found", Integer.toString(sims.size())));
saveErrors(request, errors);
return this.getCreateForward(mapping);
}
}
}
return handleNewRecordRequest(carForm, framework, mapping, request, response);
}
示例7: validate
import org.apache.struts.action.ActionErrors; //導入方法依賴的package包/類
public ActionErrors validate(ActionMapping arg0, HttpServletRequest arg1) {
ActionErrors errors = new ActionErrors();
// Check data fields
if (academicInitiative==null || academicInitiative.trim().length()==0)
errors.add("academicInitiative", new ActionMessage("errors.required", "Academic Initiative"));
if (academicTerm==null || academicTerm.trim().length()==0)
errors.add("academicTerm", new ActionMessage("errors.required", "Academic Term"));
if (academicYear==null || academicYear.trim().length()==0)
errors.add("academicYear", new ActionMessage("errors.required", "Academic Year"));
else {
try {
Integer.parseInt(academicYear);
}
catch (Exception e) {
errors.add("academicYear", new ActionMessage("errors.numeric", "Academic Year"));
}
}
validateDates(errors);
if (getStatus()==null || getStatus().trim().length()==0)
errors.add("status", new ActionMessage("errors.required", "Session Status"));
// Check for duplicate academic initiative, year & term
if (errors.size()==0) {
Session sessn = Session.getSessionUsingInitiativeYearTerm(academicInitiative, academicYear, academicTerm);
if (session.getSessionId()==null && sessn!=null)
errors.add("sessionId", new ActionMessage("errors.generic", "An academic session for the initiative, year and term already exists"));
if (session.getSessionId()!=null && sessn!=null) {
if (!session.getSessionId().equals(sessn.getSessionId()))
errors.add("sessionId", new ActionMessage("errors.generic", "Another academic session for the same initiative, year and term already exists"));
}
}
return errors;
}