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


Java ActionMessages類代碼示例

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


ActionMessages類屬於org.apache.struts.action包,在下文中一共展示了ActionMessages類的15個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。

示例1: validate

import org.apache.struts.action.ActionMessages; //導入依賴的package包/類
private ActionMessages validate(AuthoringForm sbmtForm, ActionMapping mapping, HttpServletRequest request) {
ActionMessages errors = new ActionMessages();
// if (StringUtils.isBlank(sbmtForm.getTitle())) {
// ActionMessage error = new ActionMessage("error.title.blank");
// errors.add(ActionMessages.GLOBAL_MESSAGE, error);
// }
// define it later mode(TEACHER) skip below validation.
String modeStr = request.getParameter(AttributeNames.ATTR_MODE);
if (StringUtils.equals(modeStr, ToolAccessMode.TEACHER.toString())) {
    return errors;
}

// Some other validation outside basic Tab.

return errors;
   }
 
開發者ID:lamsfoundation,項目名稱:lams,代碼行數:17,代碼來源:AuthoringAction.java

示例2: validateNamespaceIdentifier

import org.apache.struts.action.ActionMessages; //導入依賴的package包/類
/**
 *  Validates that the String is a valid namespace identifier for OAI.
 *
 * @param  bean            The Struts bean
 * @param  va              the ValidatorAction
 * @param  field           The Field
 * @param  messages        The ActionMessages
 * @param  validator       The Validator
 * @param  request         The HttpServletRequest
 * @param  servletContext  The ServletContext
 * @return                 True if valid
 */
public static boolean validateNamespaceIdentifier(
                                          Object bean,
                                          ValidatorAction va,
                                          Field field,
                                          ActionMessages messages,
                                          Validator validator,
                                          HttpServletRequest request,
                                          ServletContext servletContext) {		
	// Get the value the user entered:
	String repositoryIdentifier = ValidatorUtils.getValueAsString(bean, field.getProperty());
	boolean isValid = (
			repositoryIdentifier == null || 
			repositoryIdentifier.length() == 0 ||
			repositoryIdentifier.matches("[a-zA-Z][a-zA-Z0-9\\-]*(\\.[a-zA-Z][a-zA-Z0-9\\-]+)+"));
	if(!isValid) {
		ActionMessage message = Resources.getActionMessage(validator, request, va, field);
		messages.add(field.getKey(), message);			
	}
	return isValid;
}
 
開發者ID:NCAR,項目名稱:joai-project,代碼行數:33,代碼來源:FieldValidators.java

示例3: validateSurveyItem

import org.apache.struts.action.ActionMessages; //導入依賴的package包/類
/**
    * Vaidate survey item regards to their type (url/file/learning object/website zip file)
    *
    * @param itemForm
    * @param instructionList
    * @return
    */
   private ActionErrors validateSurveyItem(QuestionForm itemForm, List<String> instructionList) {
ActionErrors errors = new ActionErrors();
if (StringUtils.isBlank(itemForm.getQuestion().getDescription())) {
    errors.add(ActionMessages.GLOBAL_MESSAGE, new ActionMessage(SurveyConstants.ERROR_MSG_DESC_BLANK));
}

short type = getQuestionType(itemForm);
if (type != SurveyConstants.QUESTION_TYPE_TEXT_ENTRY) {
    if (instructionList == null || instructionList.size() < 2) {
	errors.add(ActionMessages.GLOBAL_MESSAGE, new ActionMessage(SurveyConstants.ERROR_MSG_LESS_OPTIONS));
    }
}

return errors;
   }
 
開發者ID:lamsfoundation,項目名稱:lams,代碼行數:23,代碼來源:AuthoringAction.java

示例4: rollClassInstructorsForward

import org.apache.struts.action.ActionMessages; //導入依賴的package包/類
public void rollClassInstructorsForward(ActionMessages errors,
		RollForwardSessionForm rollForwardSessionForm) {
	Session toSession = Session.getSessionById(rollForwardSessionForm.getSessionToRollForwardTo());
	ArrayList subjects = new ArrayList();
	SubjectAreaDAO saDao = new SubjectAreaDAO();
	for (int i = 0; i <	rollForwardSessionForm.getRollForwardClassInstrSubjectIds().length; i++){
		subjects.add(saDao.get(Long.parseLong(rollForwardSessionForm.getRollForwardClassInstrSubjectIds()[i])));
	}
	if (toSession.getSubjectAreas() != null) {
		SubjectArea subjectArea = null;
		for (Iterator saIt = subjects.iterator(); saIt.hasNext();){
			subjectArea = (SubjectArea) saIt.next();
			SubjectArea.loadSubjectAreas(toSession.getUniqueId());
			rollForwardClassInstructorsForASubjectArea(subjectArea.getSubjectAreaAbbreviation(), toSession);
		}
	}		
}
 
開發者ID:Jenner4S,項目名稱:unitimes,代碼行數:18,代碼來源:SessionRollForward.java

示例5: addRoomFeatPref

