Hello,
I have a problem with class members in a Modal Window.
Here's my general structure of things:
-- AbstractParametersModalWindow
                                                  --
GeneralLinkParametersModalWindow
                                                  --
ReportPageParamatersModalWindow

In the parent modal window I have this:
setWindowClosedCallback(new ModalWindow.WindowClosedCallback() {
            private static final long serialVersionUID = 1L;

            public void onClose(final AjaxRequestTarget target) {
                // If not pressed ok, we don't want to make the ajax call
                if (okPressed) {
                    onOk(target);
                }
                okPressed = false;
            }
        });

The problem is with the *okPressed* class member.

The Modal uses a Page as content.
In the page there are OK and Cancel buttons.
When the user presses OK, I set the okPressed to true, do some stuff and
call the close method.
This is the OK button code:
        EurekifyAjaxButton okButton = new EurekifyAjaxButton("ok") {
            private static final long serialVersionUID = 1L;

            @Override
            protected void onError(AjaxRequestTarget target, Form form) {
                super.onError(target, form);
                target.addComponent(feedbackPanel);
            }

            @Override
            protected void onSubmit(AjaxRequestTarget target, Form form) {
                window.okPressed(getParametersPairsForReport(),
getReportName());
                window.close(target);
            }

        };

This is the okPressed method in the modal window:
    public final void okPressed(Map<String, String>
parametersPairsForReport, String reportName) {
        okPressed = true;
        setReportSrcUrl(parametersPairsForReport, reportName);
    }

For the sake of the question, it's not important how the onOk is implemented
in each sub class.

Here is how I add a link with ReportPageParamatersModalWindow:
        popupParametersWindow =
                new
ReportPageParamatersModalWindow(ReportParametersLink.POPUP_WINDOW_ID,
                        parametersWebPageClassName, this);

        add(popupParametersWindow);
        AjaxLink link = new AjaxLink(MenuItem.LINK_ID) {
            private static final long serialVersionUID = 1L;

            @Override
            public void onClick(AjaxRequestTarget target) {
                popupParametersWindow.show(target);
            }
        };
        link.addOrReplace(new Label("linktext", new
ResourceModel("Reports.showParameters")));
        add(link);

And this is the description of my problem:
When putting break point in the onClose callback, the okPressed is FALSE
even though I set it to TRUE.
I tried many options of subclassing etc.

The link with GeneralLinkParametersModalWindow works fine and the okPressed
is true.
It seems that I look at two different objects.

I tried to be as clear as possible.

Any thoughts?



-- 
Eyal Golan
[EMAIL PROTECTED]

Visit: http://jvdrums.sourceforge.net/
LinkedIn: http://www.linkedin.com/in/egolan74

P Save a tree. Please don't print this e-mail unless it's really necessary

Reply via email to