Formatting Cells in Tables

Translations of this page:

Every table in JVx displays even- and odd-numbered rows in different colors, which greatly enhances user friendliness. However, in many cases that is not enough. Therefore, we also have the option of formatting cells using different fonts and colors.

Cells can be formatted using ICellFormatter.


Our application creates a form in which a log table from the database is displayed. Each entry has a status (ERROR, WARNING, INFO). All columns in a given row should be colored depending on the status.

The following lines show the definition and use of cell formatting:

/** the cell format for red lines. */
public static final UICellFormat CP_RED = new UICellFormat(;
/** the log data. */
private RemoteDataBook rdbLog = new RemoteDataBook();
/** the log table. */
private UITable tblLog = new UITable();
 * Initializes the UI.
public void init()
    tblLog.setCellFormatter(this, "formatLog");
 * Formats the log table.
 * @param pDataBook the log databook
 * @param pDataPage the current datapage
 * @param pDataRow the current row
 * @param pColumnName the current column name
 * @param pRow the current row
 * @param pColumn the current column
 * @return the cell format
 * @throws ModelException if an error occurs during format detection
public ICellFormat formatLog(IDataBook pDataBook, 
                      IDataPage pDataPage, 
                      IDataRow pDataRow, 
                      String pColumnName, 
                      int pRow, 
                      int pColumn) throws ModelException
    if ("ERROR".equals(pDataRow.getValue("STATE")))
        return CP_RED;
    return null;


If the formatting of cells causes and throws an exception, it will be ignored by the table and not be sent to the surface.

The developer, therefore, needs to handle the error!

This website uses cookies for visitor traffic analysis. By using the website, you agree with storing the cookies on your computer.More information