Java tutorial
/******************************************************************************* * Copyright (c) 2011 University of Western Australia. All rights reserved. * * This file is part of The Ark. * * The Ark is free software; you can redistribute it and/or * modify it under the terms of the GNU General Public License * as published by the Free Software Foundation; either version 3 * of the License, or (at your option) any later version. * * The Ark is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License * along with this program. If not, see <http://www.gnu.org/licenses/>. ******************************************************************************/ package au.org.theark.report.web.component.dataextraction; import org.apache.shiro.SecurityUtils; import org.apache.wicket.ajax.markup.html.navigation.paging.AjaxPagingNavigator; import org.apache.wicket.markup.html.WebMarkupContainer; import org.apache.wicket.markup.html.list.PageableListView; import org.apache.wicket.model.CompoundPropertyModel; import org.apache.wicket.model.LoadableDetachableModel; import org.apache.wicket.spring.injection.annot.SpringBean; import au.org.theark.core.model.report.entity.Search; import au.org.theark.core.model.study.entity.Study; import au.org.theark.core.service.IArkCommonService; import au.org.theark.core.vo.SearchVO; import au.org.theark.core.web.component.AbstractContainerPanel; import au.org.theark.report.web.component.dataextraction.form.ContainerForm; public class DataExtractionContainerPanel extends AbstractContainerPanel<SearchVO> { private static final long serialVersionUID = 1L; // Panels private SearchPanel searchComponentPanel; private SearchResultListPanel searchResultPanel; private DetailPanel detailsPanel; private PageableListView<Search> pageableListView; private ContainerForm containerForm; @SpringBean(name = au.org.theark.core.Constants.ARK_COMMON_SERVICE) private IArkCommonService iArkCommonService; public DataExtractionContainerPanel(String id) { super(id); /* Initialise the CPM */ cpModel = new CompoundPropertyModel<SearchVO>(new SearchVO()); /* Bind the CPM to the Form */ containerForm = new ContainerForm("containerForm", cpModel); containerForm.add(initialiseFeedBackPanel()); containerForm.add(initialiseDetailPanel()); containerForm.add(initialiseSearchResults()); containerForm.add(initialiseSearchPanel()); add(containerForm); } protected WebMarkupContainer initialiseSearchResults() { searchResultPanel = new SearchResultListPanel("searchResults", arkCrudContainerVO, containerForm); iModel = new LoadableDetachableModel<Object>() { private static final long serialVersionUID = 1L; @Override protected Object load() { Long studySessionId = (Long) SecurityUtils.getSubject().getSession() .getAttribute(au.org.theark.core.Constants.STUDY_CONTEXT_ID); if (isActionPermitted() && studySessionId != null) { Study studyInContext = iArkCommonService.getStudy(studySessionId); cpModel.getObject().getSearch().setStudy(studyInContext); //containerForm.getModelObject().setListOfSearchesForResultList(iArkCommonService.getSearchesForThisStudy(studyInContext)); containerForm.getModelObject().setListOfSearchesForResultList( iArkCommonService.getSearchesForSearch(cpModel.getObject().getSearch())); } //pageableListView.removeAll(); return containerForm.getModelObject().getListOfSearchesForResultList(); //.getStudyCompList(); } }; pageableListView = searchResultPanel.buildPageableListView(iModel); pageableListView.setReuseItems(true); AjaxPagingNavigator pageNavigator = new AjaxPagingNavigator("navigator", pageableListView); searchResultPanel.add(pageNavigator); searchResultPanel.add(pageableListView); searchResultPanel.setOutputMarkupId(true); arkCrudContainerVO.getSearchResultPanelContainer().add(searchResultPanel); return arkCrudContainerVO.getSearchResultPanelContainer(); } protected WebMarkupContainer initialiseDetailPanel() { detailsPanel = new DetailPanel("detailPanel", feedBackPanel, arkCrudContainerVO, containerForm); detailsPanel.initialisePanel(); arkCrudContainerVO.getDetailPanelContainer().add(detailsPanel); return arkCrudContainerVO.getDetailPanelContainer(); } protected WebMarkupContainer initialiseSearchPanel() { searchComponentPanel = new SearchPanel("searchComponentPanel", arkCrudContainerVO, feedBackPanel, containerForm, pageableListView); searchComponentPanel.initialisePanel(cpModel); arkCrudContainerVO.getSearchPanelContainer().add(searchComponentPanel); return arkCrudContainerVO.getSearchPanelContainer(); } }