import org.apache.struts.action.ActionMessages; //導入依賴的package包/類
/**
 * Add a room feature preference to the list (UI)
 * @param request
 * @param frm
 * @param errors
 */
protected void addRoomFeatPref(
        HttpServletRequest request, 
        PreferencesForm frm,
        ActionMessages errors ) {

    List lst = frm.getRoomFeaturePrefs();
    if(frm.checkPrefs(lst)) {
        for (int i=0; i<Constants.PREF_ROWS_ADDED; i++) {
         frm.addToRoomFeatPrefs(
                 Preference.BLANK_PREF_VALUE, 
                 Preference.BLANK_PREF_VALUE );
        }
        request.setAttribute(HASH_ATTR, HASH_RM_FEAT_PREF);
    }
    else {
        errors.add("roomFeaturePrefs", 
                   new ActionMessage(
                           "errors.generic", 
                           MSG.errorInvalidRoomFeaturePreference()) );
        saveErrors(request, errors);
    }
}
 
開發者ID:Jenner4S,項目名稱:unitimes,代碼行數:29,代碼來源:PreferencesAction.java

示例6: addBldgPref

import org.apache.struts.action.ActionMessages; //導入依賴的package包/類
/**
 * Add a building preference to the list (UI)
 * @param request
 * @param frm
 * @param errors
 */
protected void addBldgPref(
        HttpServletRequest request, 
        PreferencesForm frm,
        ActionMessages errors ) {
 
    List lst = frm.getBldgPrefs();
    if(frm.checkPrefs(lst)) {
        for (int i=0; i<Constants.PREF_ROWS_ADDED; i++) {
         frm.addToBldgPrefs(
                 Preference.BLANK_PREF_VALUE, 
                 Preference.BLANK_PREF_VALUE );
        }
        request.setAttribute(HASH_ATTR, HASH_BLDG_PREF);
    }
    else {
        errors.add("bldgPrefs", 
                   new ActionMessage(
                           "errors.generic", 
                           MSG.errorInvalidBuildingPreference()) );
        saveErrors(request, errors);
    }
}
 
開發者ID:Jenner4S,項目名稱:unitimes,代碼行數:29,代碼來源:PreferencesAction.java

示例7: validate

import org.apache.struts.action.ActionMessages; //導入依賴的package包/類
/**
    * Checks if the provided group/learner number is a nonnegative integer.
    */
   @Override
   public ActionMessages validate() {
ActionMessages errors = new ActionMessages();
boolean valid = true;
boolean numberValid = true;

String numberToParse = StringUtils.isEmpty(getNumberOfGroups()) ? getLearnersPerGroup() : getNumberOfGroups();
try {
    int number = Integer.parseInt(numberToParse);
    if (number < 0) {
	numberValid = false;
    }
} catch (Exception e) {
    numberValid = false;
}
if (!numberValid) {
    errors.add(ActionMessages.GLOBAL_MESSAGE, new ActionMessage("error.planner.grouping.number.integer"));
    valid = false;
}
setValid(valid);
return errors;
   }
 
開發者ID:lamsfoundation,項目名稱:lams,代碼行數:26,代碼來源:PedagogicalPlannerGroupingForm.java

示例8: validateBeforeFinish

import org.apache.struts.action.ActionMessages; //導入依賴的package包/類
private boolean validateBeforeFinish(HttpServletRequest request, String sessionMapID) {
SessionMap<String, Object> sessionMap = (SessionMap<String, Object>) request.getSession().getAttribute(sessionMapID);
Long sessionId = (Long) sessionMap.get(AttributeNames.PARAM_TOOL_SESSION_ID);

HttpSession ss = SessionManager.getSession();
UserDTO user = (UserDTO) ss.getAttribute(AttributeNames.USER);
Long userID = new Long(user.getUserID().longValue());

IResourceService service = getResourceService();
int miniViewFlag = service.checkMiniView(sessionId, userID);
// if current user view less than reqired view count number, then just return error message.
if (miniViewFlag > 0) {
    ActionErrors errors = new ActionErrors();
    errors.add(ActionMessages.GLOBAL_MESSAGE,
	    new ActionMessage("lable.learning.minimum.view.number.less", miniViewFlag));
    this.addErrors(request, errors);
    return false;
}

return true;
   }
 
開發者ID:lamsfoundation,項目名稱:lams,代碼行數:22,代碼來源:LearningAction.java

示例9: validateBeforeFinish

import org.apache.struts.action.ActionMessages; //導入依賴的package包/類
private boolean validateBeforeFinish(HttpServletRequest request, String sessionMapID) {
SessionMap<String, Object> sessionMap = (SessionMap<String, Object>) request.getSession().getAttribute(sessionMapID);
Long sessionId = (Long) sessionMap.get(AttributeNames.PARAM_TOOL_SESSION_ID);

HttpSession ss = SessionManager.getSession();
UserDTO user = (UserDTO) ss.getAttribute(AttributeNames.USER);
Long userID = new Long(user.getUserID().longValue());

ICommonCartridgeService service = getCommonCartridgeService();
int miniViewFlag = service.checkMiniView(sessionId, userID);
// if current user view less than reqired view count number, then just return error message.
if (miniViewFlag > 0) {
    ActionErrors errors = new ActionErrors();
    errors.add(ActionMessages.GLOBAL_MESSAGE,
	    new ActionMessage("lable.learning.minimum.view.number.less", miniViewFlag));
    this.addErrors(request, errors);
    return false;
}

return true;
   }
 
