當前位置: 首頁>>代碼示例>>Java>>正文


Java ActionErrors.add方法代碼示例

本文整理匯總了Java中org.apache.struts.action.ActionErrors.add方法的典型用法代碼示例。如果您正苦於以下問題:Java ActionErrors.add方法的具體用法?Java ActionErrors.add怎麽用?Java ActionErrors.add使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在org.apache.struts.action.ActionErrors的用法示例。


在下文中一共展示了ActionErrors.add方法的15個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的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);
}
 
開發者ID:NCAR,項目名稱:joai-project,代碼行數:32,代碼來源:StandAloneSchemEditAction.java

示例2: validate

import org.apache.struts.action.ActionErrors; //導入方法依賴的package包/類
/**
 * This is the action called from the Struts framework.
 * @param mapping The ActionMapping used to select this instance.
 * @param request The HTTP Request we are processing.
 * @return
 */
public ActionErrors validate(ActionMapping mapping, HttpServletRequest request) {
	
	 System.out.println("LoginForm:validate()");
    ActionErrors errors = new ActionErrors();
    if (userName == null || userName.length() < 1) {
        errors.add("userName", new ActionMessage("error.userName.required"));
        // TODO: add 'error.name.required' key to your resources
    }
    if (password == null || password.length() < 1) {
        errors.add("password", new ActionMessage("error.password.required"));
        // TODO: add 'error.name.required' key to your resources
    }
    return errors;
}
 
開發者ID:Illusionist80,項目名稱:SpringTutorial,代碼行數:21,代碼來源:LoginForm.java

示例3: validate

import org.apache.struts.action.ActionErrors; //導入方法依賴的package包/類
public ActionErrors validate(ActionMapping mapping, HttpServletRequest request) {
    ActionErrors errors = new ActionErrors();

    if (iReports==null || iReports.length==0)
        errors.add("reports", new ActionMessage("errors.generic", "No report selected."));
    
    if (!iAll && (iSubjects==null || iSubjects.length==0))
        errors.add("subjects", new ActionMessage("errors.generic", "No subject area selected."));
    
    return errors;
}
 
開發者ID:Jenner4S,項目名稱:unitimes,代碼行數:12,代碼來源:EnrollmentAuditPdfReportForm.java

示例4: handleRemoveRecords

import org.apache.struts.action.ActionErrors; //導入方法依賴的package包/類
/**
 *  Remove records from the set of records to operate upon and return a forward
 *  to the appropriate batch operation page.
 *
 *@param  request  Description of the Parameter
 *@param  bof      Description of the Parameter
 *@param  mapping  Description of the Parameter
 *@param  forward  Description of the Parameter
 *@return          Description of the Return Value
 */
private ActionForward handleRemoveRecords(
		HttpServletRequest request,
		BatchOperationsForm bof,
		ActionMapping mapping,
		String forward) {
	ActionErrors errors = new ActionErrors();
	SimpleLuceneIndex index = repositoryManager.getIndex();
	RecordList recsToRemove = new RecordList(request.getParameterValues("rmId"), index);

	if (!recsToRemove.isEmpty()) {
		// RecordList prunedRecs = new RecordList(new ArrayList(), index);
		RecordList prunedRecs = new RecordList(index);
		RecordList records = bof.getRecordList();
		for (Iterator i = records.iterator(); i.hasNext(); ) {
			String id = (String) i.next();
			if (!recsToRemove.contains(id)) {
				prunedRecs.add(id);
			} else {
				this.getSessionBean(request).releaseLock(id);
			}
		}
		bof.setRecordList(prunedRecs);
		errors.add("message", new ActionError("generic.message", recsToRemove.size() + " items removed from list."));

	} else {
		errors.add("error", new ActionError("generic.error", "Record list unchanged - no items were selected to remove"));
	}
	saveErrors(request, errors);
	return mapping.findForward(forward);
}
 
開發者ID:NCAR,項目名稱:joai-project,代碼行數:41,代碼來源:BatchOperationsAction.java

示例5: validate

import org.apache.struts.action.ActionErrors; //導入方法依賴的package包/類
/**
 * This is the action called from the Struts framework.
 *
 * @param mapping The ActionMapping used to select this instance.
 * @param request The HTTP Request we are processing.
 * @return
 */
public ActionErrors validate(ActionMapping mapping, HttpServletRequest request) {
    ActionErrors errors = new ActionErrors();
    if (getName() == null || getName().length() < 1) {
        errors.add("name", new ActionMessage("error.name.required"));
        // TODO: add 'error.name.required' key to your resources
    }
    return errors;
}
 
