Example usage for org.apache.wicket.request.mapper.parameter PageParameters getNamedKeys

List of usage examples for org.apache.wicket.request.mapper.parameter PageParameters getNamedKeys

Introduction

In this page you can find the example usage for org.apache.wicket.request.mapper.parameter PageParameters getNamedKeys.

Prototype

@Override
    public Set<String> getNamedKeys() 

Source Link

Usage

From source file:com.axway.ats.testexplorer.pages.model.BookmarkableTabbedPanel.java

License:Apache License

/**
* Using this constructor the following defaults take effect:
* <ul>/*from   w  w  w  .j a v a 2 s. c o m*/
* <li>tabParameterName = "tab"</li>
* <li>defaultTabIndex = 0</li>
* </ul>
* @param id component id
* @param tabs list of ITab objects used to represent tabs
* @param pageParameters Container for parameters to a requested page. A
* parameter for the selected tab will be inserted.
*/
public BookmarkableTabbedPanel(String id, List<ITab> tabs, PageParameters pageParameters) {

    super(id, tabs);
    this.pageParameters = pageParameters;

    if (pageParameters.getNamedKeys().contains(tabParameterName)) {

        int tab = pageParameters.get(tabParameterName).toInt();
        setSelectedTab(tab);
    } else {
        setSelectedTab(defaultTabIndex);
    }
}

From source file:com.francetelecom.clara.cloud.presentation.applications.ApplicationInformationPanel.java

License:Apache License

public ApplicationInformationPanel(String id, Application app, PageParameters params,
        SelectedAppPage parentPage) {// www  . jav a  2  s  .  co  m
    super(id);
    this.parentPage = parentPage;
    if (params.getNamedKeys().contains("edit")) {
        this.edit = params.get("edit").toBoolean();
    }

    String applicationLabel = app.getLabel();
    Label appLabel = new Label("applicationLabel", new StringResourceModel(
            "portal.application.information.title", new Model<String[]>(new String[] { applicationLabel })));
    add(appLabel);
    createEditShowInformationComponent(app);

}

From source file:com.francetelecom.clara.cloud.presentation.designer.pages.DesignerHelperPage.java

License:Apache License

/**
 * PageTemplate constructor/*from w  ww .ja  va2  s  . c  o m*/
 *
 * @param params - page parameters map
 */
public DesignerHelperPage(final PageParameters params) {
    super(params);
    try {

        if (params.getNamedKeys().contains("releaseUid")) {
            logicalDeployment = getLogicalDeploymentPersisted(params.get("releaseUid").toString());
        }
    } catch (ObjectNotFoundException e) {
        error(e.getMessage());
    }

    modalServiceView = new CustomModalWindow("modalServiceView");
    modalServiceView.setWindowClosedCallback(new ModalWindow.WindowClosedCallback() {
        private static final long serialVersionUID = 1L;

        public void onClose(AjaxRequestTarget target) {

        }
    });
    add(modalServiceView);
}

From source file:com.francetelecom.clara.cloud.presentation.releases.ReleaseInformationPanel.java

License:Apache License

public ReleaseInformationPanel(String id, IModel<ApplicationRelease> model, PageParameters params,
        ManageApplicationRelease manageApplicationRelease, SelectedReleasePage parentPage) {
    super(id, model);

    this.params = params;
    this.manageApplicationRelease = manageApplicationRelease;
    this.parentPage = parentPage;

    if (params.getNamedKeys().contains("edit")) {
        this.edit = params.get("edit").toBoolean();
    }//from w ww. ja va 2s. c o m

    Label releaseLabel = new Label("releaseLabel",
            new StringResourceModel("portal.release.information.title",
                    new Model(new String[] { model.getObject().getApplication().getLabel() + " - "
                            + model.getObject().getReleaseVersion() })));
    add(releaseLabel);

    createEditShowInformationComponent(model);

}

From source file:com.francetelecom.clara.cloud.presentation.releases.ReleasesPage.java

License:Apache License

