Re: Strange behavior withe Modal Window

2008-09-22 Thread Eyal Golan
I thought taking out all state from the modal window to the page it is
holding.
It is very strange:
When the user presses OK in a form that in the page, i construct a new
instance (of WebPage).
When the close callback is initiated, the instance that was created is null.

Any thoughts?
I am on this for a few days already ...

-- 
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


Re: Strange behavior withe Modal Window

2008-09-22 Thread Daan van Etten

Hi,

You can try using abstract methods. I have made an example with demo  
project here: http://stuq.nl/weblog/2008-06-05/wicket-how-to-write-a-reusable-modal-window-popup


Regards,

Daan


On 22 sep 2008, at 10:41, Eyal Golan wrote:


I thought taking out all state from the modal window to the page it is
holding.
It is very strange:
When the user presses OK in a form that in the page, i construct a new
instance (of WebPage).
When the close callback is initiated, the instance that was created  
is null.


Any thoughts?
I am on this for a few days already ...

--
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



-
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]



Re: Strange behavior withe Modal Window

2008-09-22 Thread Eyal Golan
Thanks,
I did something similar but with Page and not panel.
The problem was keeping state in the page that was created in the
PageCreator.
I will soon post here (or in a blog) my solution.

Eyal

On Mon, Sep 22, 2008 at 12:03 PM, Daan van Etten [EMAIL PROTECTED] wrote:

 Hi,

 You can try using abstract methods. I have made an example with demo
 project here:
 http://stuq.nl/weblog/2008-06-05/wicket-how-to-write-a-reusable-modal-window-popup

 Regards,

 Daan



 On 22 sep 2008, at 10:41, Eyal Golan wrote:

  I thought taking out all state from the modal window to the page it is
 holding.
 It is very strange:
 When the user presses OK in a form that in the page, i construct a new
 instance (of WebPage).
 When the close callback is initiated, the instance that was created is
 null.

 Any thoughts?
 I am on this for a few days already ...

 --
 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



 -
 To unsubscribe, e-mail: [EMAIL PROTECTED]
 For additional commands, e-mail: [EMAIL PROTECTED]




-- 
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


Strange behavior withe Modal Window

2008-09-21 Thread Eyal Golan
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(MapString, 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


Re: Strange behavior withe Modal Window

2008-09-21 Thread Eyal Golan
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(MapString, 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(MapString, 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