[Wicket-user] Refresh page after form submit within ModalWindow

2007-06-26 Thread Tauren Mills
I have the following hierarchy:

MyPage
  MyDataView
  ModalWindow (containing a MyModalPage)
MyModalPage
  MyModalForm
AjaxSubmitLink

The modal window is used to add new items to MyDataView.

If there are errors when the form is submitted, the modal window
should stay open with feedback inside it.  I have that working.

If the submit is successful, I want MyDataView on MyPage to refresh.
I see two ways to do that:

1.  Somehow refresh the entire page with setResponsePage or some other means.
2.  Use AJAX to refresh just MyDataView

When I tried #1, the modal window didn't close and the contents of it
became the outer page (myPage).  So the modal windows contained the
content of the outer page.

add(new AjaxSubmitLink(submit,this)
{
protected void onSubmit(AjaxRequestTarget target, Form form) {
target.addComponent(feedback);
window.close(target);
myPage.setResponsePage(myPage);
}
});

When I tried #2, the form submitted properly, but myDataView didn't refresh.

add(new AjaxSubmitLink(submit,this)
{
protected void onSubmit(AjaxRequestTarget target, Form form) {
target.addComponent(feedback);
target.addComponent(myPage.getMyDataView());
window.close(target);
}
});

I don't know if myPage.getMyDataView() will work in this way since
myPage is private field of MyModalPage that accesses a getter for a
private field of MyPage called myDataView. I did
setOutputMarkupId(true) on it.

What is the best way to accomplish this? Below is the pertinent code.

Thanks,
Tauren



public class MyPage extends UserBasePage {
private DataView myDataView;

public MyPage() {
super();
MyDataProvider dp = new MyDataProvider();
myDataView = new DataView(dataview, dp)
{
 
};
myDataView.setOutputMarkupId(true);
myDataView.setItemsPerPage(40);
add(myDataView);

final ModalWindow newService;
add(newService = new ModalWindow(newService));
newService.setPageMapName(newService);
newService.setCookieName(newService);
newService.setPageCreator(new ModalWindow.PageCreator()
{
public Page createPage()
{
return new MyModalPage(MyPage.this, newService);
}
});
   }
   public DataView getMyDataView() ...
   public void setMyDataView(DataView myDataView) ...
}

