Buggy code:
public class DatePicker extends AbstractBehavior implements IHeaderContributor { private static final class UnableToDetermineFormatException extends WicketRuntimeException { private static final long serialVersionUID = 1L ; public UnableToDetermineFormatException ( ) { } } private static final long serialVersionUID = 1L ; private Component component ; public DatePicker ( ) { } public void bind ( Component component ) { } public void onRendered ( Component component ) { } public void renderHead ( IHeaderResponse response ) { response . renderJavascriptReference ( new JavascriptResourceReference ( YuiLib . class , "yahoo.js" ) ) ; response . renderJavascriptReference ( new JavascriptResourceReference ( YuiLib . class , "event.js" ) ) ; response . renderJavascriptReference ( new JavascriptResourceReference ( YuiLib . class , "dom.js" ) ) ; response . renderJavascriptReference ( new JavascriptResourceReference ( DatePicker . class , "calendar.js" ) ) ; response . renderCSSReference ( new CompressedResourceReference ( DatePicker . class , "assets//calendar.css" ) ) ; response . renderJavascriptReference ( new JavascriptResourceReference ( DatePicker . class , "wicket-date.js" ) ) ; Map variables = new HashMap ( ) ; String widgetId = getComponentMarkupId ( ) ; variables . put ( "widgetId" , widgetId ) ; variables . put ( "datePattern" , getDatePattern ( ) ) ; variables . put ( "fireChangeEvent" , Boolean . valueOf ( notifyComponentOnDateSelected ( ) ) ) ; variables . put ( "alignWithIcon" , Boolean . valueOf ( alignWithIcon ( ) ) ) ; Properties p = new Properties ( ) ; configureWidgetProperties ( p ) ; StringBuffer calendarInit = new StringBuffer ( ) ; for ( Iterator i = p . entrySet ( ) . iterator ( ) ; i . hasNext ( ) ; ) { Map . Entry entry = ( ( Map . Entry ) ( i . next ( ) ) ) ; calendarInit . append ( entry . getKey ( ) ) ; Object value = entry . getValue ( ) ; if ( value instanceof CharSequence ) { calendarInit . append ( ":\"" ) ; calendarInit . append ( value ) ; calendarInit . append ( "\"" ) ; } else if ( value instanceof CharSequence [ ] ) { calendarInit . append ( ":[" ) ; CharSequence [ ] valueArray = ( ( CharSequence [ ] ) ( value ) ) ; for ( int j = 0 ; j < ( valueArray . length ) ; j ++ ) { CharSequence tmpValue = valueArray [ j ] ; calendarInit . append ( "\"" ) ; calendarInit . append ( tmpValue ) ; calendarInit . append ( "\"" ) ; if ( j < ( ( valueArray . length ) - 1 ) ) { calendarInit . append ( "," ) ; } } calendarInit . append ( "]" ) ; } else { calendarInit . append ( ":" ) ; calendarInit . append ( value ) ; } if ( i . hasNext ( ) ) { calendarInit . append ( "," ) ; } } variables . put ( "calendarInit" , calendarInit . toString ( ) ) ; org . apache . wicket . util . template . TextTemplateHeaderContributor . forJavaScript ( DatePicker . class , "DatePicker.js" , org . apache . wicket . model . Model . valueOf ( variables ) ) . renderHead ( response ) ; StringBuffer initBuffer = new StringBuffer ( ) ; initBuffer . append ( "init" ) ; initBuffer . append ( ( widgetId + "DpJs" ) ) ; initBuffer . append ( "();" ) ; <START_BUG> response . renderOnLoadJavascript ( initBuffer . toString ( ) ) ; <END_BUG> } private final void checkComponentProvidesDateFormat ( Component component ) { } protected boolean alignWithIcon ( ) { } protected void appendToInit ( String markupId , String javascriptId , String javascriptWidgetId , StringBuffer b ) { } protected void configureWidgetProperties ( Map widgetProperties ) { } protected final String getComponentMarkupId ( ) { } protected String getDatePattern ( ) { } protected final String getIconId ( ) { } protected String getIconStyle ( ) { } protected CharSequence getIconUrl ( ) { } protected boolean notifyComponentOnDateSelected ( ) { } }

Fix:
response . renderOnDomReadyJavascript ( initBuffer . toString ( ) ) ;