本文整理汇总了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));
}
}
示例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);
}
示例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;
}
示例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);
}
示例5: getModelFactory
import org.thymeleaf.model.IModelFactory; //导入依赖的package包/类
private IModelFactory getModelFactory(ITemplateContext context) {
return new StandardModelFactory(context.getConfiguration(), templateMode);
}
示例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);
}