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


Java ActionErrors.isEmpty方法代碼示例

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


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

示例1: execute

import org.apache.struts.action.ActionErrors; //導入方法依賴的package包/類
public ActionForward execute (
		ActionMapping mapping,
		ActionForm form,
		HttpServletRequest request,
		HttpServletResponse response)
	throws IOException, ServletException {

	SchemEditForm sef = (SchemEditForm) form;
	ActionErrors errors = initializeFromContext (mapping, request);
	if (!errors.isEmpty()) {
		saveErrors (request, errors);
		return (mapping.findForward("error.page"));
	}
	
	String errorMsg;
	recordsDir = getRecordsDir();
	if (recordsDir == null) {
		errorMsg = "attribute \"recordsDir\" not found";
		prtln(errorMsg);
		throw new ServletException(errorMsg);
	}
	sef.setRecordsDir(recordsDir);
	
	return super.execute (mapping, form, request, response);
}
 
開發者ID:NCAR,項目名稱:joai-project,代碼行數:26,代碼來源:StandAloneSchemEditAction.java

示例2: getAnswers

import org.apache.struts.action.ActionErrors; //導入方法依賴的package包/類
/**
    * Get all answer for all questions in this page
    *
    * @param request
    * @return
    */
   private ActionErrors getAnswers(HttpServletRequest request) {
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);
Collection<AnswerDTO> answerDtoList = getQuestionList(sessionMap).values();

for (AnswerDTO answerDto : answerDtoList) {
    SurveyAnswer answer = getAnswerFromPage(request, answerDto, sessionID);
    answerDto.setAnswer(answer);
    validateAnswers(request, answerDto, errors, answer);
}
if (!errors.isEmpty()) {
    addErrors(request, errors);
}
return errors;
   }
 
開發者ID:lamsfoundation,項目名稱:lams,代碼行數:26,代碼來源:LearningAction.java

示例3: initializeSuggestor

import org.apache.struts.action.ActionErrors; //導入方法依賴的package包/類
/**
 *  NOT YET DOCUMENTED
 *
 * @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  ServletException  NOT YET DOCUMENTED
 */
protected ActionForward initializeSuggestor(
                                            ActionMapping mapping,
                                            ActionForm form,
                                            HttpServletRequest request,
                                            HttpServletResponse response)
	 throws ServletException {

	SuggestResourceForm srf = (SuggestResourceForm) form;
	ActionErrors errors = validateUrl(form, mapping, request);

	// this suggestor only cares about DuplicatePrimaries (not similars, etc)
	if (errors.isEmpty() && srf.getDupRecord() != null) {
		prtln("getDupRecord found");
		return mapping.findForward("duplicate");
	}

	if (!errors.isEmpty()) {
		saveErrors(request, errors);
		return mapping.findForward("home");
	}

	// if validateUrl has been set in form by validateUrl
	String verifiedUrl = srf.getUrl();
	prtln("verifiedUrl: " + verifiedUrl);

	return mapping.findForward("form");
}
 
開發者ID:NCAR,項目名稱:joai-project,代碼行數:38,代碼來源:SuggestResourceAction.java

示例4: 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> TaskListItemList. 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) {

TaskListConditionForm conditionForm = (TaskListConditionForm) form;
ActionErrors errors = validateTaskListCondition(conditionForm, request);

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

try {
    extractFormToTaskListCondition(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(TaskListConstants.ERROR_MSG_UPLOAD_FAILED, e.getMessage()));
    if (!errors.isEmpty()) {
	populateFormWithPossibleItems(form, request);
	this.addErrors(request, errors);
	return mapping.findForward("addcondition");
    }
}
// set session map ID so that itemlist.jsp can get sessionMAP
request.setAttribute(TaskListConstants.ATTR_SESSION_MAP_ID, conditionForm.getSessionMapID());
// return null to close this window
return mapping.findForward(TaskListConstants.SUCCESS);
   }
 