public class MyModalPage extends WebPage {

private FeedbackPanel feedback;
private MyPage myPage;
private ModalWindow window;

public MyModalPage(final MyPage myPage, final ModalWindow window)
{
this.myPage = myPage;
this.window = window;
feedback = new FeedbackPanel(feedback);
feedback.setOutputMarkupId(true);
add(feedback);
Form form = new MyModalForm(form);
add(form);
}

public class MyModalForm extends Form {
public MyModalForm(String id){
  ...
add(new AjaxSubmitLink(submit,this)
{
@Override
protected void onSubmit(AjaxRequestTarget target, Form form) {
target.addComponent(feedback);
target.addComponent(myPage.getMyDataView());
window.close(target);
}

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

-
This SF.net email is sponsored by DB2 Express
Download DB2 Express C - the FREE version of DB2 express and take
control of your XML. No limits. Just data. Click to get it now.
http://sourceforge.net/powerbar/db2/
___
Wicket-user mailing list
Wicket-user@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/wicket-user


Re: [Wicket-user] Refresh page after form submit within ModalWindow

2007-06-26 Thread Timo Rantalaiho
On Tue, 26 Jun 2007, Tauren Mills wrote:
 2.  Use AJAX to refresh just MyDataView

Have you tried adding a placeholder container around your 
DataView and refreshing that with ajax instead?  I'm not 
sure but I think that Repeaters used to need that if you
wanted to update them via AJAX.

Have you checked that the DataProvider of your DataView gets
called (and returns the new item)?

- Timo

-- 
Timo Rantalaiho   
Reaktor Innovations OyURL: http://www.ri.fi/ 

-
This SF.net email is sponsored by DB2 Express
Download DB2 Express C - the FREE version of DB2 express and take
control of your XML. No limits. Just data. Click to get it now.
http://sourceforge.net/powerbar/db2/
___
Wicket-user mailing list
Wicket-user@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/wicket-user


Re: [Wicket-user] Refresh page after form submit within ModalWindow

2007-06-26 Thread Tauren Mills
Timo,

Good idea, but that doesn't work either.  The Ajax Debug window in
MyPage shows nothing being sent to do.  Note this is in Wicket 1.2.6.

INFO:
INFO: Initiating Ajax GET request on
/db/app?wicket:interface=:6:newService::IBehaviorListenerwicket:behaviorId=1random=0.9353265386317773
INFO: Invoking pre-call handler(s)...
INFO: Received ajax response (69 characters)
INFO:
?xml version=1.0 encoding=UTF-8?ajax-response/ajax-response
INFO: Response parsed. Now invoking steps...
INFO: Response processed successfully.
INFO: Invoking post-call handler(s)...

If there is nothing in the ajax response to do, then the problem
shouldn't have to do with the dataview/dataprovider, should it?

Any other ideas?

Tauren



On 6/26/07, Timo Rantalaiho [EMAIL PROTECTED] wrote:
 On Tue, 26 Jun 2007, Tauren Mills wrote:
  2.  Use AJAX to refresh just MyDataView

 Have you tried adding a placeholder container around your
 DataView and refreshing that with ajax instead?  I'm not
 sure but I think that Repeaters used to need that if you
 wanted to update them via AJAX.

 Have you checked that the DataProvider of your DataView gets
 called (and returns the new item)?

 - Timo

 --
 Timo Rantalaiho
 Reaktor Innovations OyURL: http://www.ri.fi/ 

 -
 This SF.net email is sponsored by DB2 Express
 Download DB2 Express C - the FREE version of DB2 express and take
 control of your XML. No limits. Just data. Click to get it now.
 http://sourceforge.net/powerbar/db2/
 ___
 Wicket-user mailing list
 Wicket-user@lists.sourceforge.net
 https://lists.sourceforge.net/lists/listinfo/wicket-user


-
This SF.net email is sponsored by DB2 Express
Download DB2 Express C - the FREE version of DB2 express and take
control of your XML. No limits. Just data. Click to get it now.
http://sourceforge.net/powerbar/db2/
___
Wicket-user mailing list
Wicket-user@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/wicket-user


Re: [Wicket-user] Refresh page after form submit within ModalWindow

2007-06-26 Thread Tauren Mills
I solved the problem...  In case anyone else has a similar issue in
the future, the target.addComponent needs to be set in MyPage, not in
MyModalPage.  Something like this needs to be done:

newService.setWindowClosedCallback(new
ModalWindow.WindowClosedCallback()
{
public void onClose(AjaxRequestTarget target)
{
target.addComponent(container);
}
});

Note that I'm targeting a container around MyDataView. This code was
in the ModalWindow example, I just hadn't got it right.  It works now.

Thanks for the help!
Tauren


On 6/26/07, Tauren Mills [EMAIL PROTECTED] wrote:
 Timo,

 Good idea, but that doesn't work either.  The Ajax Debug window in
 MyPage shows nothing being sent to do.  Note this is in Wicket 1.2.6.

 INFO:
 INFO: Initiating Ajax GET request on
 /db/app?wicket:interface=:6:newService::IBehaviorListenerwicket:behaviorId=1random=0.9353265386317773
 INFO: Invoking pre-call handler(s)...
 INFO: Received ajax response (69 characters)
 INFO:
 ?xml version=1.0 encoding=UTF-8?ajax-response/ajax-response
 INFO: Response parsed. Now invoking steps...
 INFO: Response processed successfully.
 INFO: Invoking post-call handler(s)...

 If there is nothing in the ajax response to do, then the problem
 shouldn't have to do with the dataview/dataprovider, should it?

 Any other ideas?

 Tauren



 On 6/26/07, Timo Rantalaiho [EMAIL PROTECTED] wrote:
  On Tue, 26 Jun 2007, Tauren Mills wrote:
   2.  Use AJAX to refresh just MyDataView
 
  Have you tried adding a placeholder container around your
  DataView and refreshing that with ajax instead?  I'm not
  sure but I think that Repeaters used to need that if you
  wanted to update them via AJAX.
 
  Have you checked that the DataProvider of your DataView gets
  called (and returns the new item)?
 
  - Timo
 
  --
  Timo Rantalaiho
  Reaktor Innovations OyURL: http://www.ri.fi/ 
 
  -
  This SF.net email is sponsored by DB2 Express
  Download DB2 Express C - the FREE version of DB2 express and take
  control of your XML. No limits. Just data. Click to get it now.
  http://sourceforge.net/powerbar/db2/
  ___
  Wicket-user mailing list
  Wicket-user@lists.sourceforge.net
  https://lists.sourceforge.net/lists/listinfo/wicket-user
 


-
This SF.net email is sponsored by DB2 Express
Download DB2 Express C - the FREE version of DB2 express and take
control of your XML. No limits. Just data. Click to get it now.
http://sourceforge.net/powerbar/db2/
___
Wicket-user mailing list
Wicket-user@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/wicket-user