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); }
@SuppressWarnings("unchecked") public EditNotePage(PageParameters params) { super(params); if (params.containsKey(BugeaterConstants.PARAM_NAME_NOTE_ID)) { try { Note note = noteService.load(params.getLong(BugeaterConstants.PARAM_NAME_NOTE_ID)); init(new IssueModel(note.getIssue()), new NoteModel(note), null); } catch (StringValueConversionException svce) { throw new IllegalArgumentException(svce); } } else if (params.containsKey(BugeaterConstants.PARAM_NAME_ISSUE_ID)) { try { Long issueid = params.getLong(BugeaterConstants.PARAM_NAME_ISSUE_ID); IssueStatus newStatus = null; if (params.containsKey(BugeaterConstants.PARAM_NAME_ISSUE_STATUS)) { try { newStatus = IssueStatus.fromOrdinal(params.getInt(BugeaterConstants.PARAM_NAME_ISSUE_STATUS)); } catch (StringValueConversionException svce) { throw new IllegalArgumentException(svce); } } init(new IssueModel(issueid), new NoteModel((Long) null), newStatus); } catch (StringValueConversionException svce) { logger.error(svce); } } else { setResponsePage(Home.class); } }
AddNoteForm(MarkupContainer container, String id, IModel<Note> noteModel) { super(container, id, noteModel); new FeedbackPanel(this, "formFeedback"); textModel = new Model<String>(); Note n = noteModel.getObject(); if (n != null) { textModel.setObject(n.getText()); } new TextArea<String>(this, "text", textModel).setRequired(true); }