All Downloads are FREE. Search and download functionalities are using the official Maven repository.

com.github.dandelion.datatables.thymeleaf.processor.TrElProcessor Maven / Gradle / Ivy

There is a newer version: 1.1.0
Show newest version
package com.github.dandelion.datatables.thymeleaf.processor;

import org.thymeleaf.Arguments;
import org.thymeleaf.dom.Element;
import org.thymeleaf.processor.IElementNameProcessorMatcher;
import org.thymeleaf.processor.ProcessorResult;

import com.github.dandelion.datatables.core.html.HtmlRow;
import com.github.dandelion.datatables.core.html.HtmlTable;
import com.github.dandelion.datatables.thymeleaf.dialect.DataTablesDialect;
import com.github.dandelion.datatables.thymeleaf.dialect.AbstractDatatablesElProcessor;

/**
 * Element processor applied to the tr HTML tag. Whenever Thymeleaf
 * meets a tr tag, a HtmlRow is added to the current table. So each
 * td tag will be able to update it.
 * 
 * @author Thibault Duchateau
 */
public class TrElProcessor extends AbstractDatatablesElProcessor {

	public TrElProcessor(IElementNameProcessorMatcher matcher) {
		super(matcher);
	}

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

	@Override
	protected ProcessorResult doProcessElement(Arguments arguments, Element element, HtmlTable table) {

		if (table != null) {
			table.getBodyRows().add(new HtmlRow());
		}

		if (element.hasAttribute(DataTablesDialect.DIALECT_PREFIX + ":data")) {
			element.removeAttribute(DataTablesDialect.DIALECT_PREFIX + ":data");
		}

		return ProcessorResult.OK;
	}
}




© 2015 - 2024 Weber Informatics LLC | Privacy Policy