} else {
odd = true;
}
buffer.append("<tr>\n");
ValueListRow row = (ValueListRow) list.get(i);
List rowData = row.getRowData();
// if this is an Entity list, and we're looking at the Default entity
// record (id == 1), highlight the row
if (listType == 1 && row.getRowId() == 1) { // sorry 'bout the magic
// numbers
rowClass = "defaultEntityRow";
}
if (this.listObject.getDisplay().isCheckboxes() && !this.listObject.getLookupType().equals("SecurityProfile")) {
if (this.listObject.getParameters().getValueListType() == ValueListConstants.KNOWLEDGEBASE_LIST_TYPE
|| this.listObject.getParameters().getValueListType() == ValueListConstants.FILE_LIST_TYPE) {
this.addCheckBox(buffer, row.getRowId(), odd, rowClass, rowData, ValueListConstants.FILE_INDEX);
} else {
this.addCheckBox(buffer, row.getRowId(), odd, rowClass, null, 0);
}
}
// If the selection widgets are radio boxes instead of the checkboxes
// (as when the list is a lookup), then we must do the following things:
if (this.listObject.getDisplay().isRadio()) {
// Added the selected index value to the javascript function so that it
// will populate the form
Integer listTypeInteger = new Integer(this.listObject.getParameters().getValueListType());
ArrayList radioSelectionIndexList = (ArrayList) ValueListConstants.RADIO_SELECTION_MAP.get(listTypeInteger);
StringBuffer onSelectParameters = new StringBuffer();
StringBuffer onRowValues = new StringBuffer();
onSelectParameters.append("'");
Iterator thisIndexIterator = radioSelectionIndexList.iterator();
String typeOfLookup = (String) thisIndexIterator.next();
String radioType = "radio";
// This is a special Condition. We have to set the correct lookup type,
// so that we will make the correct selection of values
if (this.listObject.getLookupType() != null && this.listObject.getLookupType().equals("lookup_attendee")) {
typeOfLookup = "lookup_attendee";
ArrayList radioSelectionIndexAttendee = ValueListConstants.radioSelectedIndexAttendee;
for (int k = 0; k < radioSelectionIndexAttendee.size(); k++) {
int currentIndex = ((Integer) radioSelectionIndexAttendee.get(k)).intValue();
String fieldValue = String.valueOf(rowData.get(currentIndex - 1));
if (currentIndex == ValueListConstants.ATTENDEEROWID) {
onRowValues.append(fieldValue + "&");
} else if (currentIndex == ValueListConstants.ATTENDEEFIRSTNAME) {
onRowValues.append(fieldValue + " ");
} else {
onRowValues.append(fieldValue);
}
}
}
if (this.listObject.getLookupType() != null && this.listObject.getLookupType().equals("lookupSubItem")) {
typeOfLookup = "SubItem";
}
// First snag the lookupType string from the front of the arrayList.
onSelectParameters.append(typeOfLookup);
onSelectParameters.append("','");
while (thisIndexIterator.hasNext()) {
int currentIndex = ((Integer) thisIndexIterator.next()).intValue();
String fieldValue = String.valueOf(rowData.get(currentIndex - 1));
if (fieldValue != null) {
Pattern pattern = Pattern.compile("[^a-zA-z_0-9 ]");
Matcher fieldMatch = pattern.matcher(fieldValue);
fieldValue = fieldMatch.replaceAll("");
// fieldValue = fieldValue.replaceAll("'","");
}
if (fieldValue == null || fieldValue.equals("null")) {
fieldValue = "";
}
onSelectParameters.append(fieldValue);
if (thisIndexIterator.hasNext()) {
onSelectParameters.append("','");
}
}
onSelectParameters.append("'");
if (this.listObject.getDisplay().isRadioToCheckBox()) {
radioType = "checkbox";
}
boolean flagRadio = true;
String folderType = null;
if (listTypeInteger.intValue() == ValueListConstants.FILE_LIST_TYPE) {
folderType = rowData.get(ValueListConstants.KB_FILE_EMAIL_HACK_INDEX - 1).toString();
if (folderType != null && folderType.equals("FOLDER")) {
flagRadio = false;
}
}
if (flagRadio) {
this.addRadio(buffer, row.getRowId(), onSelectParameters.toString(), onRowValues.toString(), radioType, rowClass);
}
}
if (this.listObject.getLookupType().equals("SecurityProfile")) {
this.addCheckBox(buffer, row.getRowId(), odd, rowClass, rowData, ValueListConstants.SECURITY_PROFILE);
}
if (this.listObject.getDisplay().isIcon()) {
if (this.listObject.getParameters().getValueListType() == ValueListConstants.EMAIL_LIST_TYPE) {
this.addIcon(buffer, rowData, ValueListConstants.EMAIL_ICON, rowClass);
} else if (this.listObject.getParameters().getValueListType() == ValueListConstants.KNOWLEDGEBASE_LIST_TYPE
|| this.listObject.getParameters().getValueListType() == ValueListConstants.FILE_LIST_TYPE) {
this.addIcon(buffer, rowData, ValueListConstants.KB_FILE_EMAIL_HACK_INDEX, rowClass);
} else {
this.addIcon(buffer, rowData, ValueListConstants.ICON_INDEX, rowClass);
}
}
if (this.listObject.getDisplay().isAttachmentIcon()) {
this.addAttachmentIcon(buffer, rowData, ValueListConstants.ATTACHMENT_ICON, rowClass);
}
if (this.listObject.getDisplay().isPriority()) {
this.addPriorityIcon(buffer, rowData, ValueListConstants.PRIORITY_ICON, rowClass);
}
if (this.listObject.getDisplay().isDownloadIcon()) {
this.addDownloadIcon(buffer, rowData, ValueListConstants.DOWNLOAD_ICON, rowClass);
}
// readStatus is NO, that means we haven't read this message
// we will apply the different Style to it
if (readStatus != null && readStatus.equals("NO")) {
rowClass = rowClass + "Bold";
}
Iterator selectedIterator = this.selectedColumns.iterator();
while (selectedIterator.hasNext()) {
int index = ((Integer) selectedIterator.next()).intValue();
Object columnData = null;
// If this a an email lookup list we need extra checkboxes on the front.
if (this.listObject.isLookup() && this.listObject.getLookupType().equals("Email")) {
switch (index) {
case ValueListConstants.TO_INDEX:
case ValueListConstants.CC_INDEX:
case ValueListConstants.BCC_INDEX:
this.addCheckBox(buffer, row.getRowId(), odd, rowClass, rowData, index);
continue;
}
}
if (index - 1 > rowData.size() || index - 1 < 0) { // Out of bounds,