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:org.wicketstuff.shiro.page.LogoutPage.java

License:Apache License

@SuppressWarnings("unchecked")
public LogoutPage(final PageParameters parameters) {
    final StringValue page = parameters.get(REDIRECTPAGE_PARAM);
    Class<? extends Page> pageClass;
    if (!page.isNull())
        try {// w w w  . ja  va2  s. c om
            pageClass = (Class<? extends Page>) Class.forName(page.toString());
        } catch (final ClassNotFoundException e) {
            throw new RuntimeException(e);
        }
    else
        pageClass = getApplication().getHomePage();

    setStatelessHint(true);
    setResponsePage(pageClass);

    // this should remove the cookie and invalidate session
    final Subject subject = SecurityUtils.getSubject();
    LOG.info("logout: " + subject);
    subject.logout();

    return;
}

From source file:org.wicketTutorial.behaviors.OnChangeSingleChoiceBehavior.java

License:Apache License

@Override
public void onRequest() {

    Request request = RequestCycle.get().getRequest();
    IRequestParameters requestParameters = request.getRequestParameters();
    StringValue choiceId = requestParameters.getParameterValue("choiceId");

    boundComponent.setDefaultModelObject(convertChoiceIdToChoice(choiceId.toString()));
}

From source file:org.yes.cart.web.page.AjaxWlPage.java

License:Apache License

/**
 * {@inheritDoc}//from  w  ww .j  a  va  2s.co m
 */
@Override
protected void onBeforeRender() {

    executeHttpPostedCommands();

    final StringValue skuValue = getPageParameters().get(ShoppingCartCommand.CMD_ADDTOWISHLIST);
    final String sku = skuValue.toString();

    final StringBuilder outJson = new StringBuilder();
    outJson.append("{ \"SKU\": \"").append(sku.replace("\"", "")).append("\" }");

    addOrReplace(new Label("wlAddedObj", outJson.toString()).setEscapeModelStrings(false));
    super.onBeforeRender();

    persistCartIfNecessary();
}

From source file:org.yes.cart.web.page.ShoppingCartPage.java

License:Apache License

@Override
protected void onBeforeRender() {

    executeHttpPostedCommands();/*  w  ww .java2  s .c o  m*/

    addOrReplace(new FeedbackPanel(FEEDBACK)).addOrReplace(new ShoppingCartView(CART_VIEW))
            .addOrReplace(new StandardFooter(FOOTER)).addOrReplace(new StandardHeader(HEADER))
            .addOrReplace(new ServerSideJs("serverSideJs"))
            .addOrReplace(new HeaderMetaInclude("headerInclude"));

    final PageParameters params = getPageParameters();
    final StringValue checkoutError = params.get("e");
    if (!checkoutError.isEmpty()) {

        if ("ec".equals(checkoutError.toString())) {
            warn(getLocalizer().getString("orderErrorCouponInvalid", this, new Model<ValueMap>(
                    new ValueMap(Collections.singletonMap("coupon", params.get("ec").toString())))));
        } else if ("es".equals(checkoutError.toString())) {
            warn(getLocalizer().getString("orderErrorSkuInvalid", this, new Model<ValueMap>(
                    new ValueMap(Collections.singletonMap("sku", params.get("es").toString())))));
        } else {
            error(getLocalizer().getString("orderErrorGeneral", this));
        }

    }

    final ShoppingCart cart = getCurrentCart();
    if (cart.getCartItemsCount() == 0) {
        info(getLocalizer().getString("emptyCart", this));
    }

    addOrReplace(new WishListNotification("wishListNotification"));

    super.onBeforeRender();

    final boolean cartModified = cart.isModified();

    if (!cartModified && cart.getCartItemsCount() > 0) {
        // Refresh prices on cart view
        getShoppingCartCommandFactory().execute(ShoppingCartCommand.CMD_RECALCULATEPRICE, cart,
                (Map) Collections.singletonMap(ShoppingCartCommand.CMD_RECALCULATEPRICE,
                        ShoppingCartCommand.CMD_RECALCULATEPRICE));
    }

    persistCartIfNecessary();

    if (cartModified) {
        // redirect to clear all command parameters
        throw new RestartResponseException(ShoppingCartPage.class);
    }
}

From source file:org.yes.cart.web.util.WicketUtil.java

License:Apache License

/**
 * Transform wicket 1.5 page parameter to more traditional map.  Expensive operation.
 *
 * @param pageParameters given parameters to transform.
 * @return parameters transformed to map
 *//*from  www  . j ava  2s  .c  o  m*/
public Map<String, List<String>> pageParametesAsMultiMap(final PageParameters pageParameters) {
    final Map<String, List<String>> map = new LinkedHashMap<String, List<String>>();
    if (pageParameters != null) {
        for (String key : pageParameters.getNamedKeys()) {
            if (!commandConfig.isInternalCommandKey(key)) {
                final List<String> vals = new ArrayList<String>();
                for (final StringValue value : pageParameters.getValues(key)) {
                    vals.add(value.toString());
                }
                map.put(key, vals);
            }
        }
    }
    return map;
}

From source file:org.yes.cart.web.util.WicketUtilTest.java

License:Apache License

@Test
public void testGetFilteredRequestParametersForSearch() {
    PageParameters parametersToFilter = new PageParameters("query=val1,query=val2,query=val3");
    assertEquals(1, parametersToFilter.getNamedKeys().size());
    assertEquals(3, parametersToFilter.getValues("query").size());
    parametersToFilter.remove("query", "val2");
    assertEquals(2, parametersToFilter.getValues("query").size());
    for (StringValue val : parametersToFilter.getValues("query")) {
        assertFalse("val2".equals(val.toString()));
    }/*from w ww . j a va  2  s  . com*/
}

From source file:sf.wicklet.gwt.site.server.db.CommentInfo.java

License:Apache License

public CommentInfo(final String user, final StringValue subject, final StringValue content) {
    this.user = user;
    this.subject = subject.toString();
    this.content = content.toString();
}

From source file:sf.wicklet.gwt.site.server.db.WikiCommentInfo.java

License:Apache License

public WikiCommentInfo(final String user, final String path, final StringValue subject,
        final StringValue content) {
    this(user, path, subject.toString(), content.toString());
}

From source file:sk.drunkenpanda.leaflet.behaviors.LeafletAjaxBehaviorTest.java

License:Apache License

@Test
public void testGetVariable() {
    final WicketTester tester = getTester();

    TestAjaxBehavior behavior = new TestAjaxBehavior("testA");
    Map map = new Map("map");
    map.add(behavior);// w  w w  .  j a  v a2s.co  m

    tester.startComponentInPage(map);

    MockHttpServletRequest request = this.prepareRequest(tester, behavior, "testA", "testValue");
    tester.processRequest(request);

    StringValue actual = behavior.actualVariableValue;
    assertThat(actual.isEmpty()).isFalse();
    assertThat(actual.toString()).isEqualTo("testValue");
}

From source file:sk.drunkenpanda.leaflet.behaviors.LeafletAjaxEventBehavior.java

License:Apache License

@Override
protected void respond(AjaxRequestTarget target) {
    final StringValue eventJs = this.getVariableValue(this.eventType.getJavascriptName());

    if (!eventJs.isEmpty()) {
        final JsonRenderer jsonRenderer = JsonRendererFactory.getJsonRenderer();
        final E event = jsonRenderer.fromJson(eventJs.toString(), jsonPayloadClass);
        this.onEvent(event, target);
    }//from   www  .  j  ava 2s  .co  m
}