コード例 #1
0
  public ActionForward newArticle(
      FormBean form, HttpServletRequest request, HttpServletResponse response)
      throws ServletException, IOException {
    HttpSession session = request.getSession();
    ArticleBean bean = (ArticleBean) form;

    logger.debug(">>> newArticle: begin");

    // ArticleType list
    ArticleTypeDao articleTypeDao = KTMEMDaoFactory.getInstance().getArticleTypeDao();
    bean.getArticleTypeCollection().clear();
    Collection<KTMEntity> articleTypes = articleTypeDao.findAll();
    for (KTMEntity entity : articleTypes) {
      if (entity instanceof ArticleType) {
        ArticleType type = (ArticleType) entity;
        ArticleTypeBean typeBean = new ArticleTypeBean();
        typeBean.loadToForm(type);
        bean.getArticleTypeCollection().add(typeBean);
      }
    }

    newImageUpload(bean, session);

    logger.debug(">>> newArticle: end");

    return ActionForward.getUri(this, request, "EditArticles.jsp");
  }
コード例 #2
0
  public ActionForward editArticle(
      FormBean form, HttpServletRequest request, HttpServletResponse response)
      throws ServletException, IOException {
    HttpSession session = request.getSession();
    ArticleBean bean = (ArticleBean) form;
    ArticleTypeDao articleTypeDao = KTMEMDaoFactory.getInstance().getArticleTypeDao();

    Collection<KTMEntity> articleTypes = articleTypeDao.findAll();
    bean.getArticleTypeCollection().clear();
    for (KTMEntity entity : articleTypes) {
      if (entity instanceof ArticleType) {
        ArticleType type = (ArticleType) entity;
        ArticleTypeBean typeBean = new ArticleTypeBean();
        typeBean.loadToForm(type);
        bean.getArticleTypeCollection().add(typeBean);
      }
    }

    ArticleDao articleDao = KTMEMDaoFactory.getInstance().getArticleDao();
    Article article = (Article) articleDao.get(Integer.parseInt(bean.getUniqueId()));
    if (article != null) {
      bean.loadToForm(article);

      session.setAttribute(ArticleBean.UNIQUD_ID, bean.getIdentifier());
      session.setAttribute(bean.getIdentifier(), bean);
      try {
        bean.setDateModified(DateUtils.formatDate(new Date()));
      } catch (ParseException e) {
        e.printStackTrace();
      }

      return ActionForward.getUri(this, request, "EditArticles.jsp");
    }

    if (bean.getServlet() != null && bean.getServlet() instanceof CRUDArticleServlet) {
      ((CRUDArticleServlet) bean.getServlet()).resetAllCRUDCollection(session);
    }

    return ActionForward.getAction(
        this,
        request,
        "index?page=CRUDArticle&t=t&param="
            + KTMCrypt.encrypt("method=list&module=article&pageNumber=" + bean.getPageNumber()),
        true);
  }
コード例 #3
0
 @Override
 protected Dao getDao() {
   return KTMEMDaoFactory.getInstance().getArticleDao();
 }