IHeaderResponse.renderOnUnLoadJavascript(String javascript); ------------------------------------------------------------
Key: WICKET-480 URL: https://issues.apache.org/jira/browse/WICKET-480 Project: Wicket Issue Type: New Feature Components: wicket Affects Versions: 1.3 Reporter: Martin Funk Priority: Minor Where there is a renderOnLoadJavascript there ought to be a renderOnUnLoadJavascript too. This is all just copy past, so it's a little smelly. Beyond that I wouldn't mind to be able to specify which element an event should be added. Index: wicket/src/main/java/org/apache/wicket/markup/html/internal/HeaderResponse.java =================================================================== --- wicket/src/main/java/org/apache/wicket/markup/html/internal/HeaderResponse.java (Revision 529942) +++ wicket/src/main/java/org/apache/wicket/markup/html/internal/HeaderResponse.java (Arbeitskopie) @@ -197,4 +197,19 @@ } } + /** + * @see org.apache.wicket.markup.html.IHeaderResponse#renderOnUnLoadJavascript(java.lang.String) + */ + public void renderOnUnLoadJavascript(String javascript) + { + List token = Arrays.asList(new Object[] { "javascript-event", "unload", javascript }); + if (wasRendered(token) == false) + { + renderJavascriptReference(WicketEventReference.INSTANCE); + JavascriptUtils.writeJavascript(getResponse(), + "Wicket.Event.add(window, \"unload\", function() { " + javascript + ";});"); + markRendered(token); + } + } + } Index: wicket/src/main/java/org/apache/wicket/markup/html/IHeaderResponse.java =================================================================== --- wicket/src/main/java/org/apache/wicket/markup/html/IHeaderResponse.java (Revision 529942) +++ wicket/src/main/java/org/apache/wicket/markup/html/IHeaderResponse.java (Arbeitskopie) @@ -174,4 +174,11 @@ * @param javascript */ public void renderOnLoadJavascript(String javascript); + + /** + * Renders javascript that is executed after the page is unloaded. + * + * @param javascript + */ + public void renderOnUnLoadJavascript(String javascript); } -- This message is automatically generated by JIRA. - You can reply to this email to add a comment to the issue online.