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

How to use
IElementTagStructureHandler
in
org.thymeleaf.processor.element

Best Java code snippets using org.thymeleaf.processor.element.IElementTagStructureHandler (Showing top 20 results out of 315)

Refine searchRefine arrow

  • ITemplateContext
  • TemplateProcessingException
  • HtmlEscape
  • BindStatus
origin: thymeleaf/thymeleaf

  throw new TemplateProcessingException("Fragment specifications cannot be empty");
final IEngineConfiguration configuration = context.getConfiguration();
    structureHandler.removeElement();
  } else {
    structureHandler.removeBody();
if (context.getTemplateMode() != fragmentModel.getTemplateMode()) {
    structureHandler.replaceWith(stringWriter.toString(), false);
  } else {
    structureHandler.setBody(stringWriter.toString(), false);
structureHandler.setTemplateData(fragmentTemplateData);
    structureHandler.setLocalVariable(fragmentParameterEntry.getKey(), fragmentParameterEntry.getValue());
    structureHandler.replaceWith(model, true);
  } else {
    structureHandler.setBody(model, true);
  structureHandler.replaceWith(fragmentModel, true);
} else {
  structureHandler.setBody(fragmentModel, true);
origin: thymeleaf/thymeleaf

    EscapedAttributeUtils.unescapeAttribute(context.getTemplateMode(), attribute.getValue());
final IStandardExpressionParser expressionParser = StandardExpressions.getExpressionParser(context.getConfiguration());
  structureHandler.removeAttribute(attributeName);
  return;
  structureHandler.removeAttribute(newAttributeName);
  structureHandler.removeAttribute(attributeName);
} else {
  structureHandler.replaceAttribute(attributeName, newAttributeName, (newAttributeValue == null? "" : newAttributeValue));
if (!e.hasTemplateName()) {
  e.setTemplateName(tag.getTemplateName());
if (!e.hasLineAndCol()) {
  e.setLineAndCol(attribute.getLine(), attribute.getCol());
origin: thymeleaf/thymeleaf

        context, attributeValue, false /* no parameters without value */);
if (assignations == null) {
  throw new TemplateProcessingException(
      "Could not parse value as attribute assignations: \"" + attributeValue + "\"");
    throw new TemplateProcessingException(
        "Attribute name expression evaluated as null or empty: \"" + leftExpr + "\"");
      structureHandler.setAttribute(newAttributeName, newAttributeName);
    } else {
      structureHandler.removeAttribute(newAttributeName);
        structureHandler.removeAttribute(newAttributeName);
          tag.getAttributeValue(newAttributeName).length() == 0) {
        structureHandler.setAttribute(newAttributeName, newAttributeValue);
      } else {
        String currentValue = tag.getAttributeValue(newAttributeName);
        if (this.modificationType == ModificationType.APPEND) {
          structureHandler.setAttribute(newAttributeName, currentValue + newAttributeValue);
        } else if (this.modificationType == ModificationType.APPEND_WITH_SPACE) {
          structureHandler.setAttribute(newAttributeName, currentValue + ' ' + newAttributeValue);
        } else if (this.modificationType == ModificationType.PREPEND) {
          structureHandler.setAttribute(newAttributeName, newAttributeValue + currentValue);
        } else { // modification type is PREPEND_WITH_SPACE
          structureHandler.setAttribute(newAttributeName, newAttributeValue + ' ' + currentValue);
origin: thymeleaf/thymeleaf

@Override
protected void doProcess(
    final ITemplateContext context,
    final IProcessableElementTag tag,
    final AttributeName attributeName, final String attributeValue,
    final Object expressionResult,
    final IElementTagStructureHandler structureHandler) {
  if (expressionResult != null) {
    final String resultStr = expressionResult.toString();
    if (VALUE_ALL.equalsIgnoreCase(resultStr)) {
      structureHandler.removeElement();
    } else if (VALUE_TAG.equalsIgnoreCase(resultStr) || VALUE_TAGS.equalsIgnoreCase(resultStr)) {
      structureHandler.removeTags();
    } else if (VALUE_ALL_BUT_FIRST.equalsIgnoreCase(resultStr)) {
      structureHandler.removeAllButFirstChild();
    } else  if (VALUE_BODY.equalsIgnoreCase(resultStr)) {
      structureHandler.removeBody();
    } else if (!VALUE_NONE.equalsIgnoreCase(resultStr)) {
      throw new TemplateProcessingException(
          "Invalid value specified for \"" + attributeName + "\": only 'all', 'tag', 'body', 'none' " +
          "and 'all-but-first' are allowed, but \"" + attributeValue + "\" was specified.");
    }
  }
}
origin: thymeleaf/thymeleaf

@Override
protected final void doProcess(
    final ITemplateContext context,
    final IProcessableElementTag tag,
    final AttributeName attributeName, final String attributeValue,
    final IElementTagStructureHandler structureHandler) {
  final IStandardExpressionParser expressionParser = StandardExpressions.getExpressionParser(context.getConfiguration());
  final IStandardExpression expression =
      expressionParser.parseExpression(context, attributeValue);
  validateSelectionValue(context, tag, attributeName, attributeValue, expression);
  final Object newSelectionTarget = expression.execute(context);
  final Map<String,Object> additionalLocalVariables =
      computeAdditionalLocalVariables(context, tag, attributeName, attributeValue, expression);
  if (additionalLocalVariables != null && additionalLocalVariables.size() > 0) {
    for (final Map.Entry<String,Object> variableEntry : additionalLocalVariables.entrySet()) {
      structureHandler.setLocalVariable(variableEntry.getKey(), variableEntry.getValue());
    }
  }
  structureHandler.setSelectionTarget(newSelectionTarget);
}
origin: thymeleaf/thymeleaf-spring

           final BindStatus bindStatus, final IElementTagStructureHandler structureHandler) {
String name = bindStatus.getExpression();
name = (name == null? "" : name);
boolean checked = false;
Object boundValue = bindStatus.getValue();
final Class<?> valueType = bindStatus.getValueType();
    throw new TemplateProcessingException(
        "Attribute \"value\" is required in \"input(checkbox)\" tags " +
        "when binding to non-boolean values");
  checked = SelectedValueComparatorWrapper.isSelected(bindStatus, HtmlEscape.unescapeHtml(value));
  StandardProcessorUtils.setAttribute(structureHandler, this.checkedAttributeDefinition, CHECKED_ATTR_NAME, CHECKED_ATTR_NAME);
} else {
  structureHandler.removeAttribute(this.checkedAttributeDefinition.getAttributeName());
  final IModelFactory modelFactory = context.getModelFactory();
    structureHandler.insertBefore(hiddenTagModel);
  } else {
    structureHandler.insertImmediatelyAfter(hiddenTagModel, false);
origin: org.thymeleaf/thymeleaf-spring4

@Override
protected void doProcess(
    final ITemplateContext context, final IProcessableElementTag tag,
    final AttributeName attributeName, final String attributeValue,
    final IElementTagStructureHandler structureHandler) {
  final BindStatus bindStatus = FieldUtils.getBindStatus(context, attributeValue);
  if (bindStatus.isError()) {
    final StringBuilder strBuilder = new StringBuilder();
    final String[] errorMsgs = bindStatus.getErrorMessages();
    for (int i = 0; i < errorMsgs.length; i++) {
      if (i > 0) {
        strBuilder.append(ERROR_DELIMITER);
      }
      final String displayString = ValueFormatterWrapper.getDisplayString(errorMsgs[i], false);
      strBuilder.append(displayString);
    }
    structureHandler.setBody(strBuilder.toString(), false);
    // Just in case we also have a th:errorclass in this tag
    structureHandler.setLocalVariable(SpringContextVariableNames.SPRING_FIELD_BIND_STATUS, bindStatus);
  } else {
    structureHandler.removeElement();
  }
}
origin: thymeleaf/thymeleaf-spring

@Override
protected void doProcess(final ITemplateContext context,
             final IProcessableElementTag tag,
             final AttributeName attributeName, final String attributeValue,
             final BindStatus bindStatus, final IElementTagStructureHandler structureHandler) {
  String name = bindStatus.getExpression();
  name = (name == null? "" : name);
  final String value = tag.getAttributeValue(this.valueAttributeDefinition.getAttributeName());
  if (value == null) {
    throw new TemplateProcessingException(
        "Attribute \"value\" is required in \"option\" tags");
  }
  final boolean selected =
      SelectedValueComparatorWrapper.isSelected(bindStatus, HtmlEscape.unescapeHtml(value));
  StandardProcessorUtils.setAttribute(
      structureHandler,
      this.valueAttributeDefinition, VALUE_ATTR_NAME,
      RequestDataValueProcessorUtils.processFormFieldValue(context, name, value, "option"));
  if (selected) {
    StandardProcessorUtils.setAttribute(structureHandler, this.selectedAttributeDefinition, SELECTED_ATTR_NAME, SELECTED_ATTR_NAME);
  } else {
    structureHandler.removeAttribute(this.selectedAttributeDefinition.getAttributeName());
  }
}
origin: thymeleaf/thymeleaf-spring

@Override
protected void doProcess(
    final ITemplateContext context,
    final IProcessableElementTag tag,
    final IElementTagStructureHandler structureHandler) {
  final AttributeName selectAttrNameToAdd =
      (AttributeName) context.getVariable(SpringSelectFieldTagProcessor.OPTION_IN_SELECT_ATTR_NAME);
  if (selectAttrNameToAdd == null) {
    // Nothing to do
    return;
  }
  // It seems this <option> is inside a <select th:field="...">, and the processor for that "th:field" has left
  // as a local variable the name and value of the attribute to be added
  final String selectAttrValueToAdd =
      (String) context.getVariable(SpringSelectFieldTagProcessor.OPTION_IN_SELECT_ATTR_VALUE);
  if (tag.hasAttribute(selectAttrNameToAdd)) {
    if (!selectAttrValueToAdd.equals(tag.getAttributeValue(selectAttrNameToAdd))) {
      throw new TemplateProcessingException(
          "If specified (which is not required), attribute \"" + selectAttrNameToAdd + "\" in " +
          "\"option\" tag must have exactly the same value as in its containing \"select\" tag");
    }
  }
  // This attribute value does not need to be escaped, because we are just "transporting" the th:field in the
  // container <select> to its <option>'s, without any modifications. It will be executed (and its results
  // escaped) later...
  structureHandler.setAttribute(selectAttrNameToAdd.getCompleteAttributeNames()[0], selectAttrValueToAdd);
}
origin: thymeleaf/thymeleaf-spring

  final IElementTagStructureHandler structureHandler) {
final String newAttributeValue = HtmlEscape.escapeHtml4Xml(expressionResult == null ? null : expressionResult.toString());
  structureHandler.removeAttribute(this.targetAttributeDefinition.getAttributeName());
  structureHandler.removeAttribute(attributeName);
} else {
  StandardProcessorUtils.replaceAttribute(structureHandler, attributeName, this.targetAttributeDefinition, TARGET_ATTR_NAME, newAttributeValue);
    final IModelFactory modelFactory = context.getModelFactory();
    structureHandler.insertImmediatelyAfter(hiddenMethodModel, false);
origin: thymeleaf/thymeleaf

  EscapedAttributeUtils.unescapeAttribute(context.getTemplateMode(), tag.getAttributeValue(attributeName));
structureHandler.removeAttribute(attributeName);
if (!e.hasTemplateName()) {
  e.setTemplateName(tag.getTemplateName());
if (!e.hasLineAndCol()) {
  if (attributeName == null) {
origin: thymeleaf/thymeleaf-spring

@Override
protected void doProcess(final ITemplateContext context,
             final IProcessableElementTag tag,
             final AttributeName attributeName, final String attributeValue,
             final IThymeleafBindStatus bindStatus, final IElementTagStructureHandler structureHandler) {
  String name = bindStatus.getExpression();
  name = (name == null? "" : name);
  final String value = tag.getAttributeValue(this.valueAttributeDefinition.getAttributeName());
  if (value == null) {
    throw new TemplateProcessingException(
        "Attribute \"value\" is required in \"option\" tags");
  }
  final boolean selected =
      SpringSelectedValueComparator.isSelected(bindStatus, HtmlEscape.unescapeHtml(value));
  StandardProcessorUtils.setAttribute(
      structureHandler,
      this.valueAttributeDefinition, VALUE_ATTR_NAME,
      RequestDataValueProcessorUtils.processFormFieldValue(context, name, value, "option"));
  if (selected) {
    StandardProcessorUtils.setAttribute(structureHandler, this.selectedAttributeDefinition, SELECTED_ATTR_NAME, SELECTED_ATTR_NAME);
  } else {
    structureHandler.removeAttribute(this.selectedAttributeDefinition.getAttributeName());
  }
}
origin: thymeleaf/thymeleaf-spring

    throw new TemplateProcessingException(
        "Attribute \"value\" is required in \"input(checkbox)\" tags " +
        "when binding to non-boolean values");
  checked = SpringSelectedValueComparator.isSelected(bindStatus, HtmlEscape.unescapeHtml(value));
  StandardProcessorUtils.setAttribute(structureHandler, this.checkedAttributeDefinition, CHECKED_ATTR_NAME, CHECKED_ATTR_NAME);
} else {
  structureHandler.removeAttribute(this.checkedAttributeDefinition.getAttributeName());
  final IModelFactory modelFactory = context.getModelFactory();
    structureHandler.insertBefore(hiddenTagModel);
  } else {
    structureHandler.insertImmediatelyAfter(hiddenTagModel, false);
origin: thymeleaf/thymeleaf-spring

           final BindStatus bindStatus, final IElementTagStructureHandler structureHandler) {
String name = bindStatus.getExpression();
name = (name == null? "" : name);
StandardProcessorUtils.setAttribute(structureHandler, this.nameAttributeDefinition, NAME_ATTR_NAME, name); // No need to escape: this is a java-valid token
structureHandler.setLocalVariable(OPTION_IN_SELECT_ATTR_NAME, attributeName);
structureHandler.setLocalVariable(OPTION_IN_SELECT_ATTR_VALUE, attributeValue);
  final IModelFactory modelFactory = context.getModelFactory();
  structureHandler.insertBefore(hiddenMethodElementModel);
origin: thymeleaf/thymeleaf-spring

  final IElementTagStructureHandler structureHandler) {
String newAttributeValue = HtmlEscape.escapeHtml4Xml(expressionResult == null ? "" : expressionResult.toString());
    final IModelFactory modelFactory = context.getModelFactory();
    structureHandler.insertImmediatelyAfter(extraHiddenElementTags, false);
origin: org.thymeleaf/thymeleaf-spring4

@Override
protected void doProcess(final ITemplateContext context,
             final IProcessableElementTag tag,
             final AttributeName attributeName, final String attributeValue,
             final BindStatus bindStatus, final IElementTagStructureHandler structureHandler) {
  String name = bindStatus.getExpression();
  name = (name == null? "" : name);
  final String id = computeId(context, tag, name, false);
  final String value = ValueFormatterWrapper.getDisplayString(bindStatus.getValue(), bindStatus.getEditor(), true);
  String processedValue =
      RequestDataValueProcessorUtils.processFormFieldValue(context, name, value, "textarea");
  if (!StringUtils.isEmpty(processedValue)) {
    final char c0 = processedValue.charAt(0);
    if (c0 == '\n') {
      processedValue = '\n' + processedValue;
    } else if (c0 == '\r' && processedValue.length() > 1 && processedValue.charAt(1) == '\n') {
      processedValue = "\r\n" + processedValue;
    } else if (c0 == '\r') {
      processedValue = '\r' + processedValue;
    }
  }
  StandardProcessorUtils.setAttribute(structureHandler, this.idAttributeDefinition, ID_ATTR_NAME, id); // No need to escape: this comes from an existing 'id' or from a token
  StandardProcessorUtils.setAttribute(structureHandler, this.nameAttributeDefinition, NAME_ATTR_NAME, name); // No need to escape: this is a java-valid token
  structureHandler.setBody((processedValue == null? "" : processedValue), false);
}
origin: thymeleaf/thymeleaf

  final IElementTagStructureHandler structureHandler) {
final IEngineConfiguration configuration = context.getConfiguration();
    structureHandler.removeBody();
    return;
  structureHandler.setBody(((Fragment)expressionResult).getTemplateModel(), false);
  return;
  structureHandler.setBody(unescapedTextStr, false);
  return;
  structureHandler.setBody(unescapedTextStr, false);
  return;
        context.getTemplateData(),
        unescapedTextStr,
        0, 0, // we won't apply offset here because the inserted text does not really come from the template itself
structureHandler.setBody(parsedFragment, false);
origin: thymeleaf/thymeleaf

      text = new LazyEscapingCharSequence(context.getConfiguration(), templateMode, input);
    } else {
  text = new LazyEscapingCharSequence(context.getConfiguration(), templateMode, expressionResult);
structureHandler.setBody(text, false);
origin: jpenren/thymeleaf-spring-data-dialect

@Override
protected void doProcess(ITemplateContext context, IProcessableElementTag tag, AttributeName attributeName,
    String attributeValue, IElementTagStructureHandler structureHandler) {
  Locale locale = context.getLocale();
  loadSelectorValues(locale);
  String selectorStyle = String.valueOf(attributeValue).trim();
  String messageKey = getMessageKey(selectorStyle);
  String options = composeSelectorOptions(selectorStyle, context);
  String message = Messages.getMessage(BUNDLE_NAME, messageKey, locale, options);
  structureHandler.setBody(message, false);
}
origin: thymeleaf/thymeleaf-spring

@Override
protected void doProcess(
    final ITemplateContext context, final IProcessableElementTag tag,
    final AttributeName attributeName, final String attributeValue,
    final IElementTagStructureHandler structureHandler) {
  final IThymeleafBindStatus bindStatus = FieldUtils.getBindStatus(context, attributeValue);
  if (bindStatus.isError()) {
    final StringBuilder strBuilder = new StringBuilder();
    final String[] errorMsgs = bindStatus.getErrorMessages();
    for (int i = 0; i < errorMsgs.length; i++) {
      if (i > 0) {
        strBuilder.append(ERROR_DELIMITER);
      }
      final String displayString = SpringValueFormatter.getDisplayString(errorMsgs[i], false);
      strBuilder.append(HtmlEscape.escapeHtml4Xml(displayString));
    }
    structureHandler.setBody(strBuilder.toString(), false);
    // Just in case we also have a th:errorclass in this tag
    structureHandler.setLocalVariable(SpringContextVariableNames.THYMELEAF_FIELD_BIND_STATUS, bindStatus);
  } else {
    structureHandler.removeElement();
  }
}
org.thymeleaf.processor.elementIElementTagStructureHandler

Javadoc

Structure handler class meant to be used by IElementTagProcessor implementations.

Structure handlers allow processors to instruct the engine to perform a series of actions that cannot be done directly from the processors themselves, usually because these actions are applied or have effects on scopes broader than the processed events themselves.

Most used methods

  • setBody
  • removeAttribute
  • removeElement
  • setAttribute
  • replaceWith
  • setLocalVariable
  • insertBefore
  • insertImmediatelyAfter
  • replaceAttribute
  • removeTags
  • iterateElement
    Instructs the engine to iterate the current element, applying a specific iteration configuration.
  • removeAllButFirstChild
    Instructs the engine to remove all the children of the element being processed, except the first on
  • iterateElement,
  • removeAllButFirstChild,
  • removeBody,
  • setInliner,
  • setSelectionTarget,
  • setTemplateData

Popular in Java

  • Running tasks concurrently on multiple threads
  • setRequestProperty (URLConnection)
  • requestLocationUpdates (LocationManager)
  • onCreateOptionsMenu (Activity)
  • Component (java.awt)
    A component is an object having a graphical representation that can be displayed on the screen and t
  • FileOutputStream (java.io)
    An output stream that writes bytes to a file. If the output file exists, it can be replaced or appen
  • System (java.lang)
    Provides access to system-related information and resources including standard input and output. Ena
  • KeyStore (java.security)
    KeyStore is responsible for maintaining cryptographic keys and their owners. The type of the syste
  • Semaphore (java.util.concurrent)
    A counting semaphore. Conceptually, a semaphore maintains a set of permits. Each #acquire blocks if
  • Cipher (javax.crypto)
    This class provides access to implementations of cryptographic ciphers for encryption and decryption
  • From CI to AI: The AI layer in your organization
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