Package org.apache.struts.action

Examples of org.apache.struts.action.ActionMessages


   */
  protected ActionForward doCreateForum(ActionMapping mapping, ActionForm form,
      HttpServletRequest request, HttpServletResponse response)
      throws Exception {
    BBSForumForm forum = (BBSForumForm)form;
    ActionMessages msgs = new ActionMessages();
    if(StringUtils.isEmpty(forum.getName())){
      msgs.add("name", new ActionMessage("error.forum_name_empty"));
    }
    else{     
      super.validateClientId(request, forum);
      SiteBean site = super.getSiteBean(request);
      ForumBean fbean = new ForumBean();
      fbean.setName(forum.getName());
      if(!StringUtils.isEmpty(forum.getDesc()))
        fbean.setDesc(forum.getDesc());
      fbean.setCreateTime(new Date());
      fbean.setSite(site);
      int s = forum.getStatus();
      if(s==ForumBean.STATUS_NORMAL||s==ForumBean.STATUS_HIDDEN||s==ForumBean.STATUS_LOCKED)
        fbean.setStatus(forum.getStatus());
      else
        fbean.setStatus(ForumBean.STATUS_NORMAL);
      if(forum.getCatalog()>0){
        fbean.setCatalog(new TypeBean(forum.getCatalog()));
      }
      BBSForumDAO.createForum(fbean, forum.getId(), forum.getDirection()==1);
    }
    if(!msgs.isEmpty()){
      saveMessages(request, msgs);
      return mapping.findForward("forum_add");
    }
    return super.makeForward(mapping.findForward("forums"), forum.getSid());
  }
