Example usage for org.apache.wicket.util.string StringValue toInteger

List of usage examples for org.apache.wicket.util.string StringValue toInteger

Introduction

In this page you can find the example usage for org.apache.wicket.util.string StringValue toInteger.

Prototype

public final Integer toInteger() throws StringValueConversionException 

Source Link

Document

Convert this text to an Integer.

Usage

From source file:com.evolveum.midpoint.gui.api.util.WebComponentUtil.java

License:Apache License

public static Integer getIntegerParameter(PageParameters params, String key) {
    if (params == null || params.get(key) == null) {
        return null;
    }//from  ww  w .j  a v a 2s . c  o  m

    StringValue value = params.get(key);
    if (!StringUtils.isNumeric(value.toString())) {
        return null;
    }

    return value.toInteger();
}

From source file:com.googlecode.wickedcharts.wicket6.highcharts.features.interaction.InteractionBehavior.java

License:Apache License

@Override
protected void respond(final AjaxRequestTarget target) {
    Chart chart = (Chart) getComponent();
    Options options = chart.getOptions();

    InteractionEvent event = new InteractionEvent();
    event.setJavascriptChartName(chart.getJavaScriptVarName());

    StringValue selectedPointValue = getVariableValue(SELECTED_POINT);
    if (selectedPointValue != null && !"".equals(selectedPointValue.toString())) {
        Integer selectedPoint = selectedPointValue.toInteger();
        Point point = OptionsUtil.getPointWithWickedChartsId(options, selectedPoint);
        event.setSelectedPoint(point);/*  w  ww.j  a va 2s. c o m*/
    }

    StringValue selectedSeriesValue = getVariableValue(SELECTED_SERIES);
    if (selectedSeriesValue != null && !"".equals(selectedSeriesValue.toString())) {
        Integer selectedSeries = selectedSeriesValue.toInteger();
        Series<?> series = OptionsUtil.getSeriesWithWickedChartsId(options, selectedSeries);
        event.setSelectedSeries(series);
    }

    event.setSelectedChart(options);

    onEvent(event, target);
}

From source file:cz.zcu.kiv.eegdatabase.wui.ui.administration.forms.LicenseManageFormPage.java

License:Open Source License

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

    License license = licenseFacade.read(licenseId.toInteger());

    add(new Label("headTitle", ResourceUtils.getModel("pageTitle.editLicenseTemplate")));
    add(new ButtonPageMenu("leftMenu", AdministrationPageLeftMenu.values()));
    add(new LicenseForm("form", new Model<License>(license), licenseFacade, getFeedback()));

}

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:de.alpharogroup.wicket.base.util.parameter.PageParametersExtensions.java

License:Apache License

/**
 * Gets the Integer object or returns null if the given StringValue is null or empty.
 *
 * @param stringValue//from www . j av  a  2 s  .  c o  m
 *            the user id as StringValue object
 * @return the Integer object or null if the given StringValue is null or empty.
 */
public static Integer toInteger(final StringValue stringValue) {
    Integer value = null;
    if (isNotNullOrEmpty(stringValue)) {
        try {
            value = stringValue.toInteger();
        } catch (final StringValueConversionException e) {
            LOGGER.error("Error by converting the given StringValue.", e);
        }
    }
    return value;
}

From source file:jp.gihyo.wicket.page.ajax.AjaxTimeline.java

License:Apache License

public AjaxTimeline(PageParameters parameters) {
    super(parameters);
    if (!AppSession.get().isLoggedIn()) {
        throw new RedirectToUrlException(getRequestCycle().urlFor(Login.class, null).toString());
    }/*from  w w w.j  a v  a  2 s. c  o m*/

    //this.currentPageNumber = parameters.getAsInteger("page", 1);
    StringValue page = parameters.get("page");
    if (!page.isEmpty()) {
        this.currentPageNumber = page.toInteger();
    }
    constructPage();
}

From source file:jp.gihyo.wicket.page.paging.PagingTimeline.java

License:Apache License