開發者ID:lamsfoundation,項目名稱:lams,代碼行數:22,代碼來源:LearningAction.java

示例10: setHolidays

import org.apache.struts.action.ActionMessages; //導入依賴的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));
}
 
開發者ID:Jenner4S,項目名稱:unitimes,代碼行數:19,代碼來源:SessionEditAction.java

示例11: validateImageGalleryItem

import org.apache.struts.action.ActionMessages; //導入依賴的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;
   }
 
開發者ID:lamsfoundation,項目名稱:lams,代碼行數:29,代碼來源:ImageGalleryUtils.java

示例12: validateMultipleImages

import org.apache.struts.action.ActionMessages; //導入依賴的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;
   }
 
開發者ID:lamsfoundation,項目名稱:lams,代碼行數:26,代碼來源:ImageGalleryUtils.java

示例13: validateBeforeFinish

import org.apache.struts.action.ActionMessages; //導入依賴的package包/類
private boolean validateBeforeFinish(HttpServletRequest request, String sessionMapID) {
SessionMap<String, Object> sessionMap = (SessionMap<String, Object>) request.getSession().getAttribute(sessionMapID);
Long sessionId = (Long) sessionMap.get(AttributeNames.PARAM_TOOL_SESSION_ID);

HttpSession ss = SessionManager.getSession();
UserDTO user = (UserDTO) ss.getAttribute(AttributeNames.USER);
Long userID = new Long(user.getUserID().longValue());

ITaskListService service = getTaskListService();

int numberCompletedTasks = service.getNumTasksCompletedByUser(sessionId, userID);
int minimumNumberTasks = service.getTaskListBySessionId(sessionId).getMinimumNumberTasks();
// if current user view less than reqired view count number, then just return error message.
if ((minimumNumberTasks - numberCompletedTasks) > 0) {
    ActionErrors errors = new ActionErrors();
    errors.add(ActionMessages.GLOBAL_MESSAGE,
	    new ActionMessage("lable.learning.minimum.view.number", minimumNumberTasks, numberCompletedTasks));
    this.addErrors(request, errors);
    return false;
}

return true;
   }
 
開發者ID:lamsfoundation,項目名稱:lams,代碼行數:24,代碼來源:LearningAction.java

示例14: addDistPref

import org.apache.struts.action.ActionMessages; //導入依賴的package包/類
protected void addDistPref(
        HttpServletRequest request, 
        PreferencesForm frm,
        ActionMessages errors ) {
 
    List lst = frm.getDistPrefs();
    if(frm.checkPrefs(lst)) {
        for (int i=0; i<Constants.PREF_ROWS_ADDED; i++) {
         frm.addToDistPrefs(
                 Preference.BLANK_PREF_VALUE, 
                 Preference.BLANK_PREF_VALUE );
        }
        request.setAttribute(HASH_ATTR, HASH_DIST_PREF);
    }
    else {
        errors.add("distPrefs", 
                   new ActionMessage(
                           "errors.generic", 
                           MSG.errorInvalidDistributionPreference()) );
        saveErrors(request, errors);
    }
}
 
開發者ID:Jenner4S,項目名稱:unitimes,代碼行數:23,代碼來源:PreferencesAction.java

示例15: validateInteger

import org.apache.struts.action.ActionMessages; //導入依賴的package包/類
/**
 * Checks if the field can safely be converted to an int primitive.
 *
 * @param  bean     The bean validation is being performed on.
 * @param  va       The <code>ValidatorAction</code> that is currently being performed.
 * @param  field    The <code>Field</code> object associated with the current
 *      field being validated.
 * @param  errors   The <code>ActionMessages</code> object to add errors to if any
 *      validation errors occur.
 * @param validator The <code>Validator</code> instance, used to access
 * other field values.
 * @param  request  Current request object.
 * @return true if valid, false otherwise.
 */
public static Object validateInteger(Object bean,
                                      ValidatorAction va, Field field,
                                      ActionMessages errors,
                                      Validator validator,
                                      HttpServletRequest request) {
    Object result = null;
    String value = null;
    if (isString(bean)) {
        value = (String) bean;
    } else {
        value = ValidatorUtils.getValueAsString(bean, field.getProperty());
    }

    if (GenericValidator.isBlankOrNull(value)) {
        return Boolean.TRUE;
    }

    result = GenericTypeValidator.formatInt(value);

    if (result == null) {
        errors.add(field.getKey(), Resources.getActionMessage(validator, request, va, field));
    }

    return result == null ? Boolean.FALSE : result;
}
 
開發者ID:lamsfoundation,項目名稱:lams,代碼行數:40,代碼來源:FieldChecks.java


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