Package com.apress.prospring.domain

Examples of com.apress.prospring.domain.Entry


     * (non-Javadoc)
     *
     * @see com.apress.prospring.data.EntryDao#getById(int)
     */
    public Entry getById(int entryId) {
        Entry e = (Entry) selectById.findObject(entryId);
        e.setComments(new HashSet<Comment>());
        e.setAttachments(new HashSet<Attachment>());
        e.getComments().addAll(commentDao.getByEntry(e.getEntryId()));
        e.getAttachments().addAll(attachmentDao.getByEntry(e.getEntryId()));
        return e;
    }
View Full Code Here


         *
         * @see org.springframework.jdbc.object.MappingSqlQuery#mapRow(java.sql.ResultSet,
         *      int)
         */
        protected Object mapRow(ResultSet rs, int rowNum) throws SQLException {
            Entry entry = new Entry();

            entry.setBody(rs.getString("Body"));
            entry.setEntryId(rs.getInt("EntryId"));
            entry.setPostDate(rs.getTimestamp("PostDate"));
            entry.setSubject(rs.getString("Subject"));

            return entry;
        }
View Full Code Here

   */
  protected Object formBackingObject(HttpServletRequest request) throws Exception {
    int entryId = RequestUtils.getIntParameter(request, "entryId", 0);
    EntryForm form = new EntryForm();
    if (entryId != 0) {
      Entry entry = getBlogManager().getEntry(entryId);
      form.setBody(entry.getBody());
      form.setEntryId(entry.getEntryId());
      form.setPostDate(entry.getPostDate());
      form.setSubject(entry.getSubject());
    } else {
      form.setPostDate(new Date());
    }
    return form;
  }
View Full Code Here

  /**
   * Handles View
   */
  public ModelAndView handleView(HttpServletRequest request, HttpServletResponse response) throws Exception {
    int entryId = RequestUtils.getRequiredIntParameter(request, "entryId");
    Entry e = getBlogManager().getEntry(entryId);
    Map<String, Object> model = new HashMap<String, Object>();
    model.put("entry", e);
    return new ModelAndView("entry-view", model);
  }
View Full Code Here

  /* (non-Javadoc)
   * @see com.apress.prospring.web.struts.AbstractBlogManagerAction#executeInternal(org.apache.struts.action.ActionMapping, org.apache.struts.action.ActionForm, javax.servlet.http.HttpServletRequest, javax.servlet.http.HttpServletResponse)
   */
  protected ActionForward executeInternal(ActionMapping mapping, ActionForm form, HttpServletRequest request, HttpServletResponse response) throws Exception {
    String forward;
    Entry entry;
    EditEntryForm entryForm = (EditEntryForm)form;
    if (request.getParameter("submit") == null) {
      // we need to load the entry
      int entryId = RequestUtils.getRequiredIntParameter(request, "entryId");
      entry = getBlogManager().getEntry(entryId);
      BeanUtils.copyProperties(entryForm, entry);
      entryForm.setPostDateTime(entry.getPostDate().getTime());
      forward = "edit";
    } else {
      // we are saving the entry
      entry = new Entry();
      BeanUtils.copyProperties(entry, entryForm);
      entry.setPostDate(new Date(entryForm.getPostDateTime()));
      getBlogManager().saveEntry(entry, SessionSecurityManager.getUser(request));

      if (entryForm.getAttachment() != null) {
        Attachment attachment = new Attachment();
        attachment.setContentType("");
        attachment.setFileData(entryForm.getAttachment().getFileData());
        attachment.setFileName("attachment.txt");
        getBlogManager().attachToEntry(attachment, entry.getEntryId());
      }
     
      forward = "posted";
    }
    return mapping.findForward(forward);
View Full Code Here

TOP

Related Classes of com.apress.prospring.domain.Entry

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.