Example usage for org.apache.wicket RestartResponseAtInterceptPageException RestartResponseAtInterceptPageException

List of usage examples for org.apache.wicket RestartResponseAtInterceptPageException RestartResponseAtInterceptPageException

Introduction

In this page you can find the example usage for org.apache.wicket RestartResponseAtInterceptPageException RestartResponseAtInterceptPageException.

Prototype

public RestartResponseAtInterceptPageException(Class<? extends Page> interceptPageClass) 

Source Link

Document

Redirects to the specified intercept page, this will result in a bookmarkable redirect.

Usage

From source file:cz.zcu.kiv.eegdatabase.wui.ui.experiments.metadata.template.TemplateFormPage.java

License:Apache License

public TemplateFormPage(PageParameters parameters) {

    IModel<String> title = ResourceUtils.getModel("pageTitle.template.edit");
    setPageTitle(title);// w  w w.j a  v a2s.co m
    add(new Label("title", title));
    add(new ButtonPageMenu("leftMenu", ExperimentsPageLeftMenu.values()));

    StringValue value = parameters.get(DEFAULT_PARAM_ID);
    if (value.isEmpty() || value.isNull()) {
        throw new RestartResponseAtInterceptPageException(ListTemplatePage.class);
    }

    int templateId = value.toInt();
    Template template = facade.read(templateId);

    Reader reader = new Reader();
    try {
        Section section = reader
                .load(new ByteInputStream(template.getTemplate(), template.getTemplate().length));
        section.setName(template.getName());
        add(new TemplateForm("template-panel", new Model<Section>(section), templateId));
    } catch (Exception e) {
        log.error(e.getMessage(), e);
        throw new RestartResponseAtInterceptPageException(ListTemplatePage.class);
    }

}

From source file:cz.zcu.kiv.eegdatabase.wui.ui.groups.BuyMembershipPlanGroupPage.java

License:Apache License

public BuyMembershipPlanGroupPage(PageParameters parameters) {
    StringValue value = parseParameters(parameters);
    final int groupId = value.toInt();
    final ResearchGroup group = groupFacade.getResearchGroupById(groupId);

    setPageTitle(ResourceUtils.getModel("pageTitle.buyPlan"));
    add(new ButtonPageMenu("leftMenu", prepareLeftMenu()));

    Person user = EEGDataBaseSession.get().getLoggedUser();

    if (user == null)
        throw new RestartResponseAtInterceptPageException(HomePage.class);

    DefaultDataTable<MembershipPlan, String> personPlans = new DefaultDataTable<MembershipPlan, String>(
            "groupPlans", createMembershipListColumns(groupId),
            new ListMembershipsDataProvider(planFacade, MembershipPlanType.GROUP), ITEMS_PER_PAGE);

    add(personPlans);//from w  ww  .  j  av a 2  s  . c o  m
}

From source file:cz.zcu.kiv.eegdatabase.wui.ui.groups.form.AddMemberToGroupPage.java

License:Apache License

private StringValue parseParameters(PageParameters parameters) {

    StringValue value = parameters.get(BasePage.DEFAULT_PARAM_ID);
    if (value.isNull() || value.isEmpty())
        throw new RestartResponseAtInterceptPageException(ListResearchGroupsPage.class);

    return value;
}

From source file:cz.zcu.kiv.eegdatabase.wui.ui.history.HistoryPage.java

License:Apache License

public HistoryPage(PageParameters parameters) {

    StringValue value = parseParameters(parameters);

    ChoiceHistory choice = ChoiceHistory.DAILY;

    try {//from  w  w w  .  j ava  2s .  c o m
        choice = ChoiceHistory.valueOf(ChoiceHistory.class, value.toString());
    } catch (IllegalArgumentException e) {
        throw new RestartResponseAtInterceptPageException(HistoryPage.class);
    }

    addComponents(choice);
}

From source file:cz.zcu.kiv.eegdatabase.wui.ui.history.HistoryPage.java

License:Apache License