private void createBreadCrumbs() {
    List<BreadcrumbsItem> breadcrumbsItems = new ArrayList<BreadcrumbsItem>();
    breadcrumbsItems//ww w. ja  v a  2s  .  c o  m
            .add(new BreadcrumbsItem(HomePage.class, "portal.design.breadcrumbs.homepage", null, false));

    PageParameters params = getPageParameters();
    if (params.getNamedKeys().contains("appUid")) {
        try {
            app = manageApplication.findApplicationByUID(params.get("appUid").toString());
            breadcrumbsItems.add(new BreadcrumbsItem(this.getClass(), params,
                    "portal.design.breadcrumbs.application.release.home", app.getLabel(), true));
        } catch (ObjectNotFoundException e) {
            String errMsg = getString("portal.release.objectnotfound");
            logger.error(errMsg);
            error(errMsg);

            breadcrumbsItems.add(new BreadcrumbsItem(this.getClass(), params,
                    "portal.design.breadcrumbs.releases.home", null, true));
        }

    } else {
        //            releasesTablePanel = new ReleasesTablePanel("releasesTablePanel", manageApplicationRelease);
        breadcrumbsItems.add(new BreadcrumbsItem(this.getClass(), params,
                "portal.design.breadcrumbs.releases.home", null, true));
    }

    Breadcrumbs breadcrumbs = new Breadcrumbs("breadcrumbs", breadcrumbsItems);
    add(breadcrumbs);

}

From source file:com.pushinginertia.wicket.core.util.PageParametersUtils.java

License:Open Source License

/**
 * Copies a {@link PageParameters} instance, pruning the key-value pairs for keys not given as parameters. In other
 * words, the copy will contain only key-value pairs where the key is specified as input to this method and the
 * key exists in the instance to copy.//  w ww  .ja  v  a 2  s . c o m
 * @param pp instance to copy
 * @param keys list of keys to copy
 * @return a new instance containing a subset of the key-value pairs in the instance to copy
 */
public static PageParameters copySubset(final PageParameters pp, final String... keys) {
    ValidateAs.notNull(pp, "pp");

    final PageParameters ppCopy = new PageParameters();
    final Set<String> ppKeys = pp.getNamedKeys();
    for (final String key : keys) {
        if (ppKeys.contains(key)) {
            final List<StringValue> valueList = pp.getValues(key);
            for (final StringValue value : valueList) {
                ppCopy.add(key, value.toString());
            }
        }
    }
    return ppCopy;
}

From source file:com.pushinginertia.wicket.core.util.PageParametersUtilsTest.java

License:Open Source License

@Test
public void copySubset() {
    final PageParameters pp = new PageParameters();

    final PageParameters pp0 = PageParametersUtils.copySubset(pp, "a", "b", "c");
    Assert.assertEquals(0, pp0.getNamedKeys().size());

    pp.add("a", "1");
    final PageParameters pp1 = PageParametersUtils.copySubset(pp, "a", "b", "c");
    Assert.assertEquals(1, pp1.getNamedKeys().size());
    Assert.assertEquals(1, pp1.getValues("a").size());
    Assert.assertEquals("1", pp1.get("a").toString());

    pp.add("a", "2");
    final PageParameters pp2 = PageParametersUtils.copySubset(pp, "a", "b", "c");
    Assert.assertEquals(1, pp2.getNamedKeys().size());
    Assert.assertEquals(2, pp2.getValues("a").size());
    Assert.assertTrue(pp2.getValues("a").contains(StringValue.valueOf("1")));
    Assert.assertTrue(pp2.getValues("a").contains(StringValue.valueOf("2")));

    pp.add("b", "3");
    final PageParameters pp3 = PageParametersUtils.copySubset(pp, "a", "b", "c");
    Assert.assertEquals(2, pp3.getNamedKeys().size());
    Assert.assertEquals(2, pp3.getValues("a").size());
    Assert.assertTrue(pp3.getValues("a").contains(StringValue.valueOf("1")));
    Assert.assertTrue(pp3.getValues("a").contains(StringValue.valueOf("2")));
    Assert.assertEquals(1, pp3.getValues("b").size());
    Assert.assertTrue(pp3.getValues("b").contains(StringValue.valueOf("3")));
}

From source file:com.userweave.pages.api.ApiPanel.java

License:Open Source License

