congrats Icon
New! Announcing Tabnine Chat Beta
Learn More
Tabnine Logo
RequestContext
Code IndexAdd Tabnine to your IDE (free)

How to use
RequestContext
in
org.apache.wicket

Best Java code snippets using org.apache.wicket.RequestContext (Showing top 20 results out of 315)

origin: org.onehippo.cms7/hippo-cms-xinha-integration

public static final String encodeResourceURL(String url) {
  // if it is in portlet environment, just wrap the url in portlet resource url.
  RequestContext requestContext = RequestContext.get();
  if (requestContext.isPortletRequest()) {
    url = ((PortletRequestContext) requestContext).encodeResourceURL(url).toString();
    // use relative url (FIXME: why?)
    if (url.startsWith("http:") || url.startsWith("https:")) {
      int offset = url.indexOf('/', 8);
      if (offset != -1) {
        url = url.substring(offset);
      }
    }
  }
  return url;
}
origin: org.apache.wicket/com.springsource.org.apache.wicket

/**
 * @return The current threads request context, will make one if there wasn't one.
 */
public static final RequestContext get()
{
  RequestContext context = (RequestContext)current.get();
  if (context == null)
  {
    context = new RequestContext();
  }
  return context;
}
origin: org.apache.wicket/com.springsource.org.apache.wicket

/**
 * Factory method for creating header response
 * 
 * @return new header response
 */
protected IHeaderResponse newHeaderResponse()
{
  IHeaderResponse headerResponse = RequestContext.get().getHeaderResponse();
  if (headerResponse == null)
  {
    // no (portlet) headerResponse override, create a default one
    headerResponse = new HeaderResponse()
    {
      protected Response getRealResponse()
      {
        return HtmlHeaderContainer.this.getResponse();
      }
    };
  }
  return headerResponse;
}
origin: org.apache.wicket/com.springsource.org.apache.wicket

RequestContext requestContext = RequestContext.get();
boolean portletRequest = requestContext.isPortletRequest();
boolean sharedResourceURL = false;
  url = requestContext.encodeRenderURL(url == null ? encode(requestCycle,
      (IBookmarkablePageRequestTarget)requestTarget) : url);
  url = requestContext.encodeSharedResourceURL(url == null ? encode(requestCycle,
      (ISharedResourceRequestTarget)requestTarget) : url);
  sharedResourceURL = true;
            .getDeclaringClass()))
      url = requestContext.encodeResourceURL(url);
        url = requestContext.encodeRenderURL(url);
origin: org.apache.wicket/com.springsource.org.apache.wicket

realResponse.write("<span id=\"" + RequestContext.get().getNamespace() +
    "_embedded_head\" style=\"display:none\">");
realResponse.write(output);
origin: org.ops4j.pax.wicket/pax-wicket-service

markupIdPostfix = RequestContext.get().encodeMarkupId(markupIdPostfix);
origin: org.apache.wicket/com.springsource.org.apache.wicket

  public void sendRedirect(String redirectLocation) throws IOException
  {
    RequestContext rc = RequestContext.get();
    if (rc instanceof PortletRequestContext)
    {
      String wicketUrl = ((PortletRequestContext)rc).getLastEncodedPath(redirectLocation);
      if (wicketUrl != null)
      {
        redirectLocation = wicketUrl;
      }
      else
      {
        String contextPath = ((PortletRequestContext)rc).getPortletRequest()
            .getContextPath();
        if (redirectLocation.startsWith(contextPath + "/"))
        {
          redirectLocation = redirectLocation.substring(contextPath.length());
          if (redirectLocation.length() == 0)
          {
            redirectLocation = "/";
          }
        }
      }
    }
    super.sendRedirect(redirectLocation);
  }
}
origin: org.ops4j.pax.wicket/pax-wicket-service

/**
 * Construct.
 */
public RequestContext()
{
  set(this);
}
origin: org.ops4j.pax.wicket/pax-wicket-service