開發者ID:bragex,項目名稱:the-vigilantes,代碼行數:16,代碼來源:LoginForm.java

示例6: 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(deptCode==null || deptCode.equalsIgnoreCase("")) {
       	errors.add("deptCode", 
                   new ActionMessage("errors.required", "Department") );
       }
       
       return errors;
}
 
開發者ID:Jenner4S,項目名稱:unitimes,代碼行數:19,代碼來源:RoomGroupListForm.java

示例7: validate

import org.apache.struts.action.ActionErrors; //導入方法依賴的package包/類
public ActionErrors validate(ActionMapping mapping, HttpServletRequest request) {
       ActionErrors errors = new ActionErrors();

       if(iLevel==null || iLevel.trim().length()==0)
           errors.add("level", new ActionMessage("errors.required", ""));
       
       return errors;
}
 
開發者ID:Jenner4S,項目名稱:unitimes,代碼行數:9,代碼來源:SolverLogForm.java

示例8: validate

import org.apache.struts.action.ActionErrors; //導入方法依賴的package包/類
@Override
   public ActionErrors validate(ActionMapping arg0, HttpServletRequest arg1) {
ActionErrors ac = new ActionErrors();
ac.add(ActionMessages.GLOBAL_MESSAGE, new ActionMessage("this is an error"));

return ac;
   }
 
開發者ID:lamsfoundation,項目名稱:lams,代碼行數:8,代碼來源:AuthoringForm.java

示例9: setGlobalDef

import org.apache.struts.action.ActionErrors; //導入方法依賴的package包/類
private ActionErrors setGlobalDef (String path, SchemaHelper schemaHelper, SchemaViewerForm svf) {
	ActionErrors errors = new ActionErrors ();
	GlobalDef globalDef = schemaHelper.getGlobalDefFromXPath(path);
	if (globalDef == null) {
		errors.add(errors.GLOBAL_ERROR,
			new ActionError("schemaviewer.def.notfound.error", path));
	}
	else {
		svf.setGlobalDef(globalDef);
		// svf.setTypeName(globalDef.getName());
	}
	return errors;
}
 
開發者ID:NCAR,項目名稱:joai-project,代碼行數:14,代碼來源:SchemaViewerAction.java

示例10: saveOrUpdateCondition

import org.apache.struts.action.ActionErrors; //導入方法依賴的package包/類
/**
    * This method will get necessary information from taskList item form and save or update into
    * <code>HttpSession</code> ChatItemList. Notice, this save is not persist them into database, just save
    * <code>HttpSession</code> temporarily. Only they will be persist when the entire authoring page is being
    * persisted.
    *
    * @param mapping
    * @param form
    * @param request
    * @param response
    * @return
    * @throws ServletException
    */
   private ActionForward saveOrUpdateCondition(ActionMapping mapping, ActionForm form, HttpServletRequest request,
    HttpServletResponse response) {

ChatConditionForm conditionForm = (ChatConditionForm) form;
ActionErrors errors = validateChatCondition(conditionForm, request);

if (!errors.isEmpty()) {
    this.addErrors(request, errors);
    return mapping.findForward("addcondition");
}

try {
    extractFormToChatCondition(request, conditionForm);
} catch (Exception e) {
    // any upload exception will display as normal error message rather then throw exception directly
    errors.add(ActionMessages.GLOBAL_MESSAGE,
	    new ActionMessage(ChatConstants.ERROR_MSG_CONDITION, e.getMessage()));
    if (!errors.isEmpty()) {
	this.addErrors(request, errors);
	return mapping.findForward("addcondition");
    }
}
// set session map ID so that itemlist.jsp can get sessionMAP
request.setAttribute(ChatConstants.ATTR_SESSION_MAP_ID, conditionForm.getSessionMapID());
// return null to close this window
return mapping.findForward(ChatConstants.SUCCESS);
   }
 
開發者ID:lamsfoundation,項目名稱:lams,代碼行數:41,代碼來源:AuthoringChatConditionAction.java

示例11: saveOrUpdateCondition