public void addComponents(final ChoiceHistory choice) {

    this.choice = choice;

    isGroupAdmin = securityFacade.userIsGroupAdmin();
    Person loggedUser = EEGDataBaseSession.get().getLoggedUser();
    ResearchGroup defaultGroup = loggedUser.getDefaultGroup();
    groupId = defaultGroup == null ? 0 : loggedUser.getDefaultGroup().getResearchGroupId();

    final boolean admin = securityFacade.isAdmin();
    if (!admin && !isGroupAdmin) {
        throw new RestartResponseAtInterceptPageException(HomePage.class);
    }//from  w w  w. java2  s.co m

    if (admin) {
        groupId = 0;
        isGroupAdmin = false;
    }

    setPageTitle(ResourceUtils.getModel("title.page.history"));
    add(new ButtonPageMenu("leftMenu", HistoryLeftPageMenu.values()));

    final WebMarkupContainer container = new WebMarkupContainer("container");
    container.setOutputMarkupId(true);

    final HistoryTopDownloadsDataProvider topDownloadsDataProvider = new HistoryTopDownloadsDataProvider(
            historyFacade);
    topDownloadsDataProvider.setData(choice, isGroupAdmin, groupId);
    topDownloadsDataProvider.setSort("count", SortOrder.DESCENDING);

    final HistoryLastDownloadedDataProvider lastDownloadedDataProvider = new HistoryLastDownloadedDataProvider(
            historyFacade);
    lastDownloadedDataProvider.setData(choice, isGroupAdmin, groupId);
    lastDownloadedDataProvider.setSort("dateOfDownload", SortOrder.DESCENDING);

    final HistoryAllTimeRangeRecordsDataProvider allTimeRangeDataProvider = new HistoryAllTimeRangeRecordsDataProvider(
            historyFacade);
    allTimeRangeDataProvider.setData(choice, isGroupAdmin, groupId);
    allTimeRangeDataProvider.setSort("dateOfDownload", SortOrder.DESCENDING);

    if (choice == ChoiceHistory.DAILY) {
        container.add(new Label("title", ResourceUtils.getModel("pageTitle.dailyDownloadHistory")));
        container.add(new Label("timePeriodStatistic", ResourceUtils.getModel("title.dailyStatistic")));
        container.add(new Label("allTimePeriodRecords", ResourceUtils.getModel("title.allDailyRecords")));

    } else if (choice == ChoiceHistory.WEEKLY) {
        container.add(new Label("title", ResourceUtils.getModel("pageTitle.weeklyDownloadHistory")));
        container.add(new Label("timePeriodStatistic", ResourceUtils.getModel("title.weeklyStatistic")));
        container.add(new Label("allTimePeriodRecords", ResourceUtils.getModel("title.allWeeklyRecords")));

    } else if (choice == ChoiceHistory.MONTHLY) {
        container.add(new Label("title", ResourceUtils.getModel("pageTitle.monthlyDownloadHistory")));
        container.add(new Label("timePeriodStatistic", ResourceUtils.getModel("title.monthlyStatistic")));
        container.add(new Label("allTimePeriodRecords", ResourceUtils.getModel("title.allMonthlyRecords")));

    } else {
        throw new RestartResponseAtInterceptPageException(HistoryPage.class);
    }

    container.add(
            new Label("downloadFiles", ResourceUtils.getModel("text.downloadFiles")).setRenderBodyOnly(true));

    final Model<String> countModel = new Model<String>("" + allTimeRangeDataProvider.getCountOfHistory());
    container.add(new Label("count", countModel).setRenderBodyOnly(true));

    container.add(new Label("topDownloads", ResourceUtils.getModel("title.topDownloads")));

    DefaultDataTable<DownloadStatistic, String> topDownloadedFilelist = new DefaultDataTable<DownloadStatistic, String>(
            "topDownloadedFilelist", createListColumnsTopDownloads(), topDownloadsDataProvider, ITEMS_PER_PAGE);
    container.add(topDownloadedFilelist);

    getChartImage();
    container.add(chartImage);

    container.add(new Label("lastDownloaded", ResourceUtils.getModel("title.lastDownloaded")));

    DefaultDataTable<History, String> lastDownloadedFilesHistoryList = new DefaultDataTable<History, String>(
            "lastDownloadedFilesHistoryList", createListColumnsLastDownloaded(), lastDownloadedDataProvider,
            ITEMS_PER_PAGE);
    container.add(lastDownloadedFilesHistoryList);

    DefaultDataTable<History, String> historyList = new DefaultDataTable<History, String>("historyList",
            createListColumnsAllTimeRangeRecords(), allTimeRangeDataProvider, ITEMS_PER_PAGE);
    container.add(historyList);

    Form<Void> groupForm = new Form<Void>("form");
    ChoiceRenderer<ResearchGroup> renderer = new ChoiceRenderer<ResearchGroup>("title", "researchGroupId");
    List<ResearchGroup> choices = researchGroupFacade.getResearchGroupsWhereUserIsGroupAdmin(loggedUser);
    final DropDownChoice<ResearchGroup> researchGroupChoice = new DropDownChoice<ResearchGroup>("researchGroup",
            new Model<ResearchGroup>(), choices, renderer);

    if (defaultGroup != null)
        researchGroupChoice.setModelObject(defaultGroup);

    if (admin) {
        ResearchGroup showAll = new ResearchGroup();
        showAll.setResearchGroupId(0);
        showAll.setTitle(ResourceUtils.getString("select.option.allGroups"));
        choices.add(0, showAll);
        researchGroupChoice.setModelObject(showAll);
    }

    researchGroupChoice.setRequired(true);
    researchGroupChoice.setLabel(ResourceUtils.getModel("label.group"));
    researchGroupChoice.add(new AjaxFormComponentUpdatingBehavior("onChange") {

        private static final long serialVersionUID = 1L;

        @Override
        protected void onUpdate(AjaxRequestTarget target) {
            isGroupAdmin = securityFacade.userIsGroupAdmin();
            ResearchGroup group = researchGroupChoice.getModelObject();
            groupId = group == null ? -1 : group.getResearchGroupId();

            if (groupId == 0 && admin) {
                isGroupAdmin = false;
            }

            topDownloadsDataProvider.setData(choice, isGroupAdmin, groupId);
            lastDownloadedDataProvider.setData(choice, isGroupAdmin, groupId);
            allTimeRangeDataProvider.setData(choice, isGroupAdmin, groupId);

            countModel.setObject("" + allTimeRangeDataProvider.getCountOfHistory());

            getChartImage();

            target.add(container);
        }
    });

    groupForm.add(researchGroupChoice);
    container.add(groupForm);

    add(container);

}

