Do you know about
org.apache.wicket.extensions.ajax.markup.html.modal.ModalWindow?  It
seems to do almost what you want, or at least you can look at the
source.

Cheers,
Thomas

On Dec 21, 2007 9:56 AM, thomas jaeckle <[EMAIL PROTECTED]> wrote:
>
> Hi again.
> I found a solution, but it isn't very nice:
>
> First I implemented a AjaxForm like the AjaxButton is implemented (why isn't
> there a AjaxForm delivered with Wicket?):
>
> public abstract class AjaxForm extends Form
> {
>    public AjaxForm(String id)
>    {
>       super(id);
>
>       add(new AjaxFormSubmitBehavior(this, "onsubmit")
>       {
>          private static final long serialVersionUID = 1L;
>
>          protected void onSubmit(AjaxRequestTarget target)
>          {
>             AjaxForm.this.onSubmit(target);
>          }
>
>          protected void onError(AjaxRequestTarget target)
>          {
>             AjaxForm.this.onError(target);
>          }
>
>          protected CharSequence getEventHandler()
>          {
>             return new
> AppendingStringBuffer(super.getEventHandler()).append("; return false;");
>          }
>
>          protected IAjaxCallDecorator getAjaxCallDecorator()
>          {
>             return AjaxForm.this.getAjaxCallDecorator();
>          }
>       });
>    }
>
>    protected IAjaxCallDecorator getAjaxCallDecorator()
>    {
>       return null;
>    }
>
>    protected void onError(AjaxRequestTarget target)
>    {
>    }
>
>    protected abstract void onSubmit(AjaxRequestTarget target);
> }
>
>
>
> Now I can do:
>
> AjaxForm form = new AjaxForm("form")
> {
>    private static final long serialVersionUID = 1L;
>
>    protected void onSubmit(AjaxRequestTarget target)
>    {
>       PopupSettings popupSettings = new PopupSettings(PageMap.forName("id_"
> + textField.getConvertedInput()),
> PopupSettings.RESIZABLE).setHeight(768).setWidth(1024);
>
>       PageParameters tmpParameters = new PageParameters();
>       tmpParameters.add("id", (String)
> partnerSearchTextField.getConvertedInput());
>
>        popupSettings.setTarget("'" + urlFor(PrBrsPage.class,
> tmpParameters).toString() + "'");
>
>        final String orgPopupString = popupSettings.getPopupJavaScript();
>        int i = orgPopupString.indexOf("return false;");
>        String popupString = popupSettings.getPopupJavaScript().substring(0,
> i-1);
>
>        if (target != null)
>        {
>           target.appendJavascript(popupString);
>           // focusComponent(null) to prevent that the main window regains
> focus
>           target.focusComponent(null);
>        }
>    }
> };
>
>
> But I don't really like this solution. If someone has an idea how to make
> this nicer, please speak ;)
>
> regards Thomas
> --
> View this message in context: 
> http://www.nabble.com/How-to-open-a-popup-in-onSubmit%28%29-of-a-Form-tp14435932p14452239.html
> Sent from the Wicket - User mailing list archive at Nabble.com.
>
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: [EMAIL PROTECTED]
> For additional commands, e-mail: [EMAIL PROTECTED]
>
>

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

Reply via email to