0
votes

In my current spring project, If I had a tag like this:

<thform:form attr1="..." attr2="...">
...
</thform:form>

handled by this thymeleaf processor:

public class Form extends AbstractProcessor {
  @Override
  public ProcessorResult doProcess(Arguments arguments,ProcessorMatchingContext context,Node node) {
    Element form = new Element("form");
    form.setProcessable(true);
    form.setAttribute("role", "form");
    form.setAttribute("class", "form");
    form.setAttribute("action", "");
    form.setAttribute("method", "post");
    node.getParent().insertBefore(node, form);
    return ProcessorResult.OK;
  }

  @Override
  public int getPrecedence() {
    return 0;
  }

  @Override
  public IProcessorMatcher<? extends Node> getMatcher() {
    return new ElementNameProcessorMatcher("form");
  }
}

how I could read the value for attr1 and attr2?

1

1 Answers

0
votes

I found this can be done this way:

Element parent = (Element) node;
setAction( parent.getAttributeValue("action") );

in this case, action it's a attribute of the processor class.