/** * @see org.projectforge.web.wicket.AbstractSecuredPage#getDataObjectForInitialParameters() */ @Override protected Object getDataObjectForInitialParameters() { return getData(); }
/** * Overwrite this, if getData().getId() should not be used. */ protected Serializable getHighlightedRowId() { return getData().getId(); }
/** * If user tried to add a new object and an error was occurred the edit page is shown again and the object id is * cleared (set to null). */ @Override public void clearIds() { getData().setId(null); }
/** * Checks weather the id of the data object is given or not. * * @return true if the user wants to create a new data object or false for an already existing object. */ @Override public boolean isNew() { if (form == null) { getLogger() .error("Data of form is null. Maybe you have forgotten to call AbstractEditPage.init() in constructor."); } return (getData() == null || getData().getId() == null); }
protected List<DisplayHistoryEntry> getHistory() { if (historyEntries == null) { historyEntries = getBaseDao().getDisplayHistoryEntries(getData()); } return historyEntries; }
/** * Will be called by clone button. Sets the id of the form data object to null and deleted to false. */ protected void cloneData() { final O data = getData(); getLogger().info("Clone of data chosen: " + data); data.setId(null); data.setDeleted(false); }
/** * Sets the list page (declared as annotation) as response or, if given, the returnToPage. */ @Override public void setResponsePage() { if (this.returnToPage != null) { setResponsePageAndHighlightedRow(this.returnToPage); } else { final EditPage ann = getClass().getAnnotation(EditPage.class); final Class<? extends WebPage> redirectPage; if (ann != null && ann.defaultReturnPage() != null) { redirectPage = getClass().getAnnotation(EditPage.class).defaultReturnPage(); } else { redirectPage = WicketUtils.getDefaultPage(); } final PageParameters params = new PageParameters(); if (getData().getId() != null) { params.add(AbstractListPage.PARAMETER_HIGHLIGHTED_ROW, getData().getId()); } setResponsePage(redirectPage, params); } }
@Override public void setResponsePageAndHighlightedRow(final WebPage page) { if (getData().getId() != null) { if (page instanceof AbstractListPage<?, ?, ?>) { // Force reload/refresh of calling AbstractListPage, otherwise the data object will not be updated. ((AbstractListPage<?, ?, ?>) page).setHighlightedRowId(getHighlightedRowId()); ((AbstractListPage<?, ?, ?>) page).refresh(); } else if (returnToPage instanceof TaskTreePage) { // Force reload/refresh of calling AbstractListPage, otherwise the data object will not be updated. ((TaskTreePage) page).setHighlightedRowId((Integer) getHighlightedRowId()); ((TaskTreePage) page).refresh(); } else if (returnToPage instanceof WizardPage) { ((WizardPage) returnToPage).setCreatedObject(getData()); } } setResponsePage(page); }