public PagingTimeline(PageParameters parameters) {
    super(parameters);
    if (!AppSession.get().isLoggedIn()) {
        throw new RedirectToUrlException(getRequestCycle().urlFor(Login.class, null).toString());
    }//from  w w  w. ja va 2 s .  co m

    //this.currentPageNumber = parameters.getAsInteger("page", 1);
    StringValue page = parameters.get("page");
    if (!page.isEmpty()) {
        this.currentPageNumber = page.toInteger();
    }

    constructPage();
}

From source file:net.dontdrinkandroot.extensions.wicket.component.jqueryui.JQueryUiAjaxSlider.java

License:Apache License

public JQueryUiAjaxSlider(final String id, final IModel<Integer> model, IModel<Integer> minModel,
        final IModel<Integer> maxModel, final int step) {

    super(id, model);

    this.setOutputMarkupId(true);

    this.minModel = minModel;
    this.maxModel = maxModel;
    this.step = step;

    this.valueChangedBehaviour = new AbstractDefaultAjaxBehavior() {

        private static final long serialVersionUID = 1L;

        @Override/* ww w  .j av a 2s .  c om*/
        protected void respond(final AjaxRequestTarget target) {

            final StringValue value = JQueryUiAjaxSlider.this.getRequest().getQueryParameters()
                    .getParameterValue("value");
            JQueryUiAjaxSlider.this.setModelObject(value.toInteger());
            JQueryUiAjaxSlider.this.onValueChanged(target);
        }
    };
    this.add(this.valueChangedBehaviour);
}

From source file:net.dontdrinkandroot.wicket.component.jqueryui.JQueryUiAjaxSlider.java

License:Apache License

public JQueryUiAjaxSlider(final String id, final IModel<Integer> model, IModel<Integer> minModel,
        final IModel<Integer> maxModel, final int step) {

    super(id, model);

    this.setOutputMarkupId(true);

    this.minModel = minModel;
    this.maxModel = maxModel;
    this.step = step;

    this.valueChangedBehaviour = new AbstractDefaultAjaxBehavior() {

        private static final long serialVersionUID = 1L;

        @Override/*from   ww w  .  j  ava2s.c  om*/
        protected void respond(final AjaxRequestTarget target) {

            final StringValue value = JQueryUiAjaxSlider.this.getRequest().getQueryParameters()
                    .getParameterValue("value");
            JQueryUiAjaxSlider.this.setModelObject(value.toInteger());
            JQueryUiAjaxSlider.this.onValueChanged(target);
        }

    };
    this.add(this.valueChangedBehaviour);
}

From source file:org.antbear.jee.wicket.GeolocationAjaxBehavior.java

License:Apache License

@Override
protected void respond(AjaxRequestTarget target) {
    log.debug("respond");

    Request request = RequestCycle.get().getRequest();
    IRequestParameters requestParameters = request.getRequestParameters();

    StringValue svStatus = requestParameters.getParameterValue("status");
    if (svStatus == null || svStatus.isNull() || svStatus.isEmpty())
        throw new RuntimeException("Invariant violation: status is a required parameter");
    Integer status = svStatus.toInteger();

    if (status == 0) {
        StringValue svMessage = requestParameters.getParameterValue("msg");
        if (svMessage == null || svMessage.isNull() || svMessage.isEmpty())
            throw new RuntimeException("Invariant violation: message is a required parameter");

        log.debug("Geolocation failed: " + svMessage.toString());
        onError(target, svMessage.toString());

    } else {//from w w  w.j  a va  2 s  .  co m
        StringValue svLatitude = requestParameters.getParameterValue("lat");
        if (svLatitude == null || svLatitude.isNull() || svLatitude.isEmpty())
            throw new RuntimeException("Invariant violation: message is a required parameter");

        StringValue svLongitude = requestParameters.getParameterValue("lon");
        if (svLongitude == null || svLongitude.isNull() || svLongitude.isEmpty())
            throw new RuntimeException("Invariant violation: message is a required parameter");

        log.debug("Geolocation received: lat " + svLatitude.toDouble() + ", lon " + svLongitude.toDouble());
        onLocation(target, svLatitude.toDouble(), svLongitude.toDouble());
    }
}