Add Ordinal Columns

Revision as of 08:29, 5 November 2009 by Admin (Talk | contribs)

Creating Ordinal Columns in Table Component


1. Solution 1:

- Right-click the table > Table Layout
- Add a new column named "No." and then set its value to #{currentRow.tableRow.rowId + 1}

  • The bean currentRow indicates one row (one record). Its type is TableDataProvider
  • The property tableRow has type RowKey with an auto increment attribute rowId
  • Cons: the order is changed if we sort any columns

2. Solution 2:

- Create a private property "no" in the page that contains the table
- Write a method "getNo"as below:

private int no = 0;

public int getNo() { return no++; }

- Bind value of no. column to this getter #{no}

Not logged in. Log in, Register

By use of this website, you agree to the NetBeans Policies and Terms of Use. © 2012, Oracle Corporation and/or its affiliates. Sponsored by Oracle logo