Package org.apache.struts.action

Examples of org.apache.struts.action.ActionMessage


    // we still okay with this at the moment
    ActionErrors validate = delegator.validate(null, null);

    for (Iterator iterator = validate.get(); iterator.hasNext();)
    {
      ActionMessage message = (ActionMessage) iterator.next();
      System.out.println("Message 1: " + message);
    }
  }
View Full Code Here


  /* ****** helper methods ****** */

  protected String getValidationMessage(ActionErrors errors, String propertyName)
  {
    ActionMessage message = firstError(errors, propertyName);
    assert message != null;

    String outputMessage = resources.getMessage(message.getKey(), message.getValues());
    return outputMessage;
  }
View Full Code Here

  @Override
  public ActionErrors validate(ActionMapping mapping, HttpServletRequest request)
  {
    ActionErrors errors = new ActionErrors();
    errors.add("projectName", new ActionMessage("another.error"));
    return errors;
  }
View Full Code Here

  }

  protected ActionMessage firstError(ActionErrors errors, String propertyName)
  {
    Iterator error = errors.get(propertyName);
    ActionMessage message = (ActionMessage) error.next();
    return message;
  }
View Full Code Here

    NavigableFormRenderBean actionBean = createStrictMock(NavigableFormRenderBean.class);
    ActionMapping mapping = createStrictMock(ActionMapping.class);
    DelegatingForm form = createStrictMock(DelegatingForm.class);

    ActionErrors errors = new ActionErrors();
    errors.add("prop", new ActionMessage("key"));
    expect(request.getAttribute(Globals.ERROR_KEY)).andReturn(errors);
    actionBean.setInputError(true);
    actionBean.execute();
    expect(form.getBindOutwards()).andReturn(false);
    expect(actionBean.getSuccessResult()).andReturn("success");
View Full Code Here

    BasicFormAction actionBean = createStrictMock(BasicFormAction.class);
    ActionMapping mapping = createStrictMock(ActionMapping.class);
    DelegatingForm form = createStrictMock(DelegatingForm.class);

    ActionErrors errors = new ActionErrors();
    errors.add("prop", new ActionMessage("key"));
    expect(request.getAttribute(Globals.ERROR_KEY)).andReturn(errors);
    actionBean.setInputError(true);
    expect(actionBean.execute()).andReturn("success");
    expect(form.getBindOutwards()).andReturn(false);
    expect(mapping.findForward("success")).andReturn(actionForward);
View Full Code Here

    boolean hasError = false;

    if (title == null)
    {
      ActionMessage error = new ActionMessage("Title cannot be null", false);
      errors.add("title", error);
      hasError = true;
    }

    if (days == null)
    {
      ActionMessage error = new ActionMessage("Days cannot be null", false);
      errors.add("days", error);
      hasError = true;
    }
    else
    {
      if (!GenericValidator.isInt(days))
      {
        ActionMessage error = new ActionMessage("Days must be number", false);
        errors.add("days", error);
        hasError = true;
      }
    }

    if (startDate == null)
    {
      ActionMessage error = new ActionMessage("Start date cannot be null", false);
      errors.add("startDate", error);
      hasError = true;
    }
    else
    {

      if (!GenericValidator.isDate(startDate, "yyyy-MM-dd", false))
      {
        ActionMessage error = new ActionMessage("Start date must be a date in yyyy-MM-dd", false);
        errors.add("startDate", error);
        hasError = true;
      }
    }
View Full Code Here

  @Test
  public void testNullIntegerValidation()
  {
    ActionErrors errors = delegator.validate(null, null);
    ActionMessage element = (ActionMessage) errors.get("requiredInteger").next();
    assert element != null;
  }
View Full Code Here

   
    ActionMessages msgs = new ActionMessages();
    do{
      SessionUserObject loginUser = super.getLoginUser(request,response,false);
      if(loginUser==null){
        msgs.add("photo", new ActionMessage("error.user_not_login"));
        break;
      }
      PhotoOutlineBean pbean = PhotoDAO.getPhotoOutlineByID(pform.getId());
      if(pbean==null||pbean.getStatus()!=PhotoBean.STATUS_NORMAL){
        msgs.add("photo", new ActionMessage("error.invalid_photo", new Integer(pform.getId())));
        break;
      }
      //�����ʼ�
      String s_mails = request.getParameter("mails");     
      String[] emails = StringUtils.split(s_mails, ";",MAX_MAIL_COUNT);
      if(emails==null || emails.length==0){
        msgs.add("photo", new ActionMessage("error.no_share_mails"));
        break;
      }
      List vtMails = new ArrayList();
      for(int i=0;i<emails.length;i++){
        String sm = emails[i].trim();
        if(StringUtils.isEmail(sm) && !vtMails.contains(sm))
          vtMails.add(sm);
      }
      if(vtMails.size()==0){
        msgs.add("photo", new ActionMessage("error.no_valid_mail"));
        break;
      }
      sendMails(request, loginUser, pbean, vtMails);
      msgs.add("share", new ActionMessage("mail.sent"));
      break;
    }while(true);
   
    if(!msgs.isEmpty())
      saveMessages(request, msgs);
