code: private String filterCategoryJS() {
  
          StringBuffer result = new StringBuffer();
          // fool the widget with a hidden categories input field
          result.append("<input name=\"dummysearchcategory\" id=\"dummysearchcategory\" type=\"hidden\" value=\"\">\n");
          result.append("<input name=\"dummysearchpage\" id=\"dummysearchpage\" type=\"hidden\" value=\"\">\n");
          // delete all other chosen "cateogries.x" values and put a value here
          result.append("<script type=\"text/javascript\">\n");
          result.append("  function filterCategory(category) {\n");
          result.append("    var searchform = document.forms['EDITOR'];\n");
          result.append("    var inputFields = searchform.elements;\n");
          result.append("    for (var i=0; i<inputFields.length; i++) {\n");
          result.append("      if(inputFields[i].name != null && inputFields[i].name.indexOf('categories') != -1) {\n");
          result.append("        inputFields[i].value='';\n");
          result.append("        inputFields[i].name='invalidsearchcategory';\n");
          result.append("      }\n");
          result.append("    }\n");
          // if we found a category field use it, if not, set the name of our
          // fooling field to "categories.0" or the widget filling will fail
          result.append("    var categoryField = inputFields['dummysearchcategory'];\n");
          result.append("    categoryField.name = 'categories.0';\n");
          result.append("    categoryField.value = category;\n");
          // additionally set searchpage to zero because filtered results may / will be smaller
          result.append("    inputFields['dummysearchpage'].value = '0';\n");
          result.append("    inputFields['dummysearchpage'].name = 'searchpage.0';\n");
          result.append("    validateQuery();\n");
          result.append("    searchform.submit();\n");
          result.append("  }\n");
          result.append("</script>\n");
          return result.toString();
      }
docs: Generates the JavaScript to filter categories.<p>
  
  @return the JavaScript