简体   繁体   中英

IBM Content Navigator ContentList setting properties to row item

I'm trying to build a custom search and I followed the sample from redbook. However, instead of creating a new feature, I'm just modifying the current search behavior by modifying the query that gets executed on FileNet database. Based on the sample, only few default properties are being set and displayed. I'm struggling to set the other document properties.

  private static void buildResultStructure(JSONResultSetResponse jsonResultSet, MessageResources resources, Locale clientLocale) { 
    String[] states = new String[1]; 
    states[0] = "isLocked"; 
    jsonResultSet.addColumn(new JSONResultSetColumn(" ", "multiStateIcon", false, states));
    jsonResultSet.addColumn(new JSONResultSetColumn(" ", "17px", "mimeTypeIcon", null, false)); 
    jsonResultSet.addColumn(new JSONResultSetColumn(resources.getMessage(clientLocale, "search.results.header.id"), "200px", "ID", null, false));
    jsonResultSet.addColumn(new JSONResultSetColumn("Class Name", "125px", "className", null, false)); 
    jsonResultSet.addColumn(new JSONResultSetColumn(resources.getMessage(clientLocale, "search.results.header.lastModifiedByUser"), "125px", "ModifiedBy", null, false)); 
    jsonResultSet.addColumn(new JSONResultSetColumn(resources.getMessage(clientLocale, "search.results.header.lastModifiedTimestamp"), "175px", "LastModified", null, false)); 
    jsonResultSet.addColumn(new JSONResultSetColumn(resources.getMessage(clientLocale, "search.results.header.version"), "50px", "Version", null, false));
    jsonResultSet.addMagazineColumn(new JSONResultSetColumn("thumbnail", "60px", "thumbnail", null, null)); 
    com.ibm.json.java.JSONArray fieldsToDisplay = new com.ibm.json.java.JSONArray();
    com.ibm.json.java.JSONObject jsonObj = new com.ibm.json.java.JSONObject(); 
    jsonObj.put("field", "className");
    jsonObj.put("displayName", "Class"); 
    fieldsToDisplay.add(jsonObj); 
    jsonObj =new com.ibm.json.java.JSONObject(); 
    jsonObj.put("field", "ModifiedBy");
    jsonObj.put("displayName", resources.getMessage(clientLocale, "search.results.header.lastModifiedByUser")); 
    fieldsToDisplay.add(jsonObj);
    jsonObj = new com.ibm.json.java.JSONObject(); 
    jsonObj.put("field", "LastModified");
    jsonObj.put("displayName", resources.getMessage(clientLocale, "search.results.header.lastModifiedTimestamp"));
    fieldsToDisplay.add(jsonObj);
    jsonObj = new com.ibm.json.java.JSONObject();
    jsonObj.put("field", "Version"); 
    jsonObj.put("displayName", resources.getMessage(clientLocale, "search.results.header.version"));
    fieldsToDisplay.add(jsonObj); 
    
    jsonResultSet.addMagazineColumn(new JSONResultSetColumn("content", "100%", "content", fieldsToDisplay, null));
  }

First go to the file SamplePluginSearchServiceP8.java and buildP8ResultStructure function. remove the unnecessary columns. add your new columns, with the relevant format

jsonResultSet.addColumn(new JSONResultSetColumn(" ", your column width, your field name, sortable?, false));

after you do so, go to the executeP8Search on the same java file, look at row number 122, iterate your searchResults that returned with values from your query, for each row add the relevant value.

JSONResultSetRow row = new JSONResultSetRow(sbId.toString(), doc.get_Name(), doc.get_MimeType(), privileges);

row.addAttribute("your field name", doc.isLocked(), JSONResultSetRow.TYPE_BOOLEAN, null, (new Boolean(doc.isLocked())).toString()); //***please notice to add the relevant type, string to string value, int, bool etc..

jsonResultSet.addRow(row);

do not forget to fix the ContinueQueryService.java in the same way.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM