private void save (SubmitButton source) { if (isValid()) { saveAndShow = (source == btnSaveAndShow); if (changes > 0) { changesAtSave = changes; if (post == null) { PostController.get().createPost(txtTitle.getValue(), cbxDirectOnly.getValue().booleanValue() ? Boolean.FALSE : Boolean.TRUE, cbxComments.getValue(), txtSummary.getValue(), txtContent.getValue(), cbxPublish.getValue(), txtTags.getValue()); } else { PostController.get().updatePost(post, txtTitle.getValue(), cbxDirectOnly.getValue().booleanValue() ? Boolean.FALSE : Boolean.TRUE, cbxComments.getValue(), txtSummary.getValue(), txtContent.getValue(), cbxPublish.getValue(), txtTags.getValue()); } submitting(); } else { restoreFocus(); if (saveAndShow) { PageTypeHelper.show(PageType.PostDetailPageType, PostHelper.slugify(txtTitle.getValue())); } } } else { showErrors(); } }
@UiHandler({ "btnSaveAndShow", "btnSave" }) void onBtnSubmitClicked (ClickEvent e) { save((SubmitButton) e.getSource()); }