開發者ID:lamsfoundation,項目名稱:lams,代碼行數:43,代碼來源:AuthoringTaskListConditionAction.java

示例5: saveOrUpdateCondition

import org.apache.struts.action.ActionErrors; //導入方法依賴的package包/類
/**
    * This method will get necessary information from condition form and save or update into <code>HttpSession</code>
    * condition list. 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) {

ForumConditionForm conditionForm = (ForumConditionForm) form;
ActionErrors errors = validateForumCondition(conditionForm, request);

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

try {
    extractFormToForumCondition(request, conditionForm);
} catch (Exception e) {

    errors.add(ActionMessages.GLOBAL_MESSAGE, new ActionMessage("error.condition", e.getMessage()));
    if (!errors.isEmpty()) {
	populateFormWithPossibleItems(form, request);
	this.addErrors(request, errors);
	return mapping.findForward("addcondition");
    }
}

request.setAttribute(ForumConstants.ATTR_SESSION_MAP_ID, conditionForm.getSessionMapID());

return mapping.findForward(ForumConstants.SUCCESS);
   }
 
開發者ID:lamsfoundation,項目名稱:lams,代碼行數:41,代碼來源:AuthoringConditionAction.java

示例6: saveMultipleImages

import org.apache.struts.action.ActionErrors; //導入方法依賴的package包/類
/**
    * Save file or url imageGallery item into database.
    *
    * @param mapping
    * @param form
    * @param request
    * @param response
    * @return
    * @throws IOException 
    */
   private ActionForward saveMultipleImages(ActionMapping mapping, ActionForm form, HttpServletRequest request,
    HttpServletResponse response) throws IOException {
MultipleImagesForm multipleForm = (MultipleImagesForm) form;
SessionMap<String, Object> sessionMap = (SessionMap<String, Object>) request.getSession().getAttribute(multipleForm.getSessionMapID());
ToolAccessMode mode = (ToolAccessMode) sessionMap.get(AttributeNames.ATTR_MODE);

//validate form
boolean isLargeFilesAllowed = mode.isTeacher();
ActionErrors errors = ImageGalleryUtils.validateMultipleImages(multipleForm, isLargeFilesAllowed);

try {
    if (errors.isEmpty()) {
	extractMultipleFormToImageGalleryItems(request, multipleForm);
    }
} catch (Exception e) {
    // any upload exception will display as normal error message rather then throw exception directly
    errors.add(ActionMessages.GLOBAL_MESSAGE,
	    new ActionMessage(ImageGalleryConstants.ERROR_MSG_UPLOAD_FAILED, e.getMessage()));
}

if (!errors.isEmpty()) {
    ServletOutputStream outputStream = response.getOutputStream();
    outputStream.print(errors.get().next().toString());
    response.setStatus(HttpServletResponse.SC_INTERNAL_SERVER_ERROR);
}

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

示例7: saveOrUpdateImage

import org.apache.struts.action.ActionErrors; //導入方法依賴的package包/類
/**
    * This method will get necessary information from imageGallery item form and save or update into
    * <code>HttpSession</code> ImageGalleryItemList. 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 saveOrUpdateImage(ActionMapping mapping, ActionForm form, HttpServletRequest request,
    HttpServletResponse response) {

ImageGalleryItemForm itemForm = (ImageGalleryItemForm) form;
ActionErrors errors = ImageGalleryUtils.validateImageGalleryItem(itemForm, true);

try {
    if (errors.isEmpty()) {
	extractFormToImageGalleryItem(request, itemForm);
    }
} catch (Exception e) {
    // any upload exception will display as normal error message rather then throw exception directly
    errors.add(ActionMessages.GLOBAL_MESSAGE,
	    new ActionMessage(ImageGalleryConstants.ERROR_MSG_UPLOAD_FAILED, e.getMessage()));
}

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

// set session map ID so that itemlist.jsp can get sessionMAP
request.setAttribute(ImageGalleryConstants.ATTR_SESSION_MAP_ID, itemForm.getSessionMapID());
// return null to close this window
return mapping.findForward(ImageGalleryConstants.SUCCESS);
   }
 
開發者ID:lamsfoundation,項目名稱:lams,代碼行數:40,代碼來源:AuthoringAction.java

示例8: saveOrUpdateQuestion

import org.apache.struts.action.ActionErrors; //導入方法依賴的package包/類
/**
    * This method will get necessary information from daco question form and save or update into
    * <code>HttpSession</code>
    * DacoQuestionList. 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
    */
   protected ActionForward saveOrUpdateQuestion(ActionMapping mapping, ActionForm form, HttpServletRequest request) {
List<String> answerOptionList = getAnswerOptionsFromRequest(request);
List<String> longlatMaps = geSelectedMapsFromRequest(request);
DacoQuestionForm questionForm = (DacoQuestionForm) form;
ActionErrors errors = validateDacoQuestionForm(questionForm, answerOptionList);

if (!errors.isEmpty()) {
    this.addErrors(request, errors);
    ensureMinimumAnswerOptions(answerOptionList);
    request.setAttribute(DacoConstants.ATTR_ANSWER_OPTION_LIST, answerOptionList);
    request.setAttribute(DacoConstants.PARAM_LONGLAT_MAPS_SELECTED, longlatMaps);
    return findForward(questionForm.getQuestionType(), mapping);
}

try {
    List<String> listToSave = answerOptionList == null ? longlatMaps : answerOptionList;
    extractFormToDacoQuestion(request, listToSave, questionForm);
} catch (Exception e) {
    e.printStackTrace();
    // any upload exception will display as normal error message rather
    // then throw exception directly
    errors.add(ActionMessages.GLOBAL_MESSAGE,
	    new ActionMessage(DacoConstants.ERROR_MSG_UPLOAD_FAILED, e.getMessage()));
    if (!errors.isEmpty()) {
	this.addErrors(request, errors);
	request.setAttribute(DacoConstants.ATTR_ANSWER_OPTION_LIST, answerOptionList);
	request.setAttribute(DacoConstants.PARAM_LONGLAT_MAPS_SELECTED, longlatMaps);
	return findForward(questionForm.getQuestionType(), mapping);
    }
}
// set session map ID so that questionlist.jsp can get sessionMAP
request.setAttribute(DacoConstants.ATTR_SESSION_MAP_ID, questionForm.getSessionMapID());
// return null to close this window
return mapping.findForward(DacoConstants.SUCCESS);
   }
 
開發者ID:lamsfoundation,項目名稱:lams,代碼行數:50,代碼來源:AuthoringAction.java

示例9: saveOrUpdateCondition

import org.apache.struts.action.ActionErrors; //導入方法依賴的package包/類
/**
    * This method will get necessary information from condition form and save or update into <code>HttpSession</code>
    * condition list. 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) {

SurveyConditionForm conditionForm = (SurveyConditionForm) form;
ActionErrors errors = validateSurveyCondition(conditionForm, request);

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

try {
    extractFormToSurveyCondition(request, conditionForm);
} catch (Exception e) {

    errors.add(ActionMessages.GLOBAL_MESSAGE, new ActionMessage("error.condition", e.getMessage()));
    if (!errors.isEmpty()) {
	populateFormWithPossibleItems(form, request);
	this.addErrors(request, errors);
	return mapping.findForward("addcondition");
    }
}

request.setAttribute(SurveyConstants.ATTR_SESSION_MAP_ID, conditionForm.getSessionMapID());

return mapping.findForward(SurveyConstants.SUCCESS);
   }
 
開發者ID:lamsfoundation,項目名稱:lams,代碼行數:41,代碼來源:AuthoringConditionAction.java

示例10: previousQuestion

import org.apache.struts.action.ActionErrors; //導入方法依賴的package包/類
private ActionForward previousQuestion(ActionMapping mapping, ActionForm form, HttpServletRequest request,
    HttpServletResponse response) {
AnswerForm answerForm = (AnswerForm) form;
Integer questionSeqID = answerForm.getQuestionSeqID();
String sessionMapID = answerForm.getSessionMapID();

SessionMap<String, Object> sessionMap = (SessionMap<String, Object>) request.getSession()
	.getAttribute(sessionMapID);
SortedMap<Integer, AnswerDTO> surveyItemMap = getQuestionList(sessionMap);

ActionErrors errors = getAnswer(request, surveyItemMap.get(questionSeqID));
if (!errors.isEmpty()) {
    return mapping.getInputForward();
}

SortedMap<Integer, AnswerDTO> subMap = surveyItemMap.headMap(questionSeqID);
if (subMap.isEmpty()) {
    questionSeqID = surveyItemMap.firstKey();
} else {
    questionSeqID = subMap.lastKey();
}

// get current question index of total questions
int currIdx = new ArrayList<Integer>(surveyItemMap.keySet()).indexOf(questionSeqID) + 1;
answerForm.setCurrentIdx(currIdx);

if (questionSeqID.equals(surveyItemMap.firstKey())) {
    answerForm.setPosition(SurveyConstants.POSITION_FIRST);
} else {
    answerForm.setPosition(SurveyConstants.POSITION_INSIDE);
}
answerForm.setQuestionSeqID(questionSeqID);
return mapping.findForward(SurveyConstants.SUCCESS);
   }
 
開發者ID:lamsfoundation,項目名稱:lams,代碼行數:35,代碼來源:LearningAction.java

示例11: startReflection

import org.apache.struts.action.ActionErrors; //導入方法依賴的package包/類
/**
    * Display empty reflection form.
    *
    * @param mapping
    * @param form
    * @param request
    * @param response
    * @return
    */
   protected ActionForward startReflection(ActionMapping mapping, ActionForm form, HttpServletRequest request) {

// get session value
String sessionMapID = WebUtil.readStrParam(request, DacoConstants.ATTR_SESSION_MAP_ID);

ActionErrors errors = validateBeforeFinish(request, sessionMapID);
if (!errors.isEmpty()) {
    this.addErrors(request, errors);
    refreshQuestionSummaries(mapping, request);
    request.setAttribute(DacoConstants.ATTR_DISPLAYED_RECORD_NUMBER,
	    request.getParameter(DacoConstants.ATTR_DISPLAYED_RECORD_NUMBER));
    return mapping.getInputForward();
}
SessionMap sessionMap = (SessionMap) request.getSession().getAttribute(sessionMapID);

Long toolSessionID = (Long) sessionMap.get(AttributeNames.PARAM_TOOL_SESSION_ID);
IDacoService service = getDacoService();
ReflectionForm reflectionForm = (ReflectionForm) form;
HttpSession httpSession = SessionManager.getSession();
UserDTO userDTO = (UserDTO) httpSession.getAttribute(AttributeNames.USER);
DacoUser user = service.getUserByUserIdAndSessionId(userDTO.getUserID().longValue(), toolSessionID);

reflectionForm.setUserId(userDTO.getUserID());
reflectionForm.setSessionId(toolSessionID);

// get the existing reflection entry

NotebookEntry entry = service.getEntry(toolSessionID, CoreNotebookConstants.NOTEBOOK_TOOL,
	DacoConstants.TOOL_SIGNATURE, userDTO.getUserID());

if (entry != null) {
    reflectionForm.setEntryText(entry.getEntry());
}
request.setAttribute(DacoConstants.ATTR_SESSION_MAP_ID, sessionMapID);
reflectionForm.setSessionMapID(sessionMapID);
return mapping.findForward(DacoConstants.SUCCESS);
   }
 
開發者ID:lamsfoundation,項目名稱:lams,代碼行數:47,代碼來源:LearningAction.java

示例12: saveOrUpdateItem

import org.apache.struts.action.ActionErrors; //導入方法依賴的package包/類
/**
    * This method will get necessary information from resource item form and
    * save or update into <code>HttpSession</code> ResourceItemList. 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 saveOrUpdateItem(ActionMapping mapping, ActionForm form, HttpServletRequest request,
    HttpServletResponse response) {
// get instructions:
List<String> instructionList = getInstructionsFromRequest(request);

ResourceItemForm itemForm = (ResourceItemForm) form;
ActionErrors errors = validateResourceItem(itemForm);

if (!errors.isEmpty()) {
    this.addErrors(request, errors);
    request.setAttribute(ResourceConstants.ATTR_INSTRUCTION_LIST, instructionList);
    return findForward(itemForm.getItemType(), mapping);
}

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

示例13: isValidSet

import org.apache.struts.action.ActionErrors; //導入方法依賴的package包/類
private final boolean isValidSet(String setName,
                                 String setSpec,
                                 String setDescription,
                                 RepositoryAdminForm raf,
                                 HttpServletRequest req,
                                 boolean checkSetSpec,
                                 RepositoryManager rm) {
	ActionErrors errors = new ActionErrors();

	if (checkSetSpec) {
		if (setSpec.indexOf(' ') >= 0 || setSpec.indexOf(':') >= 0 || setSpec.length() == 0) {
			errors.add("currentSetSpec", new ActionError("errors.setSpecSyntax"));
		}
		else if (rm.isSetConfigured(setSpec)) {
			errors.add("currentSetSpec", new ActionError("errors.setSpecExists"));
		}
	}
	if (setName.length() == 0) {
		errors.add("currentSetName", new ActionError("errors.setName"));
	}

	if (setDescription != null && setDescription.length() > 0) {
		String validationReport = validateXML(setDescription);
		if (validationReport != null) {
			raf.setXmlError(validationReport);
			return false;
		}
	}

	/*
	 *  if (set.getFormat().indexOf(' ') >= 0 || set.getFormat().length() == 0)
	 *  errors.add("currentSetFormat", new ActionError("errors.setFormat"));
	 *  File f = new File(set.getDirectory());
	 *  prtln("directory: " + f.getAbsolutePath());
	 *  if (!f.isDirectory())
	 *  errors.add("currentSetDirectory", new ActionError("errors.setDirectory"));
	 */
	if (errors.isEmpty()) {
		prtln("\n\n\nsetIsValid() returning no errors...\n\n\n");
		return true;
	}
	else {
		prtln("\n\n\nsetIsValid() had errors...\n\n\n");
		saveErrors(req, errors);
		return false;
	}
}
 