From source file:cz.zcu.kiv.eegdatabase.wui.ui.history.HistoryPage.java

License:Apache License

private StringValue parseParameters(PageParameters parameters) {

    StringValue value = parameters.get(BasePage.DEFAULT_PARAM_ID);
    if (value.isNull() || value.isEmpty())
        throw new RestartResponseAtInterceptPageException(HistoryPage.class);

    return value;
}

From source file:cz.zcu.kiv.eegdatabase.wui.ui.home.HomePage.java

License:Apache License

public HomePage() {

    // if is user logged in redirect on welcome page.
    if (EEGDataBaseSession.get().isSignedIn())
        throw new RestartResponseAtInterceptPageException(WelcomePage.class);

    /*//w ww.  jav  a2  s .  co  m
     *  if is user not logged in but spring session is authenticated - its used social network 
     *  for login and authorize user in wicket. Redirect on welcome page.
     */
    if (EEGDataBaseSession.get().authenticatedSocial()) {
        throw new RestartResponseAtInterceptPageException(WelcomePage.class);
    }

    // or show home page with login form.
    setPageTitle(ResourceUtils.getModel("title.page.home"));
    add(new HomeLoginForm("login"));

    add(new BookmarkablePageLink<Void>("forgottenPass", ForgottenPasswordPage.class));
    add(new BookmarkablePageLink<Void>("registerLink", RegistrationPage.class));
    add(new ExternalLink("licenseLink1", ResourceUtils.getString("homePage.license.link1")));
    add(new ExternalLink("EEGBaseLink", ResourceUtils.getString("homePage.license.EEGBaseLink"),
            ResourceUtils.getString("homePage.license.EEGBaseLink")));
    add(new ExternalLink("licenseLink2", ResourceUtils.getString("homePage.license.link1"),
            ResourceUtils.getString("homePage.license.linkText2") + "."));
    add(new ExternalLink("githubLink", ResourceUtils.getString("homePage.license.githubLink"),
            ResourceUtils.getString("homePage.license.githubLink") + "."));
}

From source file:cz.zcu.kiv.eegdatabase.wui.ui.licenses.LicenseDetailPage.java

License:Open Source License

public LicenseDetailPage(PageParameters parameters) {

    StringValue licenseId = parameters.get(DEFAULT_PARAM_ID);
    if (licenseId.isNull() || licenseId.isEmpty())
        throw new RestartResponseAtInterceptPageException(AdminManageLicensesPage.class);

    setupPageComponents(licenseId.toInteger());
}

From source file:cz.zcu.kiv.eegdatabase.wui.ui.lists.form.ArtifactFormPage.java

License:Apache License

public ArtifactFormPage(PageParameters parameters) {

    StringValue groupParam = parameters.get(PageParametersUtils.GROUP_PARAM);
    StringValue artifactParam = parameters.get(DEFAULT_PARAM_ID);

    if (groupParam.isNull() || groupParam.isEmpty())
        throw new RestartResponseAtInterceptPageException(ListArtifactDefinitionsPage.class);

    add(new ButtonPageMenu("leftMenu", ListsLeftPageMenu.values()));

    if (artifactParam.isNull() || artifactParam.isEmpty())
        setupAddComponents(groupParam.toInt());
    else//from   ww w.  ja v  a 2 s  .c  om
        setupEditComponents(groupParam.toInt(), artifactParam.toInt());
}

From source file:cz.zcu.kiv.eegdatabase.wui.ui.lists.form.ExperimentOptParamFormPage.java

License:Apache License

public ExperimentOptParamFormPage(PageParameters parameters) {

    StringValue groupParam = parameters.get(PageParametersUtils.GROUP_PARAM);
    StringValue experimentParam = parameters.get(DEFAULT_PARAM_ID);

    if (groupParam.isNull() || groupParam.isEmpty())
        throw new RestartResponseAtInterceptPageException(ListExperimentOptParamPage.class);

    add(new ButtonPageMenu("leftMenu", ListsLeftPageMenu.values()));

    if (experimentParam.isNull() || experimentParam.isEmpty())
        setupAddComponents(groupParam.toInt());
    else/*from w ww . j  a va2  s. c  o m*/
        setupEditComponents(groupParam.toInt(), experimentParam.toInt());
}