protected final String getWindowOpenJavaScript()

in src/main/java/org/apache/directory/fortress/web/modal/ModalWindow.java [1015:1124]


    protected final String getWindowOpenJavaScript()
    {
        JSONObject settings = new JSONObject();

        settings.put("minWidth", getMinimalWidth());
        settings.put("minHeight", getMinimalHeight());
        settings.put("className", getCssClassName());
        settings.put("width", getInitialWidth());

        if ((isUseInitialHeight() == true) || (isCustomComponent() == false))
        {
            settings.put("height", getInitialHeight());
        }
        else
        {
            // WICKET-6613 null would remove the key, so use false instead
            settings.put("height", false);
        }

        settings.put("resizable", isResizable());

        if (isResizable() == false)
        {
            settings.put("widthUnit", getWidthUnit());
            settings.put("heightUnit", getHeightUnit());
        }

        if (isCustomComponent() == false)
        {
            Page page = createPage();
            if (page == null)
            {
                throw new WicketRuntimeException("Error creating page for modal dialog.");
            }
            CharSequence pageUrl;
            RequestCycle requestCycle = RequestCycle.get();

            page.getSession().getPageManager().touchPage(page);
            if (page.isPageStateless())
            {
                pageUrl = requestCycle.urlFor(page.getClass(), page.getPageParameters());
            }
            else
            {
                IRequestHandler handler = new RenderPageRequestHandler(new PageProvider(page));
                pageUrl = requestCycle.urlFor(handler);
            }

            settings.put("src", pageUrl);
        }
        else
        {
            settings.put("element", new JSONFunction("document.getElementById(\"" + getContentMarkupId() + "\")"));
        }

        if (getCookieName() != null)
        {
            settings.put("cookieId", getCookieName());
        }

        String title = getTitle() != null ? getTitle().getObject() : null;
        if (title != null)
        {
            settings.put("title", getDefaultModelObjectAsString(title));
        }

        if (getMaskType() == MaskType.TRANSPARENT)
        {
            settings.put("mask", "transparent");
        }
        else if (getMaskType() == MaskType.SEMI_TRANSPARENT)
        {
            settings.put("mask", "semi-transparent");
        }

        settings.put("autoSize", autoSize);

        settings.put("unloadConfirmation", showUnloadConfirmation());

        // set true if we set a windowclosedcallback
        boolean haveCloseCallback = false;

        // in case user is interested in window close callback or we have a pagemap to clean attach
        // notification request
        if (windowClosedCallback != null)
        {
            WindowClosedBehavior behavior = getBehaviors(WindowClosedBehavior.class).get(0);
            settings.put("onClose", new JSONFunction("function() { " + behavior.getCallbackScript() + " }"));

            haveCloseCallback = true;
        }

        // in case we didn't set windowclosecallback, we need at least callback on close button, to
        // close window property (thus cleaning the shown flag)
        if ((closeButtonCallback != null) || (haveCloseCallback == false))
        {
            CloseButtonBehavior behavior = getBehaviors(CloseButtonBehavior.class).get(0);
            settings.put("onCloseButton", new JSONFunction("function() { " + behavior.getCallbackScript() + "; return false; }"));
        }

        postProcessSettings(settings);

        AppendingStringBuffer buffer = new AppendingStringBuffer(500);
        buffer.append("var settings = ");
        buffer.append(settings.toString());
        buffer.append(";");

        buffer.append(getShowJavaScript());
        return buffer.toString();
    }