Interface DomTableEditorValue

All Superinterfaces:
EditorValue<Table>

public interface DomTableEditorValue extends EditorValue<Table>
The DomTableEditorValue interface represents the FirstSpirit input component CMS_INPUT_DOMTABLE
Since:
2.3.17
Example:
How to get and store value
import de.espirit.firstspirit.access.editor.*;

import de.espirit.firstspirit.access.Language;
import de.espirit.firstspirit.access.editor.value.InvalidValueException;
import de.espirit.firstspirit.access.editor.value.Table;
import de.espirit.firstspirit.access.editor.value.TableCell;


/**
 * Example how to get the value of a DomTableEditorValue and how to store a value into a DomTableEditorValue.
 *
 * @since 4.2.34
 */
public class DomTableEditorValueExample {

	/**
	 * A simple example how to append rows and columns to an empty DomTableEditorValue.
	 *
	 * -----------------------------
	 * | cell 0 (initial) | cell 1 |
	 * -----------------------------
	 * | cell 2           | cell 3 |
	 * -----------------------------
	 *
	 * @since 4.2.34
	 */
	public void setValueForLanguage(final DomTableEditorValue editor, final Language language) throws InvalidValueException {

		// 1. check if language is provided if editor is language dependent ("useLanguages='yes'" in gom syntax)
		if (editor.isLanguageDependent() && language == null) {
			throw new NullPointerException("Language is missing!");
		}

		// 2. get the table of the editor value
		final Table table = editor.get(language);

		// 3. by default a new table already has one table cell - retrieve the already existing table cell
		final TableCell firstCell = table.getCell(0, 0);

		// 4. append an initial text to this cell
		firstCell.appendChild("cell 0 (initial)");

		// 3. create new table structure
		table.addRow(table.getRows());          // add a new row at the end
		table.addColumn(table.getColumns());    // add a new column at the end

		// 4. retrieve table cells and append text content
		final TableCell tableCell1 = table.getCell(0, 1);
		tableCell1.appendChild("cell 1");
		final TableCell tableCell2 = table.getCell(1, 0);
		tableCell2.appendChild("cell 2");
		final TableCell tableCell3 = table.getCell(1, 1);
		tableCell3.appendChild("cell 3");

		// 5. store dom element back into the editor value
		editor.set(language, table);
	}


	/**
	 * Returns the value of the DomTableEditorValue for the given language.
	 *
	 * @since 4.2.34
	 */
	public Table getValueForLanguage(final DomTableEditorValue editor, final Language language) {

		// 1. get the stored instance in the editor value
		final Table value = editor.get(language);

		// 2. and return the value for further processing
		return value;
	}
}
  • Field Details

  • Method Details

    • getRows

      int getRows(Language language)
      Provides the number of rows for the given language.
      Parameters:
      language - The language for that the number of rows should be submitted.
      Since:
      3.0.95
    • getColumns

      int getColumns(Language language)
      Provides the number of columns for the given language.
      Parameters:
      language - The language for that the number of columns should be submitted.
      Since:
      3.0.95
    • addRow

      void addRow(Language language, int afterRow)
      Adds a row for the given language after the defined row index.
      Parameters:
      language - The language for which the row should be added.
      afterRow - The row index after which the row should be added.
      Since:
      3.0.95
    • deleteRow

      void deleteRow(Language language, int row)
      Deletes the row for the given language and the defined index.
      Parameters:
      language - The language for which the row should be deleted.
      row - The row's index that should be deleted.
      Since:
      3.0.95
    • addColumn

      void addColumn(Language language, int afterColumn)
      Adds a column for the given language after the defined column index.
      Parameters:
      language - The language for which the column should be added.
      afterColumn - The column index after which the column should be added.
      Since:
      3.0.95
    • deleteColumn

      void deleteColumn(Language language, int column)
      Deletes the column for the given language and the defined index.
      Parameters:
      language - The language for which the column should be deleted.
      column - The column's index that should be deleted.
      Since:
      3.0.95
    • getCell

      @Nullable @Nullable TableCell getCell(Language language, int row, int column)
      Gets the cell of this dom table with the given row & col index or null if no cell exists with these indices.
      Parameters:
      language - the language to get the cell value for
      row - the row index
      column - the col index
      Returns:
      TableCell or null if no cell exists for given indices
      Since:
      4.0.17
    • getForm

      GomDomTable getForm()
      Get the form definition.
      Specified by:
      getForm in interface EditorValue<Table>
      Returns:
      The form definition.
      Since:
      4.0.17
    • getSection

      Section getSection(Language language, int row, int column)
      Get a cell defined by language, row, and column as Section object.
      Parameters:
      language - The language to look up.
      row - The row of the cell.
      column - The column of the cell.
      Returns:
      The matching section or null.
      Since:
      4.0.17
    • getAllowedLinkTemplates

      @NotNull @NotNull List<LinkTemplate> getAllowedLinkTemplates()
      Get a list of allowed link types.
      Returns:
      The list of allowed link types.
      Since:
      4.2.8