当前位置: 首页>>代码示例>>Java>>正文


Java IWebContext类代码示例

本文整理汇总了Java中org.thymeleaf.context.IWebContext的典型用法代码示例。如果您正苦于以下问题:Java IWebContext类的具体用法?Java IWebContext怎么用?Java IWebContext使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。


IWebContext类属于org.thymeleaf.context包,在下文中一共展示了IWebContext类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: getBundleUrl

import org.thymeleaf.context.IWebContext; //导入依赖的package包/类
/**
 * Adds the context path to the bundleUrl.    We don't use the Thymeleaf "@" syntax or any other mechanism to 
 * encode this URL as the resolvers could have a conflict.   
 * 
 * For example, resolving a bundle named "style.css" that has a file also named "style.css" creates problems as
 * the TF or version resolvers both want to version this file.
 *  
 * @param arguments
 * @param bundleName
 * @return
 */
protected String getBundleUrl(Arguments arguments, String bundleName) {
    String bundleUrl = bundleName;

    if (!StringUtils.startsWith(bundleUrl, "/")) {
        bundleUrl = "/" + bundleUrl;
    }

    IWebContext context = (IWebContext) arguments.getContext();
    HttpServletRequest request = context.getHttpServletRequest();
    String contextPath = request.getContextPath();

    if (StringUtils.isNotEmpty(contextPath)) {
        bundleUrl = contextPath + bundleUrl;
    }

    return bundleUrl;
}
 
开发者ID:takbani,项目名称:blcdemo,代码行数:29,代码来源:ResourceBundleProcessor.java

示例2: adaptHeader

import org.thymeleaf.context.IWebContext; //导入依赖的package包/类
@Override
protected void adaptHeader(HtmlTable table) {

   Node tableNode = (Node) ((IWebContext) arguments.getContext()).getHttpServletRequest().getAttribute(
         DataTablesDialect.INTERNAL_NODE_TABLE);
   Element thead = DomUtils.findElement((Element) tableNode, "thead");

   Element tr = new Element("tr");
   for (HtmlColumn column : table.getLastHeaderRow().getColumns()) {
      Element th = new Element("th");
      th.addChild(new Text(column.getContent().toString()));
      tr.addChild(th);
   }

   if (thead != null) {
      thead.addChild(tr);
   }
   else {
      thead = new Element("thead");
      thead.addChild(tr);
      ((Element) tableNode).addChild(thead);
   }

}
 
开发者ID:dandelion,项目名称:dandelion-datatables,代码行数:25,代码来源:FilteringFeature.java

示例3: adaptFooter

import org.thymeleaf.context.IWebContext; //导入依赖的package包/类
@Override
protected void adaptFooter(HtmlTable table) {

   Element tfoot = new Element("tfoot");

   Node tableNode = (Node) ((IWebContext) arguments.getContext()).getHttpServletRequest().getAttribute(
         DataTablesDialect.INTERNAL_NODE_TABLE);

   for (HtmlColumn column : table.getLastHeaderRow().getColumns()) {
      Element th = new Element("th");
      th.addChild(new Text(column.getContent().toString()));
      tfoot.addChild(th);
   }

   ((Element) tableNode).addChild(tfoot);
}
 
开发者ID:dandelion,项目名称:dandelion-datatables,代码行数:17,代码来源:FilteringFeature.java

示例4: processAttribute

import org.thymeleaf.context.IWebContext; //导入依赖的package包/类
@Override
@SuppressWarnings("unchecked")
protected ProcessorResult processAttribute(Arguments arguments, Element element, String attributeName) {

   HttpServletRequest request = ((IWebContext) arguments.getContext()).getHttpServletRequest();

   Map<Option<?>, Object> stagingOptions = (Map<Option<?>, Object>) request
         .getAttribute(DataTablesDialect.INTERNAL_BEAN_TABLE_STAGING_OPTIONS);

   // Make the actual attribute processing
   doProcessAttribute(arguments, element, attributeName, stagingOptions);

   // Housekeeping
   element.removeAttribute(attributeName);

   return ProcessorResult.ok();
}
 
开发者ID:dandelion,项目名称:dandelion-datatables,代码行数:18,代码来源:AbstractTableAttrProcessor.java

示例5: setupExport