private void init(PageParameters parameters) {
    RoundedBorderGray border = new RoundedBorderGray("border");
    add(border);//from  w  w w  .  j  a  v  a  2s  .  c o m

    RepeatingView repeater = new RepeatingView("repeater");
    border.add(repeater);

    Label noParameter = new Label("noParameter", new Model("Keine Parameter uebergeben!"));
    border.add(noParameter);

    Label errorMessageLabel = new Label("errorMessage", new Model(""));
    border.add(errorMessageLabel);

    Label secTokenHash = new Label("secTokenHash", new Model(""));
    border.add(secTokenHash);

    if (parameters != null && !parameters.isEmpty()) {
        noParameter.setVisible(false);

        // show parameters on panel
        Iterator iter = parameters.getNamedKeys().iterator();

        while (iter.hasNext()) {
            Object o = iter.next();
            String key = (String) o;
            String val = parameters.get(key).toString();

            final WebMarkupContainer line = new WebMarkupContainer(repeater.newChildId());

            line.add(new Label("key", new Model<String>(key)));
            line.add(new Label("value", new Model<String>(val)));

            repeater.add(line);
        }

        /*
         * Create pre configured study
         */
        Set<String> keys = parameters.getNamedKeys();

        if (!keys.contains(COMMAND_PARAM)
                || (keys.contains(COMMAND_PARAM) && parameters.get(COMMAND_PARAM) == null
                        || parameters.get(COMMAND_PARAM).equals(""))
                || (keys.contains(COMMAND_PARAM) && parameters.get(COMMAND_PARAM) != null
                        && parameters.get(COMMAND_PARAM).equals(COMMAND_CREATE_STUDY))) {
            // redirect doesn't contain study id
            if (!keys.contains(HASH_PARAM) || (keys.contains(HASH_PARAM) && parameters.get(HASH_PARAM) == null
                    || parameters.get(HASH_PARAM).equals(""))) {
                errorMessageLabel.setDefaultModel(new StringResourceModel("noHashParam", this, null));
            }

            /*
             * validate hash
             */
            else if (securityTokenService.validateToken(parameters.get(HASH_PARAM).toString(),
                    SecurityToken.SecurityTokenType.API_ACCESS) == null) {
                errorMessageLabel
                        .setDefaultModel(new StringResourceModel("wrongSecurityTokenHash", this, null));
            }

            else if (!keys.contains(IMG_URL_PARAM)
                    || (keys.contains(IMG_URL_PARAM) && parameters.get(IMG_URL_PARAM) == null
                            || parameters.get(IMG_URL_PARAM).equals(""))) {
                errorMessageLabel.setDefaultModel(new StringResourceModel("noImgUrlParam", this, null));
            }

            /*
             * check, if url is valid
             */
            else if (!isValidImgUrl(parameters.get(IMG_URL_PARAM).toString())) {
                errorMessageLabel.setDefaultModel(new StringResourceModel("invalidImgUrl", this, null));
            }

            else if (!keys.contains(LANGUAGE_URL_PARAM)
                    || (keys.contains(LANGUAGE_URL_PARAM) && parameters.get(LANGUAGE_URL_PARAM) == null
                            || parameters.get(LANGUAGE_URL_PARAM).equals(""))) {
                errorMessageLabel.setDefaultModel(new StringResourceModel("noLanguageUrlParam", this, null));
            }

            /*
             * locale param is correct, but maybe not a
             * supported one
             */
            else if (!isValidLanguageParam(parameters.get(LANGUAGE_URL_PARAM).toString())) {
                errorMessageLabel
                        .setDefaultModel(new StringResourceModel("notSupportedLanguageUrlParam", this, null));
            }

            /*
             * name parameter set but contains no value
             */
            else if (keys.contains(STUDY_NAME_PARAM) && (parameters.get(STUDY_NAME_PARAM) == null
                    || parameters.get(STUDY_NAME_PARAM).equals(""))) {
                errorMessageLabel.setDefaultModel(new StringResourceModel("noNameGiven", this, null));
            }

            else {
                CreateMockupStudyData data = new CreateMockupStudyData();

                String localeString = parameters.get(LANGUAGE_URL_PARAM).toString();

                data.setMockupUrl(parameters.get(IMG_URL_PARAM).toString(), new Locale(localeString));
                data.setSecurityTokenHash(parameters.get(HASH_PARAM).toString());
                data.setLocaleString(localeString);

                if (keys.contains(STUDY_NAME_PARAM)) {
                    data.setStudyName(parameters.get(STUDY_NAME_PARAM).toString());
                }

                UserWeaveSession.get().setCreateMockupStudyData(data);

                setResponsePage(ApiCreateStudyPage.class);
            }
        } else {
            /*
             * Create SecurityToken
             */
            if (parameters.get(COMMAND_PARAM).equals(COMMAND_GET_TOKEN)) {

                // redirect doesn't contain study id
                if (!keys.contains(HASH_PARAM)
                        || (keys.contains(HASH_PARAM) && parameters.get(HASH_PARAM) == null
                                || parameters.get(HASH_PARAM).equals(""))) {
                    errorMessageLabel.setDefaultModel(new StringResourceModel("noHashParam", this, null));
                } else {

                    if (isValidHash(parameters.get(HASH_PARAM).toString(), errorMessageLabel)) {
                        ApiCredentials curPartner = apiCredentialsDao
                                .findByHash(parameters.get(HASH_PARAM).toString());
                        secTokenHash.setDefaultModel(
                                new Model(securityTokenService.createTokenForApi(curPartner.getUser())));
                    }
                }
            } else {
                errorMessageLabel.setDefaultModel(new StringResourceModel("unkownCommandParam", this, null,
                        new Object[] { parameters.get(COMMAND_PARAM) }));
            }
        }
    }
}

