當前位置: 首頁>>代碼示例>>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;未經允許,請勿轉載。