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

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

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

origin: thymeleaf/thymeleaf

public static void setAttribute(
    final IElementTagStructureHandler structureHandler,
    final AttributeDefinition attributeDefinition, final String attributeName, final String attributeValue) {
  if (structureHandler instanceof ElementTagStructureHandler) {
    ((ElementTagStructureHandler) structureHandler).setAttribute(attributeDefinition, attributeName, attributeValue, null);
  } else {
    structureHandler.setAttribute(attributeName, attributeValue);
  }
}
origin: thymeleaf/thymeleaf

  structureHandler.setAttribute(newAttributeName, newAttributeName);
} else {
  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: com.foreach.across.modules/spring-mobile-module

  /**
   * This method replaces the attribute device:replace="XXX" with th:replace"DEVICE_PREFIX/XXX"
   * This is useful for including device specific fragments
   */
  @Override
  protected void doProcess( ITemplateContext context,
               IProcessableElementTag tag,
               AttributeName attributeName,
               String attributeValue,
               IElementTagStructureHandler structureHandler ) {
    ApplicationContext applicationContext
        = (ApplicationContext) context.getConfiguration()
                       .getExecutionAttributes()
                       .get( DeviceDialect.APPLICATION_CONTEXT_ATTRIBUTE );
    DeviceBasedViewNameResolver deviceBasedViewNameResolver
        = applicationContext.getBean( DeviceBasedViewNameResolver.class );

    structureHandler.setAttribute(
        StandardDialect.PREFIX + ":" + StandardReplaceTagProcessor.ATTR_NAME,
        deviceBasedViewNameResolver.resolveDeviceSpecificView( attributeValue )
    );
  }
}
origin: io.github.jpenren/thymeleaf-spring-data-dialect

@Override
protected void doProcess(ITemplateContext context, IProcessableElementTag tag, AttributeName attributeName,
    String attributeValue, IElementTagStructureHandler structureHandler) {
  String attrValue = String.valueOf(Expressions.evaluate(context, attributeValue)).trim();
  Page<?> page = PageUtils.findPage(context);
  String url = PageUtils.createSortUrl(context, attrValue);
  // Append class to the element if sorted by this field
  Sort sort = page.getSort();
  boolean isSorted = sort != null && sort.getOrderFor(attributeValue) != null;
  String clas = isSorted
      ? SORTED_PREFIX.concat(sort.getOrderFor(attributeValue).getDirection().toString().toLowerCase())
      : EMPTY;
  structureHandler.setAttribute(HREF, url);
  String currentClass = tag.getAttributeValue(CLASS);
  structureHandler.setAttribute(CLASS, Strings.concat(currentClass, BLANK, clas));
}
origin: jpenren/thymeleaf-spring-data-dialect

@Override
protected void doProcess(ITemplateContext context, IProcessableElementTag tag, AttributeName attributeName,
    String attributeValue, IElementTagStructureHandler structureHandler) {
  String attrValue = String.valueOf(Expressions.evaluate(context, attributeValue)).trim();
  Page<?> page = PageUtils.findPage(context);
  String url = PageUtils.createSortUrl(context, attrValue, getForcedDirection());
  // Append class to the element if sorted by this field
  Sort sort = page.getSort();
  boolean isSorted = sort != null && sort.getOrderFor(attrValue) != null;
  String clas = isSorted
      ? SORTED_PREFIX.concat(sort.getOrderFor(attrValue).getDirection().toString().toLowerCase())
      : EMPTY;
  structureHandler.setAttribute(HREF, url);
  String currentClass = tag.getAttributeValue(CLASS);
  structureHandler.setAttribute(CLASS, Strings.concat(currentClass, BLANK, clas));
}

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: org.thymeleaf/thymeleaf-spring4

@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

@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

@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: org.thymeleaf/thymeleaf-spring3

@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);
}
org.thymeleaf.processor.elementIElementTagStructureHandlersetAttribute

Javadoc

Instructs the engine to set an attribute (existing or not) in the current tag being processed.

Popular methods of IElementTagStructureHandler

  • setBody
    Instructs the engine to set a new body for the current element, in the form of an IModel. This is
  • removeAttribute
  • removeElement
  • replaceWith
  • setLocalVariable
  • insertBefore
  • insertImmediatelyAfter
  • replaceAttribute
    Instructs the engine to replace an existing attribute for a new one (which can also exist) in the c
  • 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
  • removeBody
    Instructs the engine to remove the body of the element being processed, but keep the open and close
  • removeAllButFirstChild,
  • removeBody,
  • setInliner,
  • setSelectionTarget,
  • setTemplateData

Popular in Java

  • Reading from database using SQL prepared statement
  • getExternalFilesDir (Context)
  • getResourceAsStream (ClassLoader)
  • getSharedPreferences (Context)
  • Pointer (com.sun.jna)
    An abstraction for a native pointer data type. A Pointer instance represents, on the Java side, a na
  • Window (java.awt)
    A Window object is a top-level window with no borders and no menubar. The default layout for a windo
  • FileInputStream (java.io)
    An input stream that reads bytes from a file. File file = ...finally if (in != null) in.clos
  • NoSuchElementException (java.util)
    Thrown when trying to retrieve an element past the end of an Enumeration or Iterator.
  • Stream (java.util.stream)
    A sequence of elements supporting sequential and parallel aggregate operations. The following exampl
  • Response (javax.ws.rs.core)
    Defines the contract between a returned instance and the runtime when an application needs to provid
  • Github Copilot alternatives
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