本文整理匯總了Java中org.apache.struts.action.ActionMessages.isEmpty方法的典型用法代碼示例。如果您正苦於以下問題:Java ActionMessages.isEmpty方法的具體用法?Java ActionMessages.isEmpty怎麽用?Java ActionMessages.isEmpty使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類org.apache.struts.action.ActionMessages
的用法示例。
在下文中一共展示了ActionMessages.isEmpty方法的15個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。
示例1: saveOrUpdatePedagogicalPlannerForm
import org.apache.struts.action.ActionMessages; //導入方法依賴的package包/類
public ActionForward saveOrUpdatePedagogicalPlannerForm(ActionMapping mapping, ActionForm form,
HttpServletRequest request, HttpServletResponse response) throws IOException {
MindmapPedagogicalPlannerForm plannerForm = (MindmapPedagogicalPlannerForm) form;
ActionMessages errors = plannerForm.validate();
if (errors.isEmpty()) {
String instructions = plannerForm.getInstructions();
Long toolContentID = plannerForm.getToolContentID();
Mindmap mindmap = getMindmapService().getMindmapByContentId(toolContentID);
mindmap.setInstructions(instructions);
getMindmapService().saveOrUpdateMindmap(mindmap);
} else {
saveErrors(request, errors);
}
return mapping.findForward(MindmapConstants.SUCCESS);
}
示例2: saveOrUpdatePedagogicalPlannerForm
import org.apache.struts.action.ActionMessages; //導入方法依賴的package包/類
public ActionForward saveOrUpdatePedagogicalPlannerForm(ActionMapping mapping, ActionForm form,
HttpServletRequest request, HttpServletResponse response) throws IOException {
KalturaPedagogicalPlannerForm plannerForm = (KalturaPedagogicalPlannerForm) form;
ActionMessages errors = plannerForm.validate();
if (errors.isEmpty()) {
String instructions = plannerForm.getInstructions();
Long toolContentID = plannerForm.getToolContentID();
Kaltura kaltura = getKalturaService().getKalturaByContentId(toolContentID);
kaltura.setInstructions(instructions);
getKalturaService().saveOrUpdateKaltura(kaltura);
} else {
saveErrors(request, errors);
}
return mapping.findForward(KalturaConstants.SUCCESS);
}
示例3: saveOrUpdatePedagogicalPlannerForm
import org.apache.struts.action.ActionMessages; //導入方法依賴的package包/類
public ActionForward saveOrUpdatePedagogicalPlannerForm(ActionMapping mapping, ActionForm form,
HttpServletRequest request, HttpServletResponse response) throws IOException {
ChatPedagogicalPlannerForm plannerForm = (ChatPedagogicalPlannerForm) form;
ActionMessages errors = plannerForm.validate();
if (errors.isEmpty()) {
String instructions = plannerForm.getInstructions();
Long toolContentID = plannerForm.getToolContentID();
Chat chat = getChatService().getChatByContentId(toolContentID);
chat.setInstructions(instructions);
getChatService().saveOrUpdateChat(chat);
} else {
saveErrors(request, errors);
}
return mapping.findForward(ChatConstants.SUCCESS);
}
示例4: saveOrUpdatePedagogicalPlannerForm
import org.apache.struts.action.ActionMessages; //導入方法依賴的package包/類
public ActionForward saveOrUpdatePedagogicalPlannerForm(ActionMapping mapping, ActionForm form,
HttpServletRequest request, HttpServletResponse response) throws IOException {
ScratchiePedagogicalPlannerForm plannerForm = (ScratchiePedagogicalPlannerForm) form;
ActionMessages errors = plannerForm.validate();
if (errors.isEmpty()) {
Scratchie scratchie = getScratchieService().getScratchieByContentId(plannerForm.getToolContentID());
scratchie.setInstructions(plannerForm.getInstructions());
getScratchieService().saveOrUpdateScratchie(scratchie);
} else {
saveErrors(request, errors);
}
return mapping.findForward(ScratchieConstants.SUCCESS);
}
示例5: saveOrUpdatePedagogicalPlannerForm
import org.apache.struts.action.ActionMessages; //導入方法依賴的package包/類
public ActionForward saveOrUpdatePedagogicalPlannerForm(ActionMapping mapping, ActionForm form,
HttpServletRequest request, HttpServletResponse response) throws IOException {
NbPedagogicalPlannerForm plannerForm = (NbPedagogicalPlannerForm) form;
ActionMessages errors = plannerForm.validate();
if (errors.isEmpty()) {
String content = plannerForm.getBasicContent();
Long toolContentID = plannerForm.getToolContentID();
NoticeboardContent noticeboard = getNoticeboardService().retrieveNoticeboard(toolContentID);
noticeboard.setContent(content);
getNoticeboardService().saveNoticeboard(noticeboard);
} else {
saveErrors(request, errors);
}
return mapping.findForward("success");
}
示例6: saveOrUpdatePedagogicalPlannerForm
import org.apache.struts.action.ActionMessages; //導入方法依賴的package包/類
public ActionForward saveOrUpdatePedagogicalPlannerForm(ActionMapping mapping, ActionForm form,
HttpServletRequest request, HttpServletResponse response) throws IOException {
SubmitFilesPedagogicalPlannerForm plannerForm = (SubmitFilesPedagogicalPlannerForm) form;
ActionMessages errors = plannerForm.validate();
if (errors.isEmpty()) {
String content = plannerForm.getInstruction();
Long toolContentID = plannerForm.getToolContentID();
SubmitFilesContent submitFiles = getSubmitFilesService().getSubmitFilesContent(toolContentID);
submitFiles.setInstruction(content);
getSubmitFilesService().saveOrUpdateContent(submitFiles);
} else {
saveErrors(request, errors);
}
return mapping.findForward(SbmtConstants.SUCCESS);
}
示例7: validateUploadForm
import org.apache.struts.action.ActionMessages; //導入方法依賴的package包/類
private boolean validateUploadForm(LearnerForm learnerForm, HttpServletRequest request) {
ActionMessages errors = new ActionMessages();
Locale preferredLocale = (Locale) request.getSession().getAttribute(LocaleFilter.PREFERRED_LOCALE_KEY);
if (learnerForm.getFile() == null || StringUtils.isBlank(learnerForm.getFile().getFileName())) {
errors.add(ActionMessages.GLOBAL_MESSAGE, new ActionMessage("errors.required",
this.getResources(request).getMessage(preferredLocale, "learner.form.filepath.displayname")));
}
if (StringUtils.isBlank(learnerForm.getDescription())) {
errors.add(ActionMessages.GLOBAL_MESSAGE, new ActionMessage("errors.required",
this.getResources(request).getMessage(preferredLocale, "label.learner.fileDescription")));
} else if (learnerForm.getDescription().length() > LearnerForm.DESCRIPTION_LENGTH) {
errors.add(ActionMessages.GLOBAL_MESSAGE,
new ActionMessage("errors.maxdescsize", LearnerForm.DESCRIPTION_LENGTH));
}
FileValidatorUtil.validateFileSize(learnerForm.getFile(), false, errors);
if (learnerForm.getFile() != null) {
LearnerAction.logger.debug("Learner submit file : " + learnerForm.getFile().getFileName());
}
if (learnerForm.getFile() != null && FileUtil.isExecutableFile(learnerForm.getFile().getFileName())) {
LearnerAction.logger.debug("File is executatable : " + learnerForm.getFile().getFileName());
ActionMessage msg = new ActionMessage("error.attachment.executable");
errors.add(ActionMessages.GLOBAL_MESSAGE, msg);
}
if (!errors.isEmpty()) {
this.addErrors(request, errors);
return true;
}
return false;
}
示例8: doStartTag
import org.apache.struts.action.ActionMessages; //導入方法依賴的package包/類
public int doStartTag() throws JspException {
ActionMessages errors = null;
try {
errors = TagUtils.getInstance().getActionMessages(pageContext, Globals.ERROR_KEY);
} catch (JspException e) {
TagUtils.getInstance().saveException(pageContext, e);
throw e;
}
String hint = null;
if (errors != null && !errors.isEmpty()) {
String message = null;
Iterator reports = (getProperty() == null ? errors.get() : errors.get(getProperty()));
while (reports.hasNext()) {
ActionMessage report = (ActionMessage) reports.next();
if (report.isResource()) {
message = TagUtils.getInstance().message(pageContext, null, Globals.LOCALE_KEY, report.getKey(), report.getValues());
} else {
message = report.getKey();
}
if (message != null && !message.isEmpty()) {
hint = (hint == null ? "" : hint + "<br>") + message;
}
}
}
setStyleClass("unitime-DateSelectionBox");
String onchange = getOnchange(); setOnchange(null);
TagUtils.getInstance().write(pageContext, "<span name='UniTimeGWT:Calendar' format=\"" + getFormat() + "\"" +
(hint == null ? "" : " error=\"" + hint + "\"") +
(onchange == null ? "" : " onchange=\"" + onchange + "\"") +
(getOuterStyle() == null ? "" : " style=\"" + getOuterStyle() + "\"" ) +
">");
super.doStartTag();
TagUtils.getInstance().write(pageContext, "</span>");
return EVAL_BODY_BUFFERED;
}
示例9: signIn
import org.apache.struts.action.ActionMessages; //導入方法依賴的package包/類
private ActionForward signIn(ActionMapping mapping, ActionForm form, HttpServletRequest request,
HttpServletResponse response) {
try {
DynaActionForm signupForm = (DynaActionForm) form;
// validation
ActionMessages errors = validateSignin(signupForm);
if (!errors.isEmpty()) {
saveErrors(request, errors);
return mapping.findForward("signup");
} else {
String login = signupForm.getString("usernameTab2");
String password = signupForm.getString("passwordTab2");
String context = signupForm.getString("context");
SignupAction.signupService.signinUser(login, context);
HttpSession hses = request.getSession();
hses.setAttribute("login", login);
hses.setAttribute("password", password);
response.sendRedirect("/lams/login.jsp?redirectURL=/lams");
return null;
}
} catch (Exception e) {
SignupAction.log.error(e.getMessage(), e);
request.setAttribute("error", e.getMessage());
}
return mapping.findForward("index");
}
示例10: validateSignin
import org.apache.struts.action.ActionMessages; //導入方法依賴的package包/類
private ActionMessages validateSignin(DynaActionForm signupForm) {
ActionMessages errors = new ActionMessages();
if (StringUtils.isBlank(signupForm.getString("usernameTab2"))) {
errors.add("usernameTab2", new ActionMessage("error.username.blank"));
}
if (StringUtils.isBlank(signupForm.getString("passwordTab2"))) {
errors.add("passwordTab2", new ActionMessage("error.password.blank"));
}
if (!SignupAction.signupService.courseKeyIsValid(signupForm.getString("context"),
signupForm.getString("courseKeyTab2"))) {
errors.add("courseKeyTab2", new ActionMessage("error.course.key.invalid"));
}
if (errors.isEmpty()) {
String login = signupForm.getString("usernameTab2");
String password = signupForm.getString("passwordTab2");
User user = SignupAction.signupService.getUserByLogin(login);
if (user == null) {
errors.add("usernameTab2", new ActionMessage("error.login.or.password.incorrect",
"<a onclick='selectSignupTab();' id='selectLoginTabA'>", "</a>"));
} else {
String passwordHash = user.getPassword().length() == HashUtil.SHA1_HEX_LENGTH ? HashUtil.sha1(password)
: HashUtil.sha256(password, user.getSalt());
if (!user.getPassword().equals(passwordHash)) {
errors.add("usernameTab2", new ActionMessage("error.login.or.password.incorrect",
"<a onclick='selectSignupTab();' id='selectLoginTabA'>", "</a>"));
}
}
}
return errors;
}
示例11: hasErrors
import org.apache.struts.action.ActionMessages; //導入方法依賴的package包/類
/** Checks if any errors have been generated
* @param request The servlet request we are processing
* @return true if errors exist
*/
public static boolean hasErrors(HttpServletRequest request) {
ActionMessages errors = getErrors(request);
if (errors != null && !errors.isEmpty())
return true;
else
return false;
}
示例12: execute
import org.apache.struts.action.ActionMessages; //導入方法依賴的package包/類
public ActionForward execute(ActionMapping mapping, ActionForm form, HttpServletRequest request, HttpServletResponse response) throws Exception {
ExamPdfReportForm myForm = (ExamPdfReportForm) form;
sessionContext.checkPermission(Right.ExaminationPdfReports);
ExamSolverProxy examSolver = examinationSolverService.getSolver();
if (examSolver!=null) {
if (ApplicationProperty.ExaminationPdfReportsCanUseSolution.isTrue())
request.setAttribute(Constants.REQUEST_WARN, "Examination PDF reports are generated from the current solution (in-memory solution taken from the solver).");
else
request.setAttribute(Constants.REQUEST_WARN, "Examination PDF reports are generated from the saved solution (solver assignments are ignored).");
}
// Read operation to be performed
String op = (myForm.getOp()!=null?myForm.getOp():request.getParameter("op"));
if ("Generate".equals(op)) myForm.save(sessionContext);
myForm.load(sessionContext);
myForm.setSubjectAreas(SubjectArea.getUserSubjectAreas(sessionContext.getUser(), false));
if (myForm.getAddress() == null)
myForm.setAddress(sessionContext.getUser().getEmail());
if ("Generate".equals(op)) {
ActionMessages errors = myForm.validate(mapping, request);
if (!errors.isEmpty()) {
saveErrors(request, errors);
} else {
QueueProcessor.getInstance().add(new PdfExamReportQueueItem(
SessionDAO.getInstance().get(sessionContext.getUser().getCurrentAcademicSessionId()),
sessionContext.getUser(),
(ExamPdfReportForm) myForm.clone(), request, examSolver));
}
}
if (request.getParameter("remove") != null) {
QueueProcessor.getInstance().remove(Long.valueOf(request.getParameter("remove")));
}
WebTable table = getQueueTable(request);
if (table != null) {
request.setAttribute("table", table.printTable(WebTable.getOrder(sessionContext,"examPdfReport.ord")));
}
LookupTables.setupExamTypes(request, sessionContext.getUser(), DepartmentStatusType.Status.ExamView, DepartmentStatusType.Status.ExamTimetable);
return mapping.findForward("show");
}
示例13: updateContent
import org.apache.struts.action.ActionMessages; //導入方法依賴的package包/類
/**
* Update all content for submit tool except online/offline instruction files list.
*
* @param mapping
* @param form
* @param request
* @param response
* @return
* @throws NoSuchMethodException
* @throws InvocationTargetException
* @throws Exception
*/
public ActionForward updateContent(ActionMapping mapping, ActionForm form, HttpServletRequest request,
HttpServletResponse response) throws Exception {
AuthoringForm authForm = (AuthoringForm) form;
SessionMap<String, Object> sessionMap = (SessionMap<String, Object>) request.getSession().getAttribute(authForm.getSessionMapID());
ToolAccessMode mode = (ToolAccessMode) sessionMap.get(AttributeNames.PARAM_MODE);
ActionMessages errors = validate(authForm, mapping, request);
if (!errors.isEmpty()) {
saveErrors(request, errors);
return mapping.getInputForward();
}
SubmitFilesContent content = getContent(form);
submitFilesService = getService();
SubmitFilesContent persistContent = submitFilesService.getSubmitFilesContent(content.getContentID());
if (persistContent == null) {
// new content
persistContent = content;
content.setCreated(new Date());
} else {
Long uid = persistContent.getContentID();
PropertyUtils.copyProperties(persistContent, content);
persistContent.setContentID(uid);
// if it is Teacher (from monitor) - change define later status
if (mode.isTeacher()) {
persistContent.setDefineLater(false);
}
}
// *******************************Handle user*******************
// get session from shared session.
HttpSession ss = SessionManager.getSession();
// get back login user DTO
UserDTO userDto = (UserDTO) ss.getAttribute(AttributeNames.USER);
Long contentId = authForm.getToolContentID();
SubmitUser user = submitFilesService.getContentUser(contentId, userDto.getUserID());
if (user == null) {
user = submitFilesService.createContentUser(userDto, contentId);
}
persistContent.setCreatedBy(user);
submitFilesService.saveOrUpdateContent(persistContent);
// to jump to common success page in lams_central
request.setAttribute(AuthoringConstants.LAMS_AUTHORING_SUCCESS_FLAG, Boolean.TRUE);
return mapping.findForward("success");
}
示例14: add
import org.apache.struts.action.ActionMessages; //導入方法依賴的package包/類
public ActionForward add(ActionMapping mapping, ActionForm form, HttpServletRequest request,
HttpServletResponse response) throws Exception {
DynaActionForm signupForm = (DynaActionForm) form;
// check if form submitted
if (signupForm.get("organisationId") != null && (Integer) signupForm.get("organisationId") > 0) {
ActionMessages errors = new ActionMessages();
// validate
if (!StringUtils.equals(signupForm.getString("courseKey"), signupForm.getString("confirmCourseKey"))) {
errors.add("courseKey", new ActionMessage("error.course.keys.unequal"));
}
if (signupService.contextExists((Integer) signupForm.get("signupOrganisationId"),
signupForm.getString("context"))) {
errors.add("context", new ActionMessage("error.context.exists"));
}
if (!errors.isEmpty()) {
saveErrors(request, errors);
} else {
// proceed
SignupOrganisation signup;
if (signupForm.get("signupOrganisationId") != null
&& (Integer) signupForm.get("signupOrganisationId") > 0) {
// form was editing existing
signup = (SignupOrganisation) userManagementService.findById(SignupOrganisation.class,
(Integer) signupForm.get("signupOrganisationId"));
} else {
signup = new SignupOrganisation();
signup.setCreateDate(new Date());
}
signup.setAddToLessons((Boolean) signupForm.get("addToLessons"));
signup.setAddAsStaff((Boolean) signupForm.get("addAsStaff"));
signup.setAddWithAuthor((Boolean) signupForm.get("addWithAuthor"));
signup.setAddWithMonitor((Boolean) signupForm.get("addWithMonitor"));
signup.setDisabled((Boolean) signupForm.get("disabled"));
signup.setLoginTabActive((Boolean) signupForm.get("loginTabActive"));
signup.setOrganisation((Organisation) userManagementService.findById(Organisation.class,
(Integer) signupForm.get("organisationId")));
signup.setCourseKey(signupForm.getString("courseKey"));
signup.setBlurb(signupForm.getString("blurb"));
signup.setContext(signupForm.getString("context"));
userManagementService.save(signup);
return mapping.findForward("signupPageListMethod");
}
} else {
// form not submitted, default values
signupForm.set("blurb", "Register your LAMS account for this group using the form below.");
}
List organisations = signupService.getOrganisationCandidates();
request.setAttribute("organisations", organisations);
return mapping.findForward("addSignupPage");
}
示例15: saveOrUpdatePedagogicalPlannerForm
import org.apache.struts.action.ActionMessages; //導入方法依賴的package包/類
public ActionForward saveOrUpdatePedagogicalPlannerForm(ActionMapping mapping, ActionForm form,
HttpServletRequest request, HttpServletResponse response) throws IOException {
ScribePedagogicalPlannerForm plannerForm = (ScribePedagogicalPlannerForm) form;
ActionMessages errors = plannerForm.validate();
if (errors.isEmpty()) {
Scribe scribe = getScribeService().getScribeByContentId(plannerForm.getToolContentID());
int headingIndex = 0;
String heading = null;
ScribeHeading scribeHeading = null;
List<ScribeHeading> newHeadings = new LinkedList<ScribeHeading>();
Iterator<ScribeHeading> scribeHeadingIterator = scribe.getScribeHeadings().iterator();
do {
heading = plannerForm.getHeading(headingIndex);
if (StringUtils.isEmpty(heading)) {
plannerForm.removeHeading(headingIndex);
} else {
if (scribeHeadingIterator.hasNext()) {
scribeHeading = scribeHeadingIterator.next();
scribeHeading.setDisplayOrder(headingIndex);
} else {
scribeHeading = new ScribeHeading();
scribeHeading.setHeadingText(heading);
scribeHeading.setDisplayOrder(headingIndex);
newHeadings.add(scribeHeading);
scribeHeading.setScribe(scribe);
}
headingIndex++;
}
} while (heading != null);
while (scribeHeadingIterator.hasNext()) {
scribeHeading = scribeHeadingIterator.next();
scribeHeadingIterator.remove();
getScribeService().deleteHeading(scribeHeading.getUid());
}
scribe.getScribeHeadings().addAll(newHeadings);
getScribeService().saveOrUpdateScribe(scribe);
} else {
saveErrors(request, errors);
}
return mapping.findForward("success");
}