RequestContext requestContext = RequestContext.get();
boolean portletRequest = requestContext.isPortletRequest();
boolean sharedResourceURL = false;
    url = requestContext.encodeRenderURL(url == null ? encode(requestCycle,
      (IBookmarkablePageRequestTarget)requestTarget) : url);
  url = requestContext.encodeSharedResourceURL(url == null ? encode(requestCycle,
    (ISharedResourceRequestTarget)requestTarget) : url);
  sharedResourceURL = true;
      IBehaviorListener.class.isAssignableFrom(rli.getMethod().getDeclaringClass()))
      url = requestContext.encodeResourceURL(url);
        url = requestContext.encodeRenderURL(url);
origin: org.ops4j.pax.wicket/pax-wicket-service

realResponse.write("<span id=\"" + RequestContext.get().getNamespace() +
  "_embedded_head\" style=\"display:none\">");
realResponse.write(output);
origin: org.apache.wicket/com.springsource.org.apache.wicket

markupIdPostfix = RequestContext.get().encodeMarkupId(markupIdPostfix);
origin: org.ops4j.pax.wicket/pax-wicket-service

RequestContext rc = RequestContext.get();
if (rc instanceof PortletRequestContext)
origin: org.apache.wicket/com.springsource.org.apache.wicket

/**
 * Construct.
 */
public RequestContext()
{
  set(this);
}
origin: org.apache.wicket/com.springsource.org.apache.wicket

protected String getContextRelativeValue(String value)
{
  if ("href".equals(attribute) || "src".equals(attribute))
  {
    RequestContext rc = RequestContext.get();
    if (rc.isPortletRequest() &&
        !(value.startsWith("http://") || value.startsWith("https://")))
    {
      if ("href".equals(attribute))
      {
        value = ((PortletRequestContext)rc).encodeRenderURL(value).toString();
      }
      else
      {
        value = ((PortletRequestContext)rc).encodeSharedResourceURL(value).toString();
      }
    }
  }
  return value;
}
origin: org.wicketstuff/minis

RequestContext requestContext = RequestContext.get();
boolean portletRequest = requestContext.isPortletRequest();
boolean sharedResourceURL = false;
    url = requestContext.encodeRenderURL(url == null ? encode(requestCycle,
      (IBookmarkablePageRequestTarget)requestTarget) : url);
  url = requestContext.encodeSharedResourceURL(url == null ? encode(requestCycle,
    (ISharedResourceRequestTarget)requestTarget) : url);
  sharedResourceURL = true;
      IBehaviorListener.class.isAssignableFrom(rli.getMethod().getDeclaringClass()))
      url = requestContext.encodeResourceURL(url);
        url = requestContext.encodeRenderURL(url);
origin: org.ops4j.pax.wicket/pax-wicket-service

/**
 * Factory method for creating header response
 * 
 * @return new header response
 */
protected IHeaderResponse newHeaderResponse()
{
  IHeaderResponse headerResponse = RequestContext.get().getHeaderResponse();
  if (headerResponse == null)
  {
    // no (portlet) headerResponse override, create a default one
    headerResponse = new HeaderResponse()
    {
      @Override
      protected Response getRealResponse()
      {
        return HtmlHeaderContainer.this.getResponse();
      }
    };
  }
  return headerResponse;
}
origin: org.ops4j.pax.wicket/pax-wicket-service

/**
 * @return The current threads request context, will make one if there wasn't one.
 */
public static final RequestContext get()
{
  RequestContext context = current.get();
  if (context == null)
  {
    context = new RequestContext();
  }
  return context;
}
origin: org.ops4j.pax.wicket/pax-wicket-service

/**
 * Checks if <code>value</code> represents a path and if it does transforms it into a relative
 * path
 * 
 * @param value
 * @return value as a relative path or untouched if not a path
 */
