Buggy code:
public class ModalWindow extends Panel { private static final long serialVersionUID = 1L ; public static final String CSS_CLASS_BLUE = "w_blue" ; public static final String CSS_CLASS_GRAY = "w_silver" ; private static ResourceReference JAVASCRIPT = new JavascriptResourceReference ( ModalWindow . class , "res//modal.js" ) ; private static ResourceReference CSS = new CompressedResourceReference ( ModalWindow . class , "res//modal.css" ) ; private boolean shown = false ; private final boolean renderScript = false ; private WebMarkupContainer empty ; private int minimalWidth = 200 ; private int minimalHeight = 200 ; private String cssClassName = ModalWindow . CSS_CLASS_BLUE ; private int initialWidth = 600 ; private int initialHeight = 400 ; private boolean useInitialHeight = true ; private boolean resizable = true ; private String widthUnit = "px" ; private String heightUnit = "px" ; private String cookieName ; private IModel < String > title = null ; private ModalWindow . MaskType maskType = ModalWindow . MaskType . SEMI_TRANSPARENT ; private ModalWindow . PageCreator pageCreator = null ; private ModalWindow . CloseButtonCallback closeButtonCallback = null ; private ModalWindow . WindowClosedCallback windowClosedCallback = null ; public static interface PageCreator extends IClusterable { public Page createPage ( ) { } } public static interface CloseButtonCallback extends IClusterable { public boolean onCloseButtonClicked ( AjaxRequestTarget target ) { } } public static interface WindowClosedCallback extends IClusterable { public void onClose ( AjaxRequestTarget target ) { } } public ModalWindow ( final String id ) { } public ModalWindow ( final String id , final IModel < ? > model ) { } private void init ( ) { } @ Override public void renderHead ( IHeaderResponse response ) { } public boolean isShown ( ) { } public ModalWindow setPageCreator ( final ModalWindow . PageCreator creator ) { } public ModalWindow setCloseButtonCallback ( final ModalWindow . CloseButtonCallback callback ) { } public ModalWindow setWindowClosedCallback ( final ModalWindow . WindowClosedCallback callback ) { } public void show ( final AjaxRequestTarget target ) { if ( ( shown ) == false ) { getContent ( ) . setVisible ( true ) ; <START_BUG> target . addComponent ( this ) ; <END_BUG> target . appendJavascript ( getWindowOpenJavascript ( ) ) ; shown = true ; } } public static final void closeCurrent ( AjaxRequestTarget target ) { } public void close ( final AjaxRequestTarget target ) { } protected CharSequence getShowJavascript ( ) { } private static String getCloseJavacriptInternal ( ) { } protected String getCloseJavacript ( ) { } public String getContentId ( ) { } public ModalWindow setMinimalWidth ( int minimalWidth ) { } public int getMinimalWidth ( ) { } public ModalWindow setMinimalHeight ( int minimalHeight ) { } public int getMinimalHeight ( ) { } public ModalWindow setCssClassName ( String cssClassName ) { } public String getCssClassName ( ) { } public ModalWindow setInitialWidth ( int initialWidth ) { } public int getInitialWidth ( ) { } public ModalWindow setInitialHeight ( int initialHeight ) { } public int getInitialHeight ( ) { } public ModalWindow setUseInitialHeight ( boolean useInitialHeight ) { } public boolean isUseInitialHeight ( ) { } public ModalWindow setResizable ( boolean resizable ) { } public boolean isResizable ( ) { } public ModalWindow setWidthUnit ( String widthUnit ) { } public String getWidthUnit ( ) { } public ModalWindow setHeightUnit ( String heightUnit ) { } public String getHeightUnit ( ) { } public ModalWindow setCookieName ( String cookieName ) { } public String getCookieName ( ) { } public ModalWindow setTitle ( String title ) { } public ModalWindow setTitle ( IModel < String > title ) { } public IModel < String > getTitle ( ) { } public static final class MaskType extends EnumeratedType { private static final long serialVersionUID = 1L ; public static final ModalWindow . MaskType TRANSPARENT = new ModalWindow . MaskType ( "TRANSPARENT" ) ; public static final ModalWindow . MaskType SEMI_TRANSPARENT = new ModalWindow . MaskType ( "SEMI_TRANSPARENT" ) ; public MaskType ( String name ) { } } public ModalWindow setMaskType ( ModalWindow . MaskType mask ) { } public ModalWindow . MaskType getMaskType ( ) { } private Page createPage ( ) { } @ Override protected void onBeforeRender ( ) { } protected boolean makeContentVisible ( ) { } @ Override protected void onComponentTag ( final ComponentTag tag ) { } protected final Component getContent ( ) { } protected boolean isCustomComponent ( ) { } @ Override public void remove ( Component component ) { } public ModalWindow setContent ( final Component component ) { } private class WindowClosedBehavior extends AbstractDefaultAjaxBehavior { private static final long serialVersionUID = 1L ; @ Override protected void respond ( AjaxRequestTarget target ) { } @ Override protected CharSequence getCallbackScript ( ) { } } private class CloseButtonBehavior extends AbstractDefaultAjaxBehavior { private static final long serialVersionUID = 1L ; @ Override protected void respond ( AjaxRequestTarget target ) { } @ Override protected IAjaxCallDecorator getAjaxCallDecorator ( ) { } @ Override protected CharSequence getCallbackScript ( ) { } } private String getContentMarkupId ( ) { } private String escapeQuotes ( String string ) { } protected final String getWindowOpenJavascript ( ) { } private void appendAssignment ( final AppendingStringBuffer buffer , final CharSequence key , final int value ) { } private void appendAssignment ( final AppendingStringBuffer buffer , final CharSequence key , final boolean value ) { } private void appendAssignment ( final AppendingStringBuffer buffer , final CharSequence key , final CharSequence value ) { } protected AppendingStringBuffer postProcessSettings ( AppendingStringBuffer settings ) { } @ Override protected void onDetach ( ) { } }

Fix:
target . add ( this ) ;