Monday, March 05, 2007

How to get all the codes in the codetable

Here's the easiest way of getting all the codes in a code table.

final String[] allCodes =
curam.type.CodeTable.getAllCodes(
  A_CODE_TABLE.TABLENAME,
  TransactionInfo.getProgramLocale());
This will get a copy of the codes in the code table cache. Normally, you'd use this to read to populate a list of code details like this.
CodeDetailList codeDetailList = new CodeDetailList();
for (int i = 0; i < allCodes.length; ++i) {
CodeDetail codeDetail = new CodeDetail();
codeDetail.code = allCodes[i];
codeDetailList.addRef(codeDetail);
}

0 comments: