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

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

Introduction

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

Prototype

@Override
public final String toString() 

Source Link

Usage

From source file:com.evolveum.midpoint.web.page.admin.workflow.PageProcessInstance.java

License:Apache License

private ProcessInstanceDto loadProcessInstance() {
    OperationResult result = new OperationResult(OPERATION_LOAD_TASK);

    try {//from  w  w w  . ja v  a2s  . c o m
        StringValue pid = parameters.get(OnePageParameterEncoder.PARAMETER);
        boolean finished = parameters.get(PARAM_PROCESS_INSTANCE_FINISHED).toBoolean();
        WfProcessInstanceType processInstance;
        try {
            processInstance = getWorkflowManager().getProcessInstanceById(pid.toString(), finished, true,
                    result);
        } catch (ObjectNotFoundException e) {
            if (finished == false) {
                // maybe the process instance has finished in the meanwhile...
                processInstance = getWorkflowManager().getProcessInstanceById(pid.toString(), true, true,
                        result);
            } else {
                throw e;
            }
        }
        ProcessInstanceState processInstanceState = (ProcessInstanceState) processInstance.getState();
        String shadowTaskOid = processInstanceState.getShadowTaskOid();
        Task shadowTask = null;
        try {
            shadowTask = getTaskManager().getTask(shadowTaskOid, result);
        } catch (ObjectNotFoundException e) {
            // task is already deleted, no problem here
        }
        return new ProcessInstanceDto(processInstance, shadowTask);
    } catch (Exception ex) {
        result.recordFatalError("Couldn't get process instance information.", ex);
        showResult(result);
        getSession().error(getString("pageProcessInstance.message.cantGetDetails"));

        if (!result.isSuccess()) {
            showResultInSession(result);
        }
        throw getRestartResponseException(PageProcessInstancesAll.class);
    }
}

From source file:com.evolveum.midpoint.web.page.login.PageSelfRegistration.java

License:Apache License

private String getOidFromParams(PageParameters pageParameters) {
    if (pageParameters == null) {
        return null;
    }//w  ww.j  a  v a  2  s . co  m

    StringValue oidValue = pageParameters.get(PARAM_USER_OID);
    if (oidValue != null) {
        return oidValue.toString();
    }

    return null;
}

From source file:com.evolveum.midpoint.web.page.self.PageAccountActivation.java

License:Apache License

private String getOidFromParameter(PageParameters params) {

    if (params == null || params.isEmpty()) {
        LOGGER.error("No page parameters found for account activation. No user to activate his/her accounts");
        return null;
    }//from   ww w . ja  va2 s.c  o m

    StringValue userValue = params.get(SchemaConstants.USER_ID);
    if (userValue == null || userValue.isEmpty()) {
        LOGGER.error(
                "No user defined in the page parameter. Expected user=? attribute filled but didmn't find one.");
        return null;
    }

    return userValue.toString();

}

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);//from   w  ww . java  2 s .  co  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:com.googlecode.wickedcharts.wicket6.highcharts.features.selection.SelectionBehavior.java

License:Apache License

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

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

    StringValue selectionEventJson = getVariableValue(SELECTION_EVENT);
    if (selectionEventJson != null && !"".equals(selectionEventJson.toString())) {
        JsonRenderer renderer = JsonRendererFactory.getInstance().getRenderer();
        JsonSelectionEvent jsonEvent = renderer.fromJson(selectionEventJson.toString(),
                JsonSelectionEvent.class);

        for (JsonSelection jsonSelection : jsonEvent.getxAxes()) {
            Selection selection = mapJsonSelection(options, jsonSelection);
            event.getxAxes().add(selection);
        }/*w  w  w . j a  v  a2s . c  om*/

        for (JsonSelection jsonSelection : jsonEvent.getyAxes()) {
            Selection selection = mapJsonSelection(options, jsonSelection);
            event.getyAxes().add(selection);
        }
    }

    onSelection(event, target);
}

From source file:com.googlecode.wicketelements.security.SignOutPage.java

License:Apache License

public SignOutPage(final PageParameters params) {
    PARAM_REQ.Object.requireNotNull(params, "The page parameters parameter must not be null.");
    final StringValue page = params.get(REDIRECTPAGE_PARAM);
    Class<? extends Page> pageClass;
    if (page != null && !StringUtils.isBlank(page.toString())) {
        LOGGER.debug("Redirect page not blank: {}", page);
        try {//from w w w  . j av  a  2s.  c o  m
            pageClass = (Class<? extends Page>) Class.forName(page.toString());
        } catch (ClassNotFoundException ex) {
            LOGGER.debug("Class not found for redirect page: {}", page);
            pageClass = getApplication().getHomePage();
        }
    } else {
        LOGGER.debug("No redirect page, redirecting to application home page.");
        pageClass = getApplication().getHomePage();
    }
    setStatelessHint(true);
    getSession().invalidateNow();
    setResponsePage(pageClass);
}

From source file:com.pushinginertia.wicket.core.form.behavior.FormInputSaveDraftBehavior.java

License:Open Source License

@Override
protected void respond(final AjaxRequestTarget target) {
    // prevent focus change
    target.focusComponent(null);/*w  w  w  . j  a  v  a 2  s.  c  o  m*/

    // fire callback for any changes sent from the client
    final IRequestParameters parameters = RequestCycle.get().getRequest().getRequestParameters();
    final Set<String> parameterNames = parameters.getParameterNames();
    for (final FormComponent<String> component : components) {
        final String id = component.getMarkupId();
        if (parameterNames.contains(id)) {
            final StringValue value = parameters.getParameterValue(id);
            callback.saveDraft(component, value.toString());
        }
    }
}

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.//from  w w  w.  j ava2 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.PageParametersUtils.java

License:Open Source License

/**
 * Retrieves an integer value from given page parameters, returning a default value if the name doesn't exist in the
 * parameters or the value cannot be parsed into an integer.
 * @param pp parameters to load the value from
 * @param name name to look up//from  w  w  w .  ja  v  a2  s  . com
 * @param defaultValue default value if one cannot be parsed
 * @return parsed value
 */
public static int getInt(final PageParameters pp, final String name, final int defaultValue) {
    ValidateAs.notEmpty(name, "name");

    final StringValue value = pp.get(name);
    if (value.isEmpty()) {
        return defaultValue;
    }
    try {
        return Integer.parseInt(value.toString());
    } catch (final NumberFormatException e) {
        LOG.info("Page parameter value [{}] from name [{}] could not be parsed into an integer.", value, name);
        return defaultValue;
    }
}

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

License:Open Source License

/**
 * Retrieves a string value from given page parameters and identifies the matching enum value for that string. All
 * enumerations must be uppercased and the input is uppercased for the comparison operation. A default value is
 * returned if no value is given or it doesn't match any of the enumerations.
 * @param pp parameters to load the value from
 * @param name name to look up// w  w w  . j  a  v a2s .c om
 * @param enumClass enum type
 * @param defaultValue default value if one cannot be parsed
 * @param <E> enum type
 * @return parsed value
 */
public static <E extends Enum> E getEnum(final PageParameters pp, final String name, final Class<E> enumClass,
        final E defaultValue) {
    ValidateAs.notEmpty(name, "name");

    final StringValue value = pp.get(name);
    if (value.isEmpty()) {
        return defaultValue;
    }

    final String upperValue = value.toString().toUpperCase();

    for (final E enumValue : enumClass.getEnumConstants()) {
        if (enumValue.name().equals(upperValue)) {
            return enumValue;
        }
    }

    return defaultValue;
}