Example usage for org.apache.wicket.request Url setQueryParameter

List of usage examples for org.apache.wicket.request Url setQueryParameter

Introduction

In this page you can find the example usage for org.apache.wicket.request Url setQueryParameter.

Prototype

public void setQueryParameter(final String name, final Object value) 

Source Link

Document

Convenience method that removes all query parameters with given name and adds new query parameter with specified name and value

Usage

From source file:com.github.javawithmarcus.wicket.cdi.ConversationPropagator.java

License:Apache License

@Override
public void onUrlMapped(RequestCycle cycle, IRequestHandler handler, Url url) {
    Conversation conversation = getConversation();
    logger.debug("In onUrlMapped id = {}", conversation.getId());
    // no need to propagate the conversation to packaged resources, they should never change
    if (handler instanceof ResourceReferenceRequestHandler) {
        if (((ResourceReferenceRequestHandler) handler)
                .getResourceReference() instanceof PackageResourceReference) {
            return;
        }//from  ww w .j a v  a  2  s. c  om
    }

    if (conversation.isTransient()) {
        return;
    }

    if (getPropagation().propagatesViaParameters(handler)) {
        // propagate cid to bookmarkable pages via urls

        logger.debug("Propagating non-transient conversation {} via url", conversation.getId());

        url.setQueryParameter(CID_ATTR, conversation.getId());
    } else {
        //we did not propagate.
        //Cancel scheduled conversation end if page is auto.
        Page page = getPage(handler);
        if (page != null) {
            Conversational annotation = page.getClass().getAnnotation(Conversational.class);
            if (annotation != null) {
                if (annotation.auto() && getConversationManager().isConversationScheduledForEnd()) {
                    getConversationManager().cancelConversationEnd(); //was scheduled to end but next page is auto
                }
            }
        }
    }
}