import org.apache.struts.action.ActionErrors; //導入方法依賴的package包/類
/**
    * This method will get necessary information from taskList item form and save or update into
    * <code>HttpSession</code> NotebookItemList. Notice, this save is not persist them into database, just save
    * <code>HttpSession</code> temporarily. Only they will be persist when the entire authoring page is being
    * persisted.
    *
    * @param mapping
    * @param form
    * @param request
    * @param response
    * @return
    * @throws ServletException
    */
   private ActionForward saveOrUpdateCondition(ActionMapping mapping, ActionForm form, HttpServletRequest request,
    HttpServletResponse response) {

NotebookConditionForm conditionForm = (NotebookConditionForm) form;
ActionErrors errors = validateNotebookCondition(conditionForm, request);

if (!errors.isEmpty()) {
    this.addErrors(request, errors);
    return mapping.findForward("addcondition");
}

try {
    extractFormToNotebookCondition(request, conditionForm);
} catch (Exception e) {
    // any upload exception will display as normal error message rather then throw exception directly
    errors.add(ActionMessages.GLOBAL_MESSAGE,
	    new ActionMessage(NotebookConstants.ERROR_MSG_CONDITION, e.getMessage()));
    if (!errors.isEmpty()) {
	this.addErrors(request, errors);
	return mapping.findForward("addcondition");
    }
}
// set session map ID so that itemlist.jsp can get sessionMAP
request.setAttribute(NotebookConstants.ATTR_SESSION_MAP_ID, conditionForm.getSessionMapID());
// return null to close this window
return mapping.findForward(NotebookConstants.SUCCESS);
   }
 
開發者ID:lamsfoundation,項目名稱:lams,代碼行數:41,代碼來源:AuthoringNotebookConditionAction.java

示例12: execute

import org.apache.struts.action.ActionErrors; //導入方法依賴的package包/類
/**
    * Process the specified HTTP request, and create the corresponding HTTP
    * response (or forward to another web component that will create it).
    * Return an <code>ActionForward</code> instance describing where and how
    * control should be forwarded, or <code>null</code> if the response has
    * already been completed.
    *
    * @param mapping The ActionMapping used to select this instance
    * @param actionForm The optional ActionForm bean for this request (if any)
    * @param request The HTTP request we are processing
    * @param response The HTTP response we are creating
    *
    * @exception IOException if an input/output error occurs
    * @exception ServletException if a servlet exception occurs
    */
   public ActionForward execute(ActionMapping mapping,
			 ActionForm form,
			 HttpServletRequest request,
			 HttpServletResponse response)
throws IOException, ServletException {

// Extract attributes we will need
Locale locale = getLocale(request);
MessageResources messages = getResources(request);
HttpSession session = request.getSession();
User user = (User) session.getAttribute(Constants.USER_KEY);

// Process this user logoff
if (user != null) {
    if (debug)
        servlet.log("LogoffAction: User '" + user.getUsername() +
                    "' logged off in session " + session.getId());
} else {
    if (debug)
        servlet.log("LogoffActon: User logged off in session " +
                    session.getId());
}
session.removeAttribute(Constants.USER_KEY);
session.invalidate();

ActionErrors errors = new ActionErrors ();
errors.add("message",
	new ActionError("logoff.success"));
saveErrors(request, errors);

// Forward control to the specified success URI
return (mapping.findForward("logoff"));

   }
 
開發者ID:NCAR,項目名稱:joai-project,代碼行數:50,代碼來源:LogoffAction.java

示例13: validate

import org.apache.struts.action.ActionErrors; //導入方法依賴的package包/類
public ActionErrors validate(ActionMapping mapping, HttpServletRequest request) {
    ActionErrors errors = new ActionErrors();
  
    if(deptUniqueId==null || deptUniqueId.equalsIgnoreCase("")) {
    	errors.add("deptUniqueId", 
                new ActionMessage("errors.generic", MSG.errorRequiredDepartment()) );
    }
   
    return errors;
}
 
開發者ID:Jenner4S,項目名稱:unitimes,代碼行數:11,代碼來源:InstructorSearchForm.java

示例14: validateForm

import org.apache.struts.action.ActionErrors; //導入方法依賴的package包/類
/**
 *  Validate the input from user. Put changed or default values into carForm.
 *  After this method returns carForm (rather than request) is used to process
 *  user input
 *
 * @param  request       Description of the Parameter
 * @param  carForm       Description of the Parameter
 * @param  adnFramework  NOT YET DOCUMENTED
 * @return               Description of the Return Value
 */
