Tabnine Logo
IWebContext
Code IndexAdd Tabnine to your IDE (free)

How to use
IWebContext
in
org.thymeleaf.context

Best Java code snippets using org.thymeleaf.context.IWebContext (Showing top 20 results out of 315)

origin: thymeleaf/thymeleaf

final HttpServletRequest request = ((IWebContext)context).getRequest();
return request.getContextPath();
origin: thymeleaf/thymeleaf

  return new WebEngineContext(
      configuration, templateData, templateResolutionAttributes,
      webContext.getRequest(), webContext.getResponse(), webContext.getServletContext(),
      webContext.getLocale(), Collections.EMPTY_MAP);
return new WebEngineContext(
    configuration, templateData, templateResolutionAttributes,
    webContext.getRequest(), webContext.getResponse(), webContext.getServletContext(),
    webContext.getLocale(), variables);
origin: thymeleaf/thymeleaf

return ((IWebContext) context).getRequest();
return ((IWebContext) context).getResponse();
return ((IWebContext) context).getSession();
return ((IWebContext) context).getServletContext();
return ((IWebContext) context).getRequest();
return ((IWebContext) context).getSession();
origin: thymeleaf/thymeleaf-extras-springsecurity

@Override
protected boolean isVisible(
    final ITemplateContext context, final IProcessableElementTag tag,
    final AttributeName attributeName, final String attributeValue) {
  final String attrValue = (attributeValue == null? null : attributeValue.trim());
  if (attrValue == null || attrValue.length() == 0) {
    return false;
  }
  if (!(context instanceof IWebContext)) {
    throw new ConfigurationException(
        "Thymeleaf execution context is not a web context (implementation of " +
        IWebContext.class.getName() + "). Spring Security integration can only be used in " +
        "web environments.");
  }
  final IWebContext webContext = (IWebContext) context;
  final HttpServletRequest request = webContext.getRequest();
  final HttpServletResponse response = webContext.getResponse();
  final ServletContext servletContext = webContext.getServletContext();
  final Authentication authentication = AuthUtils.getAuthenticationObject();
  if (authentication == null) {
    return false;
  }
  return AuthUtils.authorizeUsingAccessExpression(
      context, attrValue, authentication, request, response, servletContext);
}

origin: org.thymeleaf.extras/thymeleaf-extras-tiles2

final HttpServletRequest request = webContext.getHttpServletRequest();
final HttpServletResponse response = webContext.getHttpServletResponse();
final ServletContext servletContext = webContext.getServletContext();
origin: thymeleaf/thymeleaf-extras-springsecurity

final HttpServletRequest request = webContext.getRequest();
final ServletContext servletContext = webContext.getServletContext();
origin: com.github.datatables4j/datatables4j-core-thymeleaf

public static HtmlTable getTable(Arguments arguments) {
  return (HtmlTable) ((IWebContext) arguments.getContext()).getHttpServletRequest()
      .getAttribute("htmlTable");
}
origin: dandelion/dandelion-datatables

@Override
protected ProcessorResult processElement(Arguments arguments, Element element) {
 HttpServletRequest request = ((IWebContext) arguments.getContext()).getHttpServletRequest();
 HttpServletResponse response = ((IWebContext) arguments.getContext()).getHttpServletResponse();
 HtmlTable htmlTable = (HtmlTable) RequestUtils.getFromRequest(DataTablesDialect.INTERNAL_BEAN_TABLE, request);
 ProcessorResult processorResult = doProcessElement(arguments, element, request, response, htmlTable);
 return processorResult;
}
origin: thymeleaf/thymeleaf-extras-springsecurity

static ApplicationContext findRequiredWebApplicationContext(final IContext context) {
  final javax.servlet.ServletContext servletContext = ((IWebContext)context).getServletContext();
  WebApplicationContext wac = WebApplicationContextUtils.getWebApplicationContext(servletContext);
  if (wac == null) {
    final Enumeration<String> attrNames = servletContext.getAttributeNames();
    while (attrNames.hasMoreElements()) {
      final String attrName = attrNames.nextElement();
      final Object attrValue = servletContext.getAttribute(attrName);
      if (attrValue instanceof WebApplicationContext) {
        if (wac != null) {
          throw new IllegalStateException("No unique WebApplicationContext found: more than one " +
              "DispatcherServlet registered with publishContext=true?");
        }
        wac = (WebApplicationContext) attrValue;
      }
    }
  }
  if (wac == null) {
    throw new IllegalStateException("No WebApplicationContext found: no ContextLoaderListener registered?");
  }
  return wac;
}
origin: org.everit.osgi.bundles/org.everit.osgi.bundles.org.thymeleaf.thymeleaf

    HTTP_SERVLET_REQUEST_VARIABLE_NAME, webContext.getHttpServletRequest());
