thrownewRuntimeException("Number of JavaScript jobs doesn't drop to initial level for "+timeout+" seconds. It's memory leak in your JavaScript rather then request taking so long!");
returnjobs;}/** * Returns list of suggestions from rich:suggestionBox * * @param suggestion suggestionBox element * @param column column of suggestionBox to extract text from * @return list of suggestions */publicstaticMap<String,HtmlTableCell>getSuggestions(HtmlElementsuggestion,intcolumn){finalMap<String,HtmlTableCell>suggestions=newHashMap<String,HtmlTableCell>();finalHtmlElementsuggestElement=suggestion.getElementById(suggestion.getId()+":suggest");@SuppressWarnings("unchecked")finalDomNodeList<HtmlElement>suggestionRows=suggestElement.getElementsByTagName("tr");for(HtmlElementrow:suggestionRows){@SuppressWarnings("unchecked")finalDomNodeList<HtmlElement>cells=row.getElementsByTagName("td");finalHtmlTableCellcell=(HtmlTableCell)cells.get(column+1);suggestions.put(cell.asText(),cell);}returnsuggestions;}
publicstaticvoidexecuteAjaxReRenderedScripts(HtmlPagepage){finalDomNodeList<HtmlElement>scripts=page.getElementsByTagName("script");/** * We cannot iterate over html DomNodeList cause it depends on sibling relationship which we will modify. */finalList<HtmlElement>scriptsList=newArrayList<HtmlElement>();for(HtmlElementelement:scripts){scriptsList.add(element);}for(HtmlElementelement:scriptsList){if(element.getChildNodes().size()>1){element.removeChild(element.getFirstChild());finalDomNodesibling=element.getNextSibling();finalDomNodeparentNode=element.getParentNode();/** * Script will be executed upon inserting into DOM tree, so we removed and add it again. */if(sibling!=null){parentNode.removeChild(element);sibling.insertBefore(element);}else{parentNode.removeChild(element);parentNode.appendChild(element);}}}}