protected String getFragment(DataRepository data, String rollupID) { // check in the cache to see if there is a cached value for // this ID. if so, return it. String cachedResult = CACHE.get(rollupID); if (cachedResult != null) return cachedResult; // lookup the data element [/ROLLUP_ID/Rollup Instance // List]. If it is missing or if it contains less than two // items, return an empty fragment (and save the empty // fragment to the cache). String instanceListName = rollupInstanceList(rollupID); ListData instanceList = getList(data, instanceListName); if (instanceList == null || instanceList.size() < 2) return CACHE.put(rollupID, ""); // Construct an HTML fragment String prompt = resources.format("Rollup_Select_Prompt_FMT", rollupID); StringBuffer result = new StringBuffer(); result .append("<tr><td>") .append(HTMLUtils.escapeEntities(prompt)) .append(" </td>\n <td colspan=10><select name='[") .append(rollupPrefix(rollupID)) .append("]s'>"); for (int i = 0; i < instanceList.size(); i++) { String opt = HTMLUtils.escapeEntities((String) instanceList.get(i)); result.append("\n<option value=\"").append(opt).append("\">").append(opt); } result.append("\n</select></td></tr>\n"); return CACHE.put(rollupID, result.toString()); }
protected void writeContents() throws IOException { DataRepository data = getDataRepository(); if (data == null) return; init(data); // get the [Use_Rollup] data element for the current // project. If it is null, return immediately. String prefix = getPrefix(); if (prefix == null) return; String useRollupName = DataRepository.createDataName(prefix, "Use_Rollup"); ListData rollupIDs = getList(data, useRollupName); if (rollupIDs == null) return; String tableStart = TABLE_START, tableEnd = "", tableRow; for (int i = 0; i < rollupIDs.size(); i++) { tableRow = getFragment(data, rollupIDs.get(i).toString()); if (tableRow != null && tableRow.length() > 0) { out.print(tableStart); out.print(tableRow); tableStart = ""; tableEnd = TABLE_END; } } out.print(tableEnd); }