variables.put(
    HTTP_SESSION_VARIABLE_NAME, webContext.getHttpSession());
origin: thymeleaf/thymeleaf

/**
 * <p>
 *   Process an already-built URL just before returning it.
 * </p>
 * <p>
 *   By default, this method will apply the {@code HttpServletResponse.encodeURL(url)} mechanism, as standard
 *   when using the Java Servlet API. Note however that this will only be applied if {@code context} is
 *   an implementation of {@code IWebContext} (i.e. the Servlet API will only be applied in web environments).
 * </p>
 * <p>
 *   This method can be overridden by any subclasses that want to change this behaviour (e.g. in order to
 *   avoid using the Servlet API).
 * </p>
 *
 * @param context the execution context.
 * @param link the already-built URL.
 * @return the processed URL, ready to be used.
 */
protected String processLink(final IExpressionContext context, final String link) {
  if (!(context instanceof IWebContext)) {
    return link;
  }
  final HttpServletResponse response = ((IWebContext)context).getResponse();
  return (response != null? response.encodeURL(link) : link);
}
origin: org.thymeleaf.extras/thymeleaf-extras-springsecurity4

@Override
protected boolean isVisible(
    final ITemplateContext context, final IProcessableElementTag tag,
    final AttributeName attributeName, final String attributeValue) {
  final String attrValue = (attributeValue == null? null : attributeValue.trim());
  if (attrValue == null || attrValue.length() == 0) {
    return false;
  }
  if (!(context instanceof IWebContext)) {
    throw new ConfigurationException(
        "Thymeleaf execution context is not a web context (implementation of " +
        IWebContext.class.getName() + "). Spring Security integration can only be used in " +
        "web environments.");
  }
  final IWebContext webContext = (IWebContext) context;
  final HttpServletRequest request = webContext.getRequest();
  final HttpServletResponse response = webContext.getResponse();
  final ServletContext servletContext = webContext.getServletContext();
  final Authentication authentication = AuthUtils.getAuthenticationObject();
  if (authentication == null) {
    return false;
  }
  return AuthUtils.authorizeUsingAccessExpression(
      context, attrValue, authentication, request, response, servletContext);
}

origin: thymeleaf/thymeleaf-extras-tiles2

final HttpServletRequest request = webContext.getHttpServletRequest();
final HttpServletResponse response = webContext.getHttpServletResponse();
final ServletContext servletContext = webContext.getServletContext();
origin: thymeleaf/thymeleaf-extras-springsecurity

@Override
protected boolean isVisible(
    final ITemplateContext context, final IProcessableElementTag tag,
    final AttributeName attributeName, final String attributeValue) {
  final String attrValue = (attributeValue == null? null : attributeValue.trim());
  if (attrValue == null || attrValue.length() == 0) {
    return false;
  }
  final int spaceIndex = attrValue.indexOf(' ');
  final String url =
      (spaceIndex < 0? attrValue : attrValue.substring(spaceIndex + 1)).trim();
  final String method =
      (spaceIndex < 0? "GET" : attrValue.substring(0, spaceIndex)).trim();
  if (!(context instanceof IWebContext)) {
    throw new ConfigurationException(
        "Thymeleaf execution context is not a web context (implementation of " +
            IWebContext.class.getName() + "). Spring Security integration can only be used in " +
            "web environments.");
  }
  final IWebContext webContext = (IWebContext) context;
  final HttpServletRequest request = webContext.getRequest();
  final ServletContext servletContext = webContext.getServletContext();
  final Authentication authentication = AuthUtils.getAuthenticationObject();
  if (authentication == null) {
    return false;
  }
  return AuthUtils.authorizeUsingUrlCheck(
      url, method, authentication, request, servletContext);
}
origin: com.github.datatables4j/datatables4j-core-thymeleaf

public static HtmlTable getTable(Arguments arguments){
  return (HtmlTable)((IWebContext) arguments.getContext()).getHttpServletRequest().getAttribute("htmlTable");
}
 
origin: dandelion/dandelion-datatables

/**
* Sets up the export properties, before the filter intercepts the response.
* 
* @param arguments
*           The Thymeleaf arguments.
* @param htmlTable
*           The {@link HtmlTable} to export.
*/
private void setupExport(Arguments arguments, HtmlTable htmlTable) {
 HttpServletRequest request = ((IWebContext) arguments.getContext()).getHttpServletRequest();
 HttpServletResponse response = ((IWebContext) arguments.getContext()).getHttpServletResponse();
 String currentExportType = ExportUtils.getCurrentExportType(request);
 htmlTable.getTableConfiguration().setExporting(true);
 htmlTable.getTableConfiguration().setCurrentExportFormat(currentExportType);
 // Call the export delegate
 ExportDelegate exportDelegate = new ExportDelegate(htmlTable, request);
 exportDelegate.prepareExport();
 response.reset();
}
origin: org.thymeleaf.extras/thymeleaf-extras-springsecurity5

