コード例 #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
  public ActionForward listArticle(
      FormBean form, HttpServletRequest request, HttpServletResponse response)
      throws ServletException, IOException, KTMException {

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

    listData(request.getSession(), form);

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

    return ActionForward.getUri(this, request, "ListArticles.jsp");
  }
コード例 #4
0
  public ActionForward delArticle(
      FormBean form, HttpServletRequest request, HttpServletResponse response)
      throws ServletException, IOException {
    logger.debug(">>> delArticle: begin");

    delImageUpload((UploadImageBean) form, request.getSession());

    logger.debug(">>> delArticle: eng");

    return ActionForward.getAction(
        this,
        request,
        "index?page=CRUDArticle&t=t&param="
            + KTMCrypt.encrypt("method=list&module=article&pageNumber=" + form.getPageNumber()),
        true);
  }
コード例 #5
0
ファイル: Main.java プロジェクト: ammarblue/ktm-store
  @Override
  protected ActionForward processRequest(
      FormBean form, HttpServletRequest request, HttpServletResponse response)
      throws ServletException, IOException {
    String forwordUri = request.getServletContext().getInitParameter("jspMainPage");
    ActionForward action = null;
    MainBean bean = (MainBean) form;

    if (bean.getPage() != null) {
      ServletContext context = request.getServletContext();
      String basePath = context.getInitParameter(Globals.BASE_PATH);
      bean.setPageContent(basePath + bean.getPage() + "_content.jsp");
      request.getSession().setAttribute("page", bean.getPage());
      action = ActionForward.getUri(this, request, forwordUri);
    } else {
      throw new ServletException("Page not found !!");
    }
    return action;
  }
コード例 #6
0
  public ActionForward saveArticle(
      FormBean form, HttpServletRequest request, HttpServletResponse response)
      throws ServletException, IOException {
    ArticleBean bean = (ArticleBean) form;

    try {
      doSaveImageUpload(bean, request);
    } catch (CreateException e) {
      e.printStackTrace();
    } catch (DeleteException e) {
      e.printStackTrace();
    }

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

    return ActionForward.getAction(
        this,
        request,
        "index?page=CRUDArticle&t=t&param="
            + KTMCrypt.encrypt("method=list&module=article&pageNumber=" + bean.getPageNumber()),
        true);
  }