開發者ID:NCAR,項目名稱:joai-project,代碼行數:48,代碼來源:RepositoryAdminAction.java

示例14: updateContent

import org.apache.struts.action.ActionErrors; //導入方法依賴的package包/類
public ActionForward updateContent(ActionMapping mapping, ActionForm form, HttpServletRequest request,
    HttpServletResponse response) throws PixlrException {
// TODO need error checking.

// get authForm and session map.
AuthoringForm authForm = (AuthoringForm) form;
SessionMap<String, Object> map = getSessionMap(request, authForm);
ToolAccessMode mode = (ToolAccessMode) map.get(AuthoringAction.KEY_MODE);

// get pixlr content.
Pixlr pixlr = pixlrService.getPixlrByContentId((Long) map.get(AuthoringAction.KEY_TOOL_CONTENT_ID));
ActionErrors errors = new ActionErrors();

try {
    // TODO: Need to check if this is an edit, if so, delete the old image
    if (authForm.getExistingImageFileName().equals(PixlrConstants.DEFAULT_IMAGE_FILE_NAME)
	    || authForm.getExistingImageFileName().trim().equals("")) {
	errors = validateImageFile(authForm);

	if (!errors.isEmpty()) {
	    this.addErrors(request, errors);
	    updateAuthForm(authForm, pixlr);
	    if (mode != null) {
		authForm.setMode(mode.toString());
	    } else {
		authForm.setMode("");
	    }
	    return mapping.findForward("success");
	}
	uploadFormImage(authForm, pixlr);
    }
} catch (Exception e) {
    logger.error("Problem uploading image", e);
    errors.add(ActionMessages.GLOBAL_MESSAGE, new ActionMessage(PixlrConstants.ERROR_MSG_FILE_UPLOAD));
    //throw new PixlrException("Problem uploading image", e);
}

// update pixlr content using form inputs.
updatePixlr(pixlr, authForm);

// set the update date
pixlr.setUpdateDate(new Date());

// releasing defineLater flag so that learner can start using the tool.
pixlr.setDefineLater(false);

pixlrService.saveOrUpdatePixlr(pixlr);

request.setAttribute(AuthoringConstants.LAMS_AUTHORING_SUCCESS_FLAG, Boolean.TRUE);

// add the sessionMapID to form
authForm.setSessionMapID(map.getSessionID());

request.setAttribute(PixlrConstants.ATTR_SESSION_MAP, map);

updateAuthForm(authForm, pixlr);
if (mode != null) {
    authForm.setMode(mode.toString());
} else {
    authForm.setMode("");
}

return mapping.findForward("success");
   }
 