static ApplicationContext findRequiredWebApplicationContext(final IContext context) {
  final javax.servlet.ServletContext servletContext = ((IWebContext)context).getServletContext();
  WebApplicationContext wac = WebApplicationContextUtils.getWebApplicationContext(servletContext);
  if (wac == null) {
    final Enumeration<String> attrNames = servletContext.getAttributeNames();
    while (attrNames.hasMoreElements()) {
      final String attrName = attrNames.nextElement();
      final Object attrValue = servletContext.getAttribute(attrName);
      if (attrValue instanceof WebApplicationContext) {
        if (wac != null) {
          throw new IllegalStateException("No unique WebApplicationContext found: more than one " +
              "DispatcherServlet registered with publishContext=true?");
        }
        wac = (WebApplicationContext) attrValue;
      }
    }
  }
  if (wac == null) {
    throw new IllegalStateException("No WebApplicationContext found: no ContextLoaderListener registered?");
  }
  return wac;
}
origin: thymeleaf/thymeleaf-extras-springsecurity

@Override
public HttpServletResponse getHttpServletResponse(final IContext context) {
  if (context instanceof IWebContext) {
    return ((IWebContext)context).getResponse();
  }
  throw new TemplateProcessingException(
      "Cannot obtain HttpServletResponse from a non-WebFlux context implementation (\"" +
      context.getClass().getName() + "\")");
}
origin: org.thymeleaf.extras/thymeleaf-extras-springsecurity3

@Override
protected boolean isVisible(
    final ITemplateContext context, final IProcessableElementTag tag,
    final AttributeName attributeName, final String attributeValue) {
  final String attrValue = (attributeValue == null? null : attributeValue.trim());
  if (attrValue == null || attrValue.length() == 0) {
    return false;
  }
  if (!(context instanceof IWebContext)) {
    throw new ConfigurationException(
        "Thymeleaf execution context is not a web context (implementation of " +
        IWebContext.class.getName() + "). Spring Security integration can only be used in " +
        "web environments.");
  }
  final IWebContext webContext = (IWebContext) context;
  
  final HttpServletRequest request = webContext.getRequest();
  final HttpServletResponse response = webContext.getResponse();
  final ServletContext servletContext = webContext.getServletContext();
  
  final Authentication authentication = AuthUtils.getAuthenticationObject();
  if (authentication == null) {
    return false;
  }
  
  return AuthUtils.authorizeUsingAccessExpression(
      context, attrValue, authentication, request, response, servletContext);
  
}

origin: org.thymeleaf.extras/thymeleaf-extras-springsecurity5

static String getContextPath(final IContext context) {
  final javax.servlet.http.HttpServletRequest request = ((IWebContext)context).getRequest();
  return request.getContextPath();
}
org.thymeleaf.contextIWebContext

Javadoc

Specialization of the IContext interface to be implemented by contexts used for template processing in web environments.

Objects implementing this interface add to the usual IContext data the Servlet-API-related artifacts needed to perform web-oriented functions such as URL rewriting or request/session access.

Note a class with this name existed since 1.0, but it was completely reimplemented in Thymeleaf 3.0

Most used methods

  • getRequest
  • getHttpServletRequest
    Returns the HttpServletRequest object associated with the request this context has been created for
  • getServletContext
    Returns the ServletContext object associated with the web application.
  • getHttpServletResponse
    Returns the HttpServletResponse object associated with the request this context has been created fo
  • getResponse
  • getHttpSession
    Returns the HttpSession object associated with the request this context has been created for.
  • getLocale
  • getSession
    Returns the HttpSession object associated with the template execution, or null if there is no sessi

Popular in Java

  • Making http requests using okhttp
  • getContentResolver (Context)
  • notifyDataSetChanged (ArrayAdapter)
  • requestLocationUpdates (LocationManager)
  • FlowLayout (java.awt)
    A flow layout arranges components in a left-to-right flow, much like lines of text in a paragraph. F
  • SocketTimeoutException (java.net)
    This exception is thrown when a timeout expired on a socket read or accept operation.
  • URLConnection (java.net)
    A connection to a URL for reading or writing. For HTTP connections, see HttpURLConnection for docume
  • TimerTask (java.util)
    The TimerTask class represents a task to run at a specified time. The task may be run once or repeat
  • TreeMap (java.util)
    Walk the nodes of the tree left-to-right or right-to-left. Note that in descending iterations, next
  • LoggerFactory (org.slf4j)
    The LoggerFactory is a utility class producing Loggers for various logging APIs, most notably for lo
  • Top 12 Jupyter Notebook extensions
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