コード例 #1
0
 public void onSubmit() {
   Note note = getModelObject();
   if (note == null) {
     BugeaterSession sess = (BugeaterSession) Session.get();
     IUserBean userBean = sess.getUserBean();
     if (newStatus == null) {
       // Create a plain ordinary note
       note =
           new Note()
               .setIssue(EditNotePage.this.getModelObject())
               .setText(textModel.getObject())
               .setUserID(userBean.getId());
     } else {
       // Change status with the given note text
       note =
           issueService
               .changeStatus(
                   EditNotePage.this.getModelObject(),
                   userBean,
                   newStatus,
                   textModel.getObject())
               .getNote();
     }
   } else {
     note.setText(textModel.getObject());
   }
   noteService.save(note);
   PageParameters params = new PageParameters();
   params.add(BugeaterConstants.PARAM_NAME_ISSUE_ID, String.valueOf(note.getIssue().getId()));
   setResponsePage(ViewIssuePage.class, params);
 }
  /**
   * Encode a page target.
   *
   * @param requestCycle the current request cycle
   * @param requestTarget the target to encode
   * @return the encoded url
   */
  protected CharSequence encode(RequestCycle requestCycle, IPageRequestTarget requestTarget) {
    // Get the page we want a url from:
    Page page = requestTarget.getPage();

    // A url to a page is the IRedirectListener interface:
    CharSequence urlRedirect = page.urlFor(IRedirectListener.INTERFACE);

    // Touch the page once because it could be that it did go from stateless
    // to statefull or it was a internally made page where just a url must
    // be made for (frames)
    Session.get().touch(page);
    return urlRedirect;
  }