import org.thymeleaf.context.IWebContext; //导入依赖的package包/类
/**
 * 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();
}
 
开发者ID:dandelion,项目名称:dandelion-datatables,代码行数:25,代码来源:TableFinalizerElProcessor.java

示例6: processView

import org.thymeleaf.context.IWebContext; //导入依赖的package包/类
@Override public void processView(final ViewEngineContext context) throws ViewEngineException {
    try {
        final IWebContext ctx = ctxFactory.create(context);
        engine.process(context.getView(), ctx, context.getResponse().getWriter());
    } catch (IOException e) {
        throw new ViewEngineException(e);
    }
}
 
开发者ID:inbuss,项目名称:thymeleaf-mvc,代码行数:9,代码来源:ViewEngine.java

示例7: createHtmlContentFromTemplate

import org.thymeleaf.context.IWebContext; //导入依赖的package包/类
private String createHtmlContentFromTemplate(final User user, final Locale locale, final HttpServletRequest request,
                                             final HttpServletResponse response) {
    Map<String, Object> variables = new HashMap<>();
    variables.put("user", user);
    variables.put("baseUrl", request.getScheme() + "://" +   // "http" + "://
                             request.getServerName() +       // "myhost"
                             ":" + request.getServerPort());
    IWebContext context = new SpringWebContext(request, response, servletContext,
            locale, variables, applicationContext);
    return templateEngine.process("activationEmail", context);
}
 
开发者ID:sanketbajoria,项目名称:jittrackGTS,代码行数:12,代码来源:AccountResource.java

示例8: createHtmlContentFromTemplate

import org.thymeleaf.context.IWebContext; //导入依赖的package包/类
private String createHtmlContentFromTemplate(final User user, final Locale locale, final HttpServletRequest request,
                                             final HttpServletResponse response) {
    Map<String, Object> variables = new HashMap<String, Object>();
    variables.put("user", user);
    variables.put("baseUrl", request.getScheme() + "://" +   // "http" + "://
                             request.getServerName() +       // "myhost"
                             ":" + request.getServerPort());
    IWebContext context = new SpringWebContext(request, response, servletContext,
            locale, variables, applicationContext);
    return templateEngine.process(MailService.EMAIL_ACTIVATION_PREFIX + MailService.TEMPLATE_SUFFIX, context);
}
 
开发者ID:thpham,项目名称:ithings-demo,代码行数:12,代码来源:AccountResource.java

示例9: createHtmlContentFromTemplate

import org.thymeleaf.context.IWebContext; //导入依赖的package包/类
private String createHtmlContentFromTemplate(final User user, final Locale locale, final HttpServletRequest request,
                                             final HttpServletResponse response) {
    Map<String, Object> variables = new HashMap<String, Object>();
    variables.put("user", user);
    variables.put("baseUrl", request.getScheme() + "://" +   // "http" + "://
                             request.getServerName() +       // "myhost"
                             ":" + request.getServerPort());
    IWebContext context = new SpringWebContext(request, response, servletContext,
            locale, variables, applicationContext);
    return templateEngine.process("activationEmail", context);
}
 
开发者ID:la-team,项目名称:lightadmin-jhipster,代码行数:12,代码来源:AccountResource.java

示例10: buildObject

import org.thymeleaf.context.IWebContext; //导入依赖的package包/类
@Override
public Object buildObject(IExpressionContext context, String expressionObjectName) {
	if (JawrDialect.PREFIX.equals(expressionObjectName)) {
		if (context instanceof IWebContext) {
			return new Jawr((IWebContext) context);
		}
	}

	return null;
}
 
开发者ID:dtrunk90,项目名称:thymeleaf-jawr-extension,代码行数:11,代码来源:JawrExpressionObjectFactory.java

示例11: processElement

import org.thymeleaf.context.IWebContext; //导入依赖的package包/类
@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;
}
 
开发者ID:dandelion,项目名称:dandelion-datatables,代码行数:11,代码来源:AbstractElProcessor.java

示例12: processAttribute

import org.thymeleaf.context.IWebContext; //导入依赖的package包/类
/**
 * {@inheritDoc}
 */
@Override
@SuppressWarnings("unchecked")
protected ProcessorResult processAttribute(Arguments arguments, Element element, String attributeName) {

   HttpServletRequest request = ((IWebContext) arguments.getContext()).getHttpServletRequest();

   // A Map<ConfType, Object> is associated with each table id
   Map<String, Map<ConfType, Object>> configs = (Map<String, Map<ConfType, Object>>) RequestUtils.getFromRequest(
         DataTablesDialect.INTERNAL_BEAN_CONFIGS, request);

   String tableId = AttributeUtils.parseStringAttribute(arguments, element, attributeName);

   if (configs != null && configs.containsKey(tableId)) {
      throw new DandelionException("A div with id '" + tableId + "' is already present in the current template.");
   }
   else {
      configs = new HashMap<String, Map<ConfType, Object>>();
   }

   configs.put(tableId, new HashMap<ConfType, Object>());
   RequestUtils.storeInRequest(DataTablesDialect.INTERNAL_BEAN_CONFIGS, configs, request);

   // The node is stored to be easily accessed later during the processing
   RequestUtils.storeInRequest(DataTablesDialect.INTERNAL_NODE_CONFIG, element, request);

   return ProcessorResult.ok();
}
 
