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


Java IModelFactory类代码示例

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


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

示例1: renderMessages

import org.thymeleaf.model.IModelFactory; //导入依赖的package包/类
private void renderMessages(Collection<Message> messages, IModelFactory modelFactory, IModel model) {
    final boolean severalMessages = messages.size() > 1;
    final String tagName = severalMessages ? HTML_MULTI_MESSAGE_ELEMENT : HTML_SINGLE_MESSAGE;
    if (severalMessages) {
        model.add(modelFactory.createOpenElementTag(HTML_MULTI_MESSAGE_CONTAINER));
    }

    for (Message message : messages) {
        model.add(modelFactory.createOpenElementTag(tagName, "data-timestamp", message.getTimestamp().toString()));
        model.add(modelFactory.createText(message.getText()));
        model.add(modelFactory.createCloseElementTag(tagName));
    }

    if (severalMessages) {
        model.add(modelFactory.createCloseElementTag(HTML_MULTI_MESSAGE_CONTAINER));
    }
}
 
开发者ID:jeslopalo,项目名称:flash-messages,代码行数:18,代码来源:FlashMessagesElementTagProcessor.java

示例2: doProcess

import org.thymeleaf.model.IModelFactory; //导入依赖的package包/类
@Override
protected void doProcess(ITemplateContext iTemplateContext,
                         IProcessableElementTag iProcessableElementTag,
                         AttributeName attributeName,
                         String attributeValue,
                         IElementTagStructureHandler iElementTagStructureHandler) {

    final String type = iProcessableElementTag.getAttributeValue("type");
    final String property = iProcessableElementTag.getAttributeValue("property");

    final String text = ShiroFacade.getPrincipalText(type, property);
    final String elementCompleteName = iProcessableElementTag.getElementCompleteName();

    final IModelFactory modelFactory = iTemplateContext.getModelFactory();
    final IModel model = modelFactory.createModel();

    model.add(modelFactory.createOpenElementTag(elementCompleteName));
    model.add(modelFactory.createText(HtmlEscape.escapeHtml5(text)));
    model.add(modelFactory.createCloseElementTag(elementCompleteName));

    iElementTagStructureHandler.replaceWith(model, false);
}
 
开发者ID:theborakompanioni,项目名称:thymeleaf-extras-shiro,代码行数:23,代码来源:PrincipalAttrProcessor.java

示例3: levelMessages

import org.thymeleaf.model.IModelFactory; //导入依赖的package包/类
private IModel levelMessages(Level level, Collection<Message> messages, HttpServletRequest request, IModelFactory modelFactory) {
    final IModel model = modelFactory.createModel();

    model.add(modelFactory.createOpenElementTag(HTML_CONTAINER_TAG, levelMessagesContainerAttributes(level, request), AttributeValueQuotes.DOUBLE, false));
    renderMessages(messages, modelFactory, model);
    model.add(modelFactory.createCloseElementTag(HTML_CONTAINER_TAG));

    return model;
}
 
开发者ID:jeslopalo,项目名称:flash-messages,代码行数:10,代码来源:FlashMessagesElementTagProcessor.java

示例4: getAttributeValueAsEvent

import org.thymeleaf.model.IModelFactory; //导入依赖的package包/类
private IText getAttributeValueAsEvent(ITemplateContext context, String attributeValue) {
    String evaluatedAttributeValue = getEvaluatedAttributeValue(context, attributeValue);
    IModelFactory modelFactory = getModelFactory(context);
    return modelFactory.createText(evaluatedAttributeValue);
}
 
开发者ID:connect-group,项目名称:thymeleaf-extras,代码行数:6,代码来源:AbstractTextModifierProcessor.java

示例5: getModelFactory

import org.thymeleaf.model.IModelFactory; //导入依赖的package包/类
private IModelFactory getModelFactory(ITemplateContext context) {
    return new StandardModelFactory(context.getConfiguration(), templateMode);
}
 
开发者ID:connect-group,项目名称:thymeleaf-extras,代码行数:4,代码来源:AbstractTextModifierProcessor.java

示例6: doProcess

import org.thymeleaf.model.IModelFactory; //导入依赖的package包/类
/**
 * <pre>
 *  <div data-level="${level}" class="alert alert-${level}">
 *  <c:choose>
 *      <c:when test="${fn:length(messages) gt 1}">
 *          <ul>
 *          <c:forEach var="message" items="${messages}">
 *              <li data-timestamp="${message.timestamp}"><c:out value="${message.text}" escapeXml="false"/></li>
 *          </c:forEach>
 *          </ul>
 *      </c:when>
 *      <c:otherwise>
 *      <c:forEach var="message" items="${messages}">
 *          <span data-timestamp="${message.timestamp}"><c:out value="${message.text}" escapeXml="false"/></span>
 *      </c:forEach>
 *      </c:otherwise>
 *  </c:choose>
 *  </div>
 * </pre>
 *
 * @param context
 * @param tag
 * @param structureHandler
 */
@Override
protected void doProcess(ITemplateContext context, IProcessableElementTag tag, IElementTagStructureHandler structureHandler) {
    checkPreconditions(context, tag, structureHandler);

    final WebEngineContext webEngineContext = (WebEngineContext) context;
    final IModelFactory modelFactory = context.getModelFactory();
    final IModel model = modelFactory.createModel();
    final HttpServletRequest request = webEngineContext.getRequest();
    final Context flashMessagesContext = context(request);

    for (Level level : flashMessagesContext.levels()) {
        final Collection<Message> messages = flashMessagesContext.levelMessages(level, request);
        if (!messages.isEmpty()) {
            model.addModel(levelMessages(level, messages, request, modelFactory));
        }
    }

    /*
     * Instruct the engine to replace this entire element with the specified model.
     */
    structureHandler.replaceWith(model, false);
}
 
开发者ID:jeslopalo,项目名称:flash-messages,代码行数:47,代码来源:FlashMessagesElementTagProcessor.java


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