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

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

Introduction

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

Prototype

public final boolean toBoolean() throws StringValueConversionException 

Source Link

Document

Convert this text to a boolean.

Usage

From source file:net.dontdrinkandroot.extensions.wicket.jqueryui.SortableBehavior.java

License:Apache License

@Override
protected void respond(AjaxRequestTarget target) {
    final StringValue oldPositionValue = this.getComponent().getRequest().getQueryParameters()
            .getParameterValue("oldPosition");
    final StringValue newPositionValue = this.getComponent().getRequest().getQueryParameters()
            .getParameterValue("newPosition");
    final StringValue outValue = this.getComponent().getRequest().getQueryParameters().getParameterValue("out");
    final StringValue componentPathValue = this.getComponent().getRequest().getQueryParameters()
            .getParameterValue("componentPath");

    final int oldPosition = oldPositionValue.toInt();
    final int newPosition = newPositionValue.toInt();
    final boolean out = outValue.toBoolean();
    final String droppedComponentPath = componentPathValue.toString("");
    final String boundComponentPath = this.getComponent().getPageRelativePath();

    if (boundComponentPath.equals(droppedComponentPath)) {

        /* The dropped component is one of our list items */
        if (out) {
            /* Item was dragged outside of the list, remove it */
            this.onRemove(target, oldPosition, newPosition);
        } else {//from w  w  w  .  j  a  v a 2  s  .c  o m
            /* Item was dragged within the list, update position */
            this.onPositionChanged(target, oldPosition, newPosition);
        }
    } else {

        /* Retrieve the dropped component by its path and insert its model into the list */
        final Component droppedComponent = this.getComponent().getPage().get(droppedComponentPath);
        Object droppedComponentModelObject = null;
        if (droppedComponent != null) {
            droppedComponentModelObject = droppedComponent.getDefaultModelObject();
        }
        this.onInsert(target, droppedComponentModelObject, newPosition);
    }
}

From source file:net.dontdrinkandroot.wicket.behavior.ajax.KeyEventBehavior.java

License:Apache License

@Override
protected void onEvent(AjaxRequestTarget target) {

    final StringValue altKeyValue = this.getComponent().getRequest().getQueryParameters()
            .getParameterValue("keyEvent.altKey");
    final boolean altKey = altKeyValue.toBoolean();

    final StringValue charCodeValue = this.getComponent().getRequest().getQueryParameters()
            .getParameterValue("keyEvent.charCode");
    final int charCode = charCodeValue.toInt();

    final StringValue ctrlKeyValue = this.getComponent().getRequest().getQueryParameters()
            .getParameterValue("keyEvent.ctrlKey");
    final boolean ctrlKey = ctrlKeyValue.toBoolean();

    final StringValue keyCodeValue = this.getComponent().getRequest().getQueryParameters()
            .getParameterValue("keyEvent.keyCode");
    final int keyCode = keyCodeValue.toInt();

    final StringValue metaKeyValue = this.getComponent().getRequest().getQueryParameters()
            .getParameterValue("keyEvent.metaKey");
    final boolean metaKey = metaKeyValue.toBoolean();

    final StringValue shiftKeyValue = this.getComponent().getRequest().getQueryParameters()
            .getParameterValue("keyEvent.shiftKey");
    final boolean shiftKey = shiftKeyValue.toBoolean();

    final StringValue whichValue = this.getComponent().getRequest().getQueryParameters()
            .getParameterValue("keyEvent.which");
    final int which = whichValue.toInt();

    this.onEvent(target, new KeyEventResponse(which, keyCode, charCode, altKey, ctrlKey, metaKey, shiftKey));
}

From source file:net.dontdrinkandroot.wicket.behavior.jqueryui.SortableBehavior.java

License:Apache License

@Override
protected void respond(AjaxRequestTarget target) {

    final StringValue oldPositionValue = this.getComponent().getRequest().getQueryParameters()
            .getParameterValue("oldPosition");
    final StringValue newPositionValue = this.getComponent().getRequest().getQueryParameters()
            .getParameterValue("newPosition");
    final StringValue outValue = this.getComponent().getRequest().getQueryParameters().getParameterValue("out");
    final StringValue componentPathValue = this.getComponent().getRequest().getQueryParameters()
            .getParameterValue("componentPath");

    int oldPosition = oldPositionValue.toInt();
    int newPosition = newPositionValue.toInt();
    boolean out = outValue.toBoolean();
    String droppedComponentPath = componentPathValue.toString("");
    String boundComponentPath = this.getComponent().getPageRelativePath();

    if (boundComponentPath.equals(droppedComponentPath)) {

        /* The dropped component is one of our list items */
        if (out) {
            /* Item was dragged outside of the list, remove it */
            this.onRemove(target, oldPosition);
        } else {/*from  w  w w . ja  va2s  . c  o  m*/
            /* Item was dragged within the list, update position */
            this.onPositionChanged(target, oldPosition, newPosition);
        }

    } else {

        /* Retrieve the dropped component by its path and insert its model into the list */
        Component droppedComponent = this.getComponent().getPage().get(droppedComponentPath);
        Object droppedComponentModelObject = null;
        if (droppedComponent != null) {
            droppedComponentModelObject = droppedComponent.getDefaultModelObject();
        }
        this.onInsert(target, droppedComponentModelObject, newPosition);
    }
}

From source file:org.projectforge.web.wicket.WicketUtils.java

License:Open Source License

public static boolean getAsBoolean(final PageParameters parameters, final String name) {
    final StringValue sval = parameters.get(name);
    if (sval == null || sval.isNull() == true) {
        return false;
    } else {// w ww  . j av  a  2  s  .  co  m
        return sval.toBoolean();
    }
}

From source file:se.inera.axel.shs.broker.webconsole.agreement.AgreementFormPanel.java

License:Open Source License

private boolean isEditMode(final PageParameters parameters) {
    StringValue editValue = parameters.get(EDIT_MODE.toString());
    return editValue != null && editValue.toBoolean();
}