开发者ID:dandelion,项目名称:dandelion-datatables,代码行数:31,代码来源:DivConfAttrProcessor.java

示例13: findPage

import org.thymeleaf.context.IWebContext; //导入依赖的package包/类
public static Page<?> findPage(final ITemplateContext context) {
    // 1. Get Page object from local variables (defined with sd:page-object)
    // 2. Search Page using ${page} expression
    // 3. Search Page object as request attribute

    final Object pageFromLocalVariable = context.getVariable(Keys.PAGE_VARIABLE_KEY);
    if (isPageInstance(pageFromLocalVariable)) {
        return (Page<?>) pageFromLocalVariable;
    }

    // Check if not null and Page instance available with ${page} expression
    final IEngineConfiguration configuration = context.getConfiguration();
    final IStandardExpressionParser parser = StandardExpressions.getExpressionParser(configuration);
    final IStandardExpression expression = parser.parseExpression(context, Keys.PAGE_EXPRESSION);
    final Object page = expression.execute(context);
    if (isPageInstance(page)) {
        return (Page<?>) page;
    }

    // Search for Page object, and only one instance, as request attribute
    if (context instanceof IWebContext) {
        HttpServletRequest request = ((IWebContext) context).getRequest();
        Enumeration<String> attrNames = request.getAttributeNames();
        Page<?> pageOnRequest = null;
        while (attrNames.hasMoreElements()) {
            String attrName = (String) attrNames.nextElement();
            Object attr = request.getAttribute(attrName);
            if (isPageInstance(attr)) {
                if (pageOnRequest != null) {
                    throw new InvalidObjectParameterException("More than one Page object found on request!");
                }

                pageOnRequest = (Page<?>) attr;
            }
        }

        if (pageOnRequest != null) {
            return pageOnRequest;
        }
    }

    throw new InvalidObjectParameterException("Invalid or not present Page object found on request!");
}
 
开发者ID:jpenren,项目名称:thymeleaf-spring-data-dialect,代码行数:44,代码来源:PageUtils.java

示例14: buildBaseUrl

import org.thymeleaf.context.IWebContext; //导入依赖的package包/类
private static String buildBaseUrl(final ITemplateContext context, Collection<String> excludeParams) {
    // URL defined with pagination-url tag
    final String url = (String) context.getVariable(Keys.PAGINATION_URL_KEY);

    if (url == null && context instanceof IWebContext) {
        // Creates url from actual request URI and parameters
        final StringBuilder builder = new StringBuilder();
        final IWebContext webContext = (IWebContext) context;
        final HttpServletRequest request = webContext.getRequest();

        // URL base path from request
        builder.append(request.getRequestURI());

        Map<String, String[]> params = request.getParameterMap();
        Set<Entry<String, String[]>> entries = params.entrySet();
        boolean firstParam = true;
        for (Entry<String, String[]> param : entries) {
            // Append params not excluded to basePath
            String name = param.getKey();
            if (!excludeParams.contains(name)) {
                if (firstParam) {
                    builder.append(Q_MARK);
                    firstParam = false;
                } else {
                    builder.append(AND);
                }

                // Iterate over all values to create multiple values per
                // parameter
                String[] values = param.getValue();
                Collection<String> paramValues = Arrays.asList(values);
                Iterator<String> it = paramValues.iterator();
                while (it.hasNext()) {
                    String value = it.next();
                    builder.append(name).append(EQ).append(value);
                    if (it.hasNext()) {
                        builder.append(AND);
                    }
                }
            }
        }

        // Escape to HTML content
        return HtmlEscape.escapeHtml4Xml(builder.toString());
    }

    return url == null ? EMPTY : url;
}
 
开发者ID:jpenren,项目名称:thymeleaf-spring-data-dialect,代码行数:49,代码来源:PageUtils.java

示例15: execute

import org.thymeleaf.context.IWebContext; //导入依赖的package包/类
public void execute() {
    IWebContext context = (IWebContext) arguments.getContext();
    context.getRequestAttributes().put(CONNECTION_ATTR_NAME, createJdbcTemplate());
}
 
开发者ID:jmiguelsamper,项目名称:thymeleaf-extras-sqldialect,代码行数:5,代码来源:ConnectionCommand.java


注:本文中的org.thymeleaf.context.IWebContext类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。