View Full Code Here


        } catch (Exception e) {
            String stacktraceAsString = VfsUtils.maskSensitiveArguments(CoreUtil.toString(e));
            log.error("Failed to upload:" + stacktraceAsString);
           
            String exceptionMessage = VfsUtils.maskSensitiveArguments(e.getMessage());
            ActionMessages msgs = new ActionMessages();
            msgs.add(Globals.MESSAGE_KEY, new BundleActionMessage("vfs", "upload.info.fileNotUploaded", exceptionMessage));
            saveErrors(request, msgs);
            if (null != upload.getUploadedForward())
                return upload.getUploadedForward();
            else
                throw e;
View Full Code Here

                throw new Exception("No handler for upload type " + upload.getType());
            }
            request.setAttribute(Constants.REQ_ATTR_UPLOAD_DETAILS, new Integer(uploadId));

            ActionForward fwd = handler.performUpload(request, response, upload, uploadForm.getUploadFile());
            ActionMessages msgs = new ActionMessages();
            if(upload.getResourcePath()==null) {
                msgs.add(Globals.MESSAGE_KEY, new BundleActionMessage("vfs", "upload.info.fileUploadedNoPath", uploadForm.getUploadFile()
                        .getFileName()));
            } else {
                msgs.add(Globals.MESSAGE_KEY, new BundleActionMessage("vfs", "upload.info.fileUploaded", uploadForm.getUploadFile()
                            .getFileName(), upload.getResourcePath()));
            }
            saveMessages(request, msgs);
            request.setAttribute(Constants.REQ_ATTR_UPLOAD_DETAILS, uploadId);
            uploadForm.setUploadId(uploadId);
            return fwd;
        }
        catch (CoreException ce) {
            log.error("Failed to upload.", ce);
            ActionMessages errs = getErrors(request);
            errs.add(Globals.ERROR_KEY, ce.getBundleActionMessage());
            saveErrors(request, errs);
            if (null != upload.getUploadedForward())
                return new RedirectWithMessages(upload.getUploadedForward(), request);
            else
                throw ce;
        }       
        catch (Exception e) {
            log.error("Failed to upload.", e);
            ActionMessages msgs = new ActionMessages();
            msgs.add(Globals.MESSAGE_KEY, new BundleActionMessage("vfs", "upload.info.fileNotUploaded", e.getMessage()));
            saveErrors(request, msgs);
            if (null != upload.getUploadedForward())
                return upload.getUploadedForward();
            else
                throw e;
View Full Code Here

  public ActionForward create(ActionMapping mapping,
                              ActionForm form,
                              HttpServletRequest request,
                              HttpServletResponse response) throws
      Exception {
    ActionMessages mesgs = new ActionMessages();   
    mesgs.add(Globals.MESSAGE_KEY, new ActionMessage("createReplacement.message.requiredFieldIndicator"));
    saveMessages(request, mesgs);
    ( (ReplacementForm) form).initialize(new DefaultReplacement("", Replacement.REPLACEMENT_TYPE_RECEIVED_CONTENT, -1, "", "", ""), false);
    ( (ReplacementForm) form).setReferer(CoreUtil.getReferer(request));
    return mapping.findForward("display");
  }
View Full Code Here

                              HttpServletResponse response) throws Exception {
    ReplacementForm rf = (ReplacementForm)form;
    SessionInfo info = this.getSessionInfo(request);
   
    if (null == rf.getReplacement().getMatchPattern() ||"".equals(rf.getReplacement().getMatchPattern())) {
        ActionMessages mesgs = new ActionMessages();   
        mesgs.add(Globals.MESSAGE_KEY, new ActionMessage("createReplacement.error.noMatchPattern"));
        saveErrors(request, mesgs);
        return mapping.findForward("display");
    }
    if(rf.isEditing()) {
      try {
            WebForwardDatabaseFactory.getInstance().updateReplacement(rf.getReplacement());
            CoreServlet.getServlet().fireCoreEvent(new CoreEvent(this, WebForwardEventConstants.UPDATE_REPLACEMENT, null, info, CoreEvent.STATE_SUCCESSFUL)
                .addAttribute(WebForwardEventConstants.EVENT_ATTR_REPLACEMENT_TYPE, rf.getReplaceType())
                .addAttribute(WebForwardEventConstants.EVENT_ATTR_REPLACEMENT_PATTERN, rf.getReplacement().getReplacePattern()));
      } catch (Exception e) {
            CoreServlet.getServlet().fireCoreEvent(new CoreEvent(this, WebForwardEventConstants.UPDATE_REPLACEMENT, null, info, CoreEvent.STATE_UNSUCCESSFUL)
                .addAttribute(WebForwardEventConstants.EVENT_ATTR_REPLACEMENT_TYPE, rf.getReplaceType())
                .addAttribute(WebForwardEventConstants.EVENT_ATTR_REPLACEMENT_PATTERN, rf.getReplacement().getReplacePattern()));
        throw e;
      }
    }
    else {
      try {
            WebForwardDatabaseFactory.getInstance().createReplacement(rf.getReplacement());
            CoreServlet.getServlet().fireCoreEvent(new CoreEvent(this, WebForwardEventConstants.CREATE_REPLACEMENT, null, info, CoreEvent.STATE_SUCCESSFUL)
                .addAttribute(WebForwardEventConstants.EVENT_ATTR_REPLACEMENT_TYPE, rf.getReplaceType())
                .addAttribute(WebForwardEventConstants.EVENT_ATTR_REPLACEMENT_PATTERN, rf.getReplacement().getReplacePattern()));
      } catch (Exception e) {
            CoreServlet.getServlet().fireCoreEvent(new CoreEvent(this, WebForwardEventConstants.CREATE_REPLACEMENT, null, info, CoreEvent.STATE_UNSUCCESSFUL)
                .addAttribute(WebForwardEventConstants.EVENT_ATTR_REPLACEMENT_TYPE, rf.getReplaceType())
                .addAttribute(WebForwardEventConstants.EVENT_ATTR_REPLACEMENT_PATTERN, rf.getReplacement().getReplacePattern()));
        throw e;
      }
    }
    ActionMessages msgs = new ActionMessages();
    msgs.add(Globals.MESSAGE_KEY, new ActionMessage("createReplacement.message.saved"));
    saveMessages(request, msgs);
    return mapping.findForward("success");
  }