View Full Code Here

      files[4] = photo1.getImage5();
     
      //����ಾ�Ƿ���Ч
      AlbumBean album = AlbumDAO.getAlbumByID(photo1.getAlbum());
      if (album == null) {
        msgs.add(ERROR_KEY, new ActionMessage(
            "error.object_not_found", String.valueOf(photo1
                .getAlbum())));
        break;
      }

      SiteBean site = super.getSiteBean(request);
      UserBean loginUser = super.getLoginUserAfterValidateSiteOwner(request);

      String photo_desc;
      if(StringUtils.isNotEmpty(photo1.getDesc())){
        photo_desc = StringUtils.abbreviate(super.autoFiltrate(
            site, photo1.getDesc()), MAX_PHOTO_DESC_LENGTH);
        photo_desc = super.filterScriptAndStyle(photo_desc);
      }
      else
        photo_desc = " ";
     
      for(int i=0;i<files.length;i++){
        if(files[i]==null || files[i].getFileSize()<=0 || StringUtils.isEmpty(files[i].getFileName()))
          continue;
        //�жϵ���ͼƬ�Ĵ�С
        /*
        if(files[i].getFileSize()>4194304){//4*1024*1024
          msgs.add(ERROR_KEY, new ActionMessage("error.file_too_large"));
          break;
        }*/
        if(!accept(files[i])){
          msgs.add(ERROR_KEY, new ActionMessage("error.upload_file_not_supported"));
          break;
        }
        //����ϴ��ռ�����
        int photo_size = DLOG4JUtils.sizeInKbytes(files[i].getFileSize());
        int max_photo_size = site.getCapacity().getPhotoTotal();
        if(max_photo_size >= 0){       
          int current_size = site.getCapacity().getPhotoUsed();
          if((current_size + photo_size) > max_photo_size){
            msgs.add(ERROR_KEY, new ActionMessage("error.photo_space_full"));
            break;
          }
        }
        //������Ƭ����������ͼ
        Photo img = null;
        try{
          img = getPhotoSaver().save(
              getHttpContext(mapping, form, request, response),
              files[i], photo1.getAutoRotate() == 1);
          if(img == null){
            msgs.add(ERROR_KEY, new ActionMessage("error.upload_failed"));
            break;       
          }
          //д�뵽���ݿ�
          PhotoBean pbean = new PhotoBean();
          pbean.setSite(site);
          pbean.setUser(loginUser);
          if(StringUtils.isNotEmpty(photo1.getName())){
            pbean.setName(super.autoFiltrate(site, photo1.getName()));
          }
          else
            pbean.setName(img.getName());
          pbean.setDesc(photo_desc);
          if(StringUtils.isNotEmpty(photo1.getKeyword())){
            if(site.isFlagSet(SiteBean.Flag.ILLEGAL_GLOSSARY_IGNORE))
              pbean.setKeyword(photo1.getKeyword());
            else
              pbean.setKeyword(DLOGSecurityManager.IllegalGlossary
                  .deleteIllegalWord(photo1.getKeyword()));
          }
          pbean.setPreviewURL(img.getPreviewURL());
          pbean.setImageURL(img.getImageURL());
         
          pbean.setPhotoInfo(img);
          pbean.setFileName(super.autoFiltrate(site,img.getFileName()));
          pbean.setStatus(photo1.getStatus());//������������
          PhotoDAO.create(album, pbean, (photo1.getCover()==1));
        }catch(IllegalAccessException e){
          msgs.add(ERROR_KEY, new ActionMessage("error.access_deny", e.getMessage()));
          break;
        }catch(Exception e){
          log.error("Upload photo file failed.", e);
          msgs.add(ERROR_KEY, new ActionMessage("error.upload_failed", e.getMessage()));
          break;
        }
      }
      break;
    }while(true);
View Full Code Here

TOP

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

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.