protected ActionErrors validateForm(HttpServletRequest request,
                                    CreateADNRecordForm carForm,
                                    MetaDataFramework adnFramework) {
	ActionErrors errors = new ActionErrors();

	String title = request.getParameter("title");
	if ((title != null) && (title.trim().equals(""))) {
		errors.add("title", new ActionError("field.required", "title"));
	}
	else {
		carForm.setTitle(title.trim());
	}

	String primaryUrl = request.getParameter("primaryUrl");
	// does url value exist?
	if ((primaryUrl != null) && (primaryUrl.trim().equals(""))) {
		errors.add("primaryUrl", new ActionError("field.required", "Url"));
		return errors;
	}

	try {
		primaryUrl = UrlHelper.normalize(primaryUrl);
		UrlHelper.validateUrl(primaryUrl);
	} catch (MalformedURLException e) {
		if (e.getMessage() == null)
			errors.add("primaryUrl", new ActionError("generic.error", "malformed url"));
		else
			errors.add("primaryUrl", new ActionError("generic.error", "malformed url: " + e.getMessage()));
		return errors;
	}

	primaryUrl = primaryUrl.trim();
	carForm.setPrimaryUrl(primaryUrl);

	//  check dups if this framework has specified primaryUrl as a "uniqueUrl" valueType
	if (adnFramework.getUniqueUrlPath() != null) {
		List dups = repositoryService.getDups(primaryUrl, carForm.getCollection());
		carForm.setDups(dups);
		if (dups.size() > 0) {
			errors.add("primaryUrl", new ActionError("invalid.url", "URL already cataloged in this collection"));
		}
	}

	return errors;
}
 
開發者ID:NCAR,項目名稱:joai-project,代碼行數:56,代碼來源:CreateADNRecordAction.java

示例15: validate

import org.apache.struts.action.ActionErrors; //導入方法依賴的package包/類
public ActionErrors validate(ActionMapping mapping, HttpServletRequest request) {
	ActionErrors errors = new ActionErrors();
	
       if(iName==null || iName.trim().equalsIgnoreCase("")) {
       	errors.add("name", new ActionMessage("errors.required", "Name") );
       }
       if(iName!=null && iName.trim().length() > 100) {
       	errors.add("name", new ActionMessage("errors.maxlength", "Name", "100") );
       }
       
       if (iAbbv==null || iAbbv.trim().equalsIgnoreCase("")) {
       	errors.add("abbv", new ActionMessage("errors.required", "Abbreviation") );
       }
       
       if (iAbbv!=null && iAbbv.trim().length() > 20) {
       	errors.add("abbv", new ActionMessage("errors.maxlength", "Abbreviation", "20") );
       }

       if (iDeptCode==null || iDeptCode.trim().equalsIgnoreCase("")) {
       	errors.add("deptCode", new ActionMessage("errors.required", "Code") );
       }
       
       if (iDeptCode!=null && iDeptCode.trim().length() > 50) {
       	errors.add("deptCode", new ActionMessage("errors.maxlength", "Code", "50") );
       }

       if (iIsExternal && (iExtName==null || iExtName.trim().length()==0)) {
       	errors.add("extName", new ActionMessage("errors.required", "External Manager Name") );
       }
       
       if (!iIsExternal && iExtName!=null && iExtName.trim().length() > 0){ 	
       	errors.add("extName", new ActionMessage("errors.generic", "External Manager Name should only be used when the department is marked as 'External Manager'") );
       }
       
       if (iIsExternal && (iExtName!=null && iExtName.trim().length() > 30)) {
       	errors.add("extName", new ActionMessage("errors.maxlength", "External Manager Name", "30") );
       }

       if (iIsExternal && (iExtAbbv==null || iExtAbbv.trim().length()==0)) {
       	errors.add("extAbbv", new ActionMessage("errors.required", "External Manager Abbreviation") );
       }
       
       if (!iIsExternal && iExtAbbv!=null && iExtAbbv.trim().length() > 0){
       	errors.add("extName", new ActionMessage("errors.generic", "External Manager Abbreviation should only be used when the department is marked as 'External Manager'") );      	
       }
       
       if (iIsExternal && (iExtAbbv!=null && iExtAbbv.trim().length() > 10)) {
       	errors.add("extAbbv", new ActionMessage("errors.maxlength", "External Manager Abbreviation", "10") );
       }

       try {
		Department dept = Department.findByDeptCode(iDeptCode, iSessionId);
		if (dept!=null && !dept.getUniqueId().equals(iId)) {
			errors.add("deptCode", new ActionMessage("errors.exists", iDeptCode));
		}
		
	} catch (Exception e) {
		Debug.error(e);
		errors.add("deptCode", new ActionMessage("errors.generic", e.getMessage()));
	}
	
	return errors;
}
 
開發者ID:Jenner4S,項目名稱:unitimes,代碼行數:64,代碼來源:DepartmentEditForm.java


注:本文中的org.apache.struts.action.ActionErrors.add方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。