Tuesday, January 24, 2012

How to hide Add Repository browser tree node in Webtop

Probably many developers faced the problem: how to hide the 'Add repository' node from the browser tree? No, there's no OOTB configuration for this.
The WDK development Guide says you have to make your custom component, with your class, jsp and even a tld. That's cumbersome!
There's a trick that will hide that node faster: just copy the browsertree.jsp into your custom layer, add a browsertree_component.xml definition (perhaps you already have it) extending it from the webtop layer and set your custom browsertree.jsp page. Now open your custom browsertree.jsp file and add at the end of it, inside the last javascript tag, the following JS code:

var addRepository = findMatchingElements('selectrepository','div');
addRepository.style.visibility='hidden';

function findMatchingElements(toMatch, tagname) {
var reMatch = new RegExp( toMatch, "i" ); // match and ignore case
if ( tagname == null ) tagname = "*"; // if not tagname passed, search all
var elems = document.getElementsByTagName(tagname);
for ( var e = 0; e < elems.length; ++e ) {
if (elems[e].id.match(reMatch))
return elems[e];
}
}

That's all! Deploy and see it ... hidden.

4 comments:

  1. This works absolutely fine. Thnx a lot

    ReplyDelete
  2. Thank you, saved me some time

    ReplyDelete
  3. just FYI

    does not work when basic items are hid using presets.

    crappy workaround, update string in 'webtop\strings\com\documentum\webtop\control\WebtopBrowserTreeNlsProp.properties' to blank

    ReplyDelete