開發者ID:lamsfoundation,項目名稱:lams,代碼行數:65,代碼來源:AuthoringAction.java

示例15: saveMark

import org.apache.struts.action.ActionErrors; //導入方法依賴的package包/類
public ActionForward saveMark(ActionMapping mapping, ActionForm form, HttpServletRequest request,
    HttpServletResponse response) {
MarkForm markForm = (MarkForm) form;

Float markFloat = null;
String markComment = null;

// get the mark details, validating as we go.
ActionErrors errors = new ActionErrors();
String markStr = markForm.getMarks();
if (StringUtils.isBlank(markStr)) {
    errors.add(ActionMessages.GLOBAL_MESSAGE, new ActionMessage(SpreadsheetConstants.ERROR_MSG_MARKS_BLANK));
} else {
    try {
	markFloat = NumberUtil.getLocalisedFloat(markStr, request.getLocale());
    } catch (Exception e) {
	errors.add(ActionMessages.GLOBAL_MESSAGE,
		new ActionMessage(SpreadsheetConstants.ERROR_MSG_MARKS_INVALID_NUMBER));
    }
}

markComment = markForm.getComments();
if (StringUtils.isBlank(markComment)) {
    errors.add(ActionMessages.GLOBAL_MESSAGE, new ActionMessage(SpreadsheetConstants.ERROR_MSG_COMMENTS_BLANK));
}

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

// passed validation so proceed to save
Long userUid = markForm.getUserUid();
SpreadsheetUser user = getSpreadsheetService().getUser(userUid);
if (user != null && user.getUserModifiedSpreadsheet() != null) {
    //check whether it is "edit(old item)" or "add(new item)"			
    SpreadsheetMark mark;
    if (user.getUserModifiedSpreadsheet().getMark() == null) { //new mark
	mark = new SpreadsheetMark();
	user.getUserModifiedSpreadsheet().setMark(mark);
    } else { //edit
	mark = user.getUserModifiedSpreadsheet().getMark();
    }

    mark.setMarks(markFloat);
    mark.setComments(markComment);

    getSpreadsheetService().saveOrUpdateUserModifiedSpreadsheet(user.getUserModifiedSpreadsheet());
}

request.setAttribute("mark", NumberUtil.formatLocalisedNumber(markFloat, request.getLocale(),
	SpreadsheetConstants.MARK_NUM_DEC_PLACES)); // reduce it to the standard number of decimal places for redisplay
request.setAttribute("userUid", userUid);

//set session map ID so that itemlist.jsp can get sessionMAP
request.setAttribute(SpreadsheetConstants.ATTR_SESSION_MAP_ID, markForm.getSessionMapID());

return mapping.findForward(SpreadsheetConstants.SUCCESS);
   }
 
開發者ID:lamsfoundation,項目名稱:lams,代碼行數:60,代碼來源:MonitoringAction.java


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