I will try to give more info of the problem.
Here's a concrete class of my modal window:
public final class GeneralLinkParametersModalWindow extends
AbstractParametersModalWindow {
private static final long serialVersionUID = -2817303037867728250L;
private WebPage originatePage;
private ReportPage newReportPage;
private final String parametersWebPageClassName;
public GeneralLinkParametersModalWindow(String id, String
parametersWebPageClassName) {
super(id, parametersWebPageClassName);
this.parametersWebPageClassName = parametersWebPageClassName;
}
@Override
protected void onOk(AjaxRequestTarget target) {
if (originatePage == null) {
throw new RuntimeException(
"GeneralLinkParametersModalWindow.onOk - originatePage
is null!!");
}
originatePage.setResponsePage(newReportPage);
}
@Override
protected Component componentToAjaxTarget() {
return null;
}
@Override
public void setReportSrcUrl(Map<String, String>
parametersPairsForReport, String reportName) {
newReportPage = new ReportPage(parametersWebPageClassName);
newReportPage.setReportSrcUrl(parametersPairsForReport, reportName);
}
public final void setOriginatePage(WebPage webPage) {
this.originatePage = webPage;
}
}
As I described in the previous post, when the user presses OK, I set a
boolean and in the callback, the onOk is called.
I managed to progress a little bit and now I have this strange problem:
I open the first time the modal window and press Cancel.
I then open the same modal, choose the values I want and then press OK.
The sequence is that when pressing OK, the setReportSrcUrl is called. Then
the close callback is called (because I also call close());
And the bug:
In the onOk, newReportPage is null for the
originatePage.setResponsePage(newReportPage);.
This is very strange for me.
Anyone knows something about it?
We use 1.3.4
On Sun, Sep 21, 2008 at 12:19 PM, Eyal Golan <[EMAIL PROTECTED]> wrote:
>
> 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
>
--
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