View Full Code Here

     *      javax.servlet.http.HttpServletResponse)
     */
    public ActionForward remove(ActionMapping mapping, ActionForm form, HttpServletRequest request, HttpServletResponse response)
                    throws Exception {
        ActionForward fwd = super.remove(mapping, form, request, response);
        ActionMessages msgs = new ActionMessages();
        msgs.add(Globals.MESSAGE_KEY, new ActionMessage("tunnels.message.tunnelsRemoved", "1"));
        saveMessages(request, msgs);
        return fwd;

    }
View Full Code Here

            if (item.getReplacement().getSequence() == selectedSequence) {
                sel.add(item.getReplacement());
            }
        }
        if (sel.size() == 0) {
            ActionMessages errs = new ActionMessages();
            errs.add(Globals.ERROR_KEY, new ActionMessage("replacements.error.noReplacementsSelectedToDelete"));
            saveErrors(request, errs);
        } else {
            SessionInfo info = this.getSessionInfo(request);
            for (Iterator i = sel.iterator(); i.hasNext();) {
                Replacement r = (Replacement) i.next();
                try {
                    WebForwardDatabaseFactory.getInstance().deleteReplacement(r.getSequence());
                    CoreServlet.getServlet().fireCoreEvent(
                        new CoreEvent(this, WebForwardEventConstants.DELETE_REPLACEMENT, null, info, CoreEvent.STATE_SUCCESSFUL)
                                        .addAttribute(WebForwardEventConstants.EVENT_ATTR_REPLACEMENT_SEQUENCE, String.valueOf(r
                                                        .getSequence())));
                    ActionMessages msgs = new ActionMessages();
                    msgs.add(Globals.ERROR_KEY, new ActionMessage("replacements.message.replacementsDeleted", String.valueOf(sel
                                    .size())));
                    saveMessages(request, msgs);
                } catch (Exception e) {
                    CoreServlet.getServlet().fireCoreEvent(
                        new CoreEvent(this, WebForwardEventConstants.DELETE_REPLACEMENT, null, info, CoreEvent.STATE_UNSUCCESSFUL)
View Full Code Here

            if (item.getReplacement().getSequence() == selectedSequence) {
                sel.add(item.getReplacement());
            }
        }
        if (sel.size() != 1) {
            ActionMessages errs = new ActionMessages();
            errs.add(Globals.ERROR_KEY, new ActionMessage("replacements.error.invalidSelectionToEdit"));
            saveErrors(request, errs);
        } else {
            Replacement replacement = (Replacement) sel.get(0);
            request.setAttribute(ATTR_REPLACEMENT, replacement);
            return mapping.findForward("edit");
View Full Code Here

  /* (non-Javadoc)
   * @see de.odysseus.calyxo.base.access.DynamicMapAccessor#get(javax.servlet.http.HttpServletRequest, java.lang.Object)
   */
  protected Object get(HttpServletRequest request, Object key) {
    String attr = key.toString();
    ActionMessages messages = (ActionMessages)request.getAttribute(attr);
    if (messages == null) {
      HttpSession session = request.getSession(false);
      if (session != null) {
        messages = (ActionMessages)session.getAttribute(attr);
      }
      if (messages == null) {
        messages = (ActionMessages)module.getServletContext().getAttribute(attr);
      }
    }
    return messages == null || messages.size() == 0 ? null : messages.get();
  }
View Full Code Here

  /* (non-Javadoc)
     * @see com.adito.wizard.actions.AbstractWizardAction#createWizardSequence(org.apache.struts.action.ActionMapping, org.apache.struts.action.ActionForm, javax.servlet.http.HttpServletRequest, javax.servlet.http.HttpServletResponse)
     */
    protected AbstractWizardSequence createWizardSequence(ActionMapping mapping, ActionForm form, HttpServletRequest request, HttpServletResponse response) throws Exception {
        ActionMessages msgs = new ActionMessages();
        msgs.add(Constants.REQ_ATTR_WARNINGS, new ActionMessage("installation.selectCertificateSource.warning.noWizardSequence"));
        addWarnings(request, msgs);
        throw new RedirectException(mapping.findForward("restartInstallWizard"), "Cannot create sequence on this page.");
    }
View Full Code Here

TOP

Related Classes of org.apache.struts.action.ActionMessages

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.