You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@wicket.apache.org by jensiator <je...@megasol.se> on 2009/03/05 12:25:34 UTC

Callbacks with abstract method in ModalWindow

Hi. Im having a problem with the modalwindow again. It's probably my code so
I'll try to explain what I doing.

I have a Panel that I want to reuse. It's a panel with a form where you can
update som data. Because it will be used by different pages with Ajax
Behavior I want a to add 
a callback when the Panel form is commited.  

So the Panels form contains a AjaxButton where I can handle the onSubmit
method. The Panel is abstract with the abstract method
onFinished(AjaxRequestTarget target). 
Looks something like this:

public abstract class CallBackPanel extends Panel {
  public CallBackPanel(String id) {
    ...
    add(form);
    AjaxButton saveButton = new AjaxButton("savebutton", form) {
      //Also override onError
			
			@Override
			protected void onSubmit(AjaxRequestTarget pTarget,
org.apache.wicket.markup.html.form.Form<?> pForm) {
			   ... 
			   onFinished(pTarget);
			}
			
    }
    form.add(saveButton);
    //also adds a cancel button 
    ...
  }

  protected abstract void onFinished(AjaxRequestTarget pTarget);
}

I got some problems with this Panel. If I add it as a Panel in a ModalWindow
with the setContent method the callback method 'onFinished' is able to
update the 
components in the page that use the it. 
But if I add the panel to a Page and then use the ModelWindow.setPageCreator
method the callback method 'onFinished' wont update the components. 
Ex (in my page that uses the CallBackPanel):

        ...
        public Page createPage() {
					ModalContentPage mcp = new ModalContentPage();
					mcp.add(new CallBackPanel("thepanel"){
					    @Override
              protected void onFinished(AjaxRequestTarget pTarget){
                modalWindow.close(pTarget);
                pTarget.addComponent(myPageComponentThatNeedsUpdating);
//myPageComponentThatNeedsUpdating is set to final
              }
          );
					return mcp;
				}
				...

The method inFinished is running but myPageComponentThatNeedsUpdating is not
updated. 

Should I avoid doing solution like abstract CallBackPanel when morking with
modalwindows?

Or is it something with the AjaxRequestTarget that I missed? 

Jens Alenius
-- 
View this message in context: http://www.nabble.com/Callbacks-with-abstract-method-in-ModalWindow-tp22349647p22349647.html
Sent from the Wicket - User mailing list archive at Nabble.com.


---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@wicket.apache.org
For additional commands, e-mail: users-help@wicket.apache.org


Re: Callbacks with abstract method in ModalWindow

Posted by jensiator <je...@megasol.se>.
It might have something to do with which Page the AjaxRequestTarget belongs
to. The AjaxRequestTarget from the Ajaxbutton in the CallBackPanel belong to
ModalContentPage. Not the Page that Uses the ModalWindow. AnyOne have a
explanation?
Jens

-- 
View this message in context: http://www.nabble.com/Callbacks-with-abstract-method-in-ModalWindow-tp22349647p22351024.html
Sent from the Wicket - User mailing list archive at Nabble.com.


---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@wicket.apache.org
For additional commands, e-mail: users-help@wicket.apache.org