From source file:gr.abiss.calipso.domain.ItemSearch.java

License:Open Source License

public void initFromPageParameters(PageParameters params, User user, CalipsoService calipsoService) {
    showHistory = params.get("showHistory").toBoolean(false);
    showDetail = params.get("showDetail").toBoolean(false);
    if (showDetail) {
        getColumnHeading(DETAIL).setVisible(true);
    }/* w w w.  ja  v a2  s. co m*/
    if (this.space != null && (!space.isItemSummaryEnabled())) {
        ColumnHeading summaryHeading = getColumnHeading(SUMMARY);
        if (summaryHeading != null) {
            summaryHeading.setVisible(false);
        }
    }
    pageSize = params.get("pageSize").toInt(calipsoService.getRecordsPerPage());
    sortDescending = !params.get("sortAscending").toBoolean();
    sortFieldName = params.get("sortFieldName").toString("id");
    for (Object o : params.getNamedKeys()) {
        logger.info("processing parameter: " + 0);
        String name = o.toString();
        if (ColumnHeading.isValidFieldOrColumnName(name)) {
            ColumnHeading ch = getColumnHeading(name);
            ch.loadFromQueryString(params.get(name).toString(), user, calipsoService);
        }
    }
    relatingItemRefId = params.get("relatingItemRefId").toString(null);
}

From source file:guru.mmp.application.web.template.navigation.NavigationState.java

License:Apache License

/**
 * Returns <code>true</code> if the specified page is the last page that was accessed in the
 * navigation hierarchy or <code>false</code> otherwise.
 *
 * @param page the page//from   w  w  w .  j av a 2  s  .  c om
 *
 * @return <code>true</code> if the specified page is the last page that was accessed in the
 * navigation hierarchy or <code>false</code> otherwise
 */
public boolean isLastPageAccessedInNavigationHierarchy(Page page) {
    // If we do not have a last page that was accessed in the navigation hierarchy
    if (lastPageAccessedInNavigationHierarchyClass == null) {
        return false;
    }

    /*
     * If the page classes don't match then this can't be the last page that was accessed in
     * the navigation hierarchy.
     */
    if (lastPageAccessedInNavigationHierarchyClass != page.getPageClass()) {
        return false;
    }

    /*
     * If the page does not have parameters then this must be the last page that was accessed in
     * the navigation hierarchy.
     */
    if (page.getPageParameters().isEmpty()) {
        return true;
    }

    /*
     * If we get here we check the page parameters since we might be dealing with the same
     * type of page but it might have different parameters.
     */
    PageParameters pageParameters = page.getPageParameters();

    for (String namedKey : pageParameters.getNamedKeys()) {
        List<StringValue> pageParameterValues = pageParameters.getValues(namedKey);

        List<StringValue> lastPageAccessedInNavigationHierarchyParameterValues = lastPageAccessedInNavigationHierarchyParameters
                .getValues(namedKey);

        if (pageParameterValues.size() != lastPageAccessedInNavigationHierarchyParameterValues.size()) {
            return false;
        }

        for (int i = 0; i < pageParameterValues.size(); i++) {
            if (!pageParameterValues.get(i).toString()
                    .equals(lastPageAccessedInNavigationHierarchyParameterValues.get(i).toString())) {
                return false;
            }
        }
    }

    return true;
}