protected String getContextRelativeValue(String value)
{
  if ("href".equals(attribute) || "src".equals(attribute))
  {
    RequestContext rc = RequestContext.get();
    if (rc.isPortletRequest() &&
      !(value.startsWith("http://") || value.startsWith("https://")))
    {
      if ("href".equals(attribute))
      {
        value = ((PortletRequestContext)rc).encodeRenderURL(value).toString();
      }
      else
      {
        value = ((PortletRequestContext)rc).encodeSharedResourceURL(value).toString();
      }
    }
  }
  return value;
}
origin: org.ops4j.pax.wicket/pax-wicket-service

protected void createRequestContext(WebRequest request, WebResponse response)
{
  if (filterPortletContext == null ||
    !filterPortletContext.createPortletRequestContext(request, response))
  {
    new RequestContext();
  }
}
origin: org.ops4j.pax.wicket/pax-wicket-service

public AppendingStringBuffer filter(AppendingStringBuffer responseBuffer)
{
  RequestContext rc = RequestContext.get();
  if (rc.isPortletRequest() && ((PortletRequestContext)rc).isEmbedded())
  {
    deleteFragment(responseBuffer, "<?xml", "?>");
    deleteFragment(responseBuffer, "<!DOCTYPE", ">");
    deleteOpenTag(responseBuffer, "html");
    deleteOpenTag(responseBuffer, "head");
    deleteOpenTag(responseBuffer, "body");
  }
  return responseBuffer;
}
org.apache.wicketRequestContext

Javadoc

Handles url rewriting, provides access to the namespace for markup Ids and isolated session state.

This is the base strategy for encoding URLs, which is to leave them as is. This is mainly so that PortletRequestContext can implement it's portlet encoding strategies as portlets need to have special URLs encoded with portal information and portlet namespace.

For url rewriting, only three methods are needed to support creating Portlet ActionURLs, Portlet RenderURLs and Resource/Ajax URLs.

The RequestContext is somewhat comparable to the JSF ExternalContext interface which abstracts the external environment (like web or portlet) in which the application is currently running. As this is request dependent (the same application can technically be accessed even concurrently as web or portlet), in Wicket this context has been termed RequestContext.

Most used methods

  • get
  • isPortletRequest
  • encodeRenderURL
    Encodes URL's for render URLs, typically overridden by the portlet implementation.
  • encodeResourceURL
    Encodes URL's for resource targets, typically overridden by the portlet implementation.
  • encodeSharedResourceURL
    Encodes URL's for shared resource targets, typically overridden by the portlet implementation.
  • <init>
    Construct.
  • encodeMarkupId
    Encodes markup Ids, typically overridden by the portlet implementation.
  • getHeaderResponse
    Used to override response objects, typically used by the portlet implementation. In a Portlet envir
  • getNamespace
  • set
    Sets the RequestContext for the current threads active request.
  • unset
    Resets the RequestContext for the current threads active request.
  • unset

Popular in Java

  • Creating JSON documents from java classes using gson
  • getSystemService (Context)
  • startActivity (Activity)
  • orElseThrow (Optional)
    Return the contained value, if present, otherwise throw an exception to be created by the provided s
  • PrintStream (java.io)
    Fake signature of an existing Java class.
  • Proxy (java.net)
    This class represents proxy server settings. A created instance of Proxy stores a type and an addres
  • Connection (java.sql)
    A connection represents a link from a Java application to a database. All SQL statements and results
  • Handler (java.util.logging)
    A Handler object accepts a logging request and exports the desired messages to a target, for example
  • Pattern (java.util.regex)
    Patterns are compiled regular expressions. In many cases, convenience methods such as String#matches
  • IsNull (org.hamcrest.core)
    Is the value null?
  • Github Copilot alternatives
Tabnine Logo
  • Products

    Search for Java codeSearch for JavaScript code
  • IDE Plugins

    IntelliJ IDEAWebStormVisual StudioAndroid StudioEclipseVisual Studio CodePyCharmSublime TextPhpStormVimGoLandRubyMineEmacsJupyter NotebookJupyter LabRiderDataGripAppCode
  • Company

    About UsContact UsCareers
  • Resources

    FAQBlogTabnine AcademyTerms of usePrivacy policyJava Code IndexJavascript Code Index
Get Tabnine for your IDE now