Skip to content

Instantly share code, notes, and snippets.

@ArjanBas
Last active January 16, 2017 12:35
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save ArjanBas/62c38e7888973df31d195f09bb5b99d4 to your computer and use it in GitHub Desktop.
Save ArjanBas/62c38e7888973df31d195f09bb5b99d4 to your computer and use it in GitHub Desktop.
Content navigator extension to extend desktop configuration with custom parameters (java/javascript)
package nl.arba.sample.contentnavigator.desktop.requestFilter;
import com.ibm.ecm.extension.PluginResponseFilter;
import com.ibm.ecm.extension.PluginServiceCallbacks;
import com.ibm.json.java.JSONObject;
import javax.servlet.http.HttpServletRequest;
public class DesktopRequestFilter extends PluginResponseFilter {
/**
* Extend the getDesktop service
*/
  @Override   
public String[] getFilteredServices() {
return new String[] { "/getDesktop" };   
}
  @Override
public void filter(String serverType, PluginServiceCallbacks callbacks, HttpServletRequest request, JSONObject jsonresponse) throws Exception {
try {
jsonresponse.put("MyAppName", JSONObject.parse("{\"appName\":\"MyApp\"}"));
System.out.println("GETDESKTOPRESPONSEFILTER: " + request.getParameter("repositoryId"));
}
catch (Exception err) {
jsonresponse.put("MyAppName", "error");
}
}
}
require([
"dojo/_base/declare", 
"dojo/_base/lang", 
"ecm/model/Desktop", 
"dojo/aspect"
], function(declare, lang, Desktop, aspect) { 
aspect.after(Desktop,"onDesktopLoaded",function (payload){
if ("error"==payload.MyAppName) {
new ecm.widget.dialog.MessageDialog({
label:"Fout tijdens opstarten",
text:"Het is niet gelukt je Favorieten te laden"
}).show();
Desktop.MyAppName = '?';
} else {
Desktop.MyAppName = payload.MyAppName;   
}
},true);
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment