Re: How to open a popup in onSubmit() of a Form

2007-12-21 Thread thomas jaeckle

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]



Re: How to open a popup in onSubmit() of a Form

2007-12-21 Thread Thomas Kappler
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]



Re: How to open a popup in onSubmit() of a Form

2007-12-21 Thread thomas jaeckle



Thomas Kappler-2 wrote:
 
 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
 
Thanks for the tip.
But at this place I don't want a ModalWindow, a want a normal popup.
And my problem would also remain with a ModalWindow: how can I open a new
ModalWindow in onSubmit() of a form?

Thomas
-- 
View this message in context: 
http://www.nabble.com/How-to-open-a-popup-in-onSubmit%28%29-of-a-Form-tp14435932p14454415.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]



How to open a popup in onSubmit() of a Form

2007-12-20 Thread thomas jaeckle

Hello.

I am trying to open a popup in onSubmit() of a form.
The form is simple: it has a TextField and a Button. 
When it is submitted the value from the TextField shall become a
PageParameter for the popup and it shall be used in PageMap.forName(...) as
identifier (so for equal values the created Pages are loaded in the same
popup).

I only know how to open a Popup in a static way - with a Link that knows at
Page creation time what popup it should load and with which PageParameters.

I came up with something like that:

Form form = new Form(form)
{
  protected void onSubmit()
  {
PopupSettings popupSettings = new PopupSettings(PageMap.forName(id_
  + textField.getConvertedInput())).setHeight(768).setWidth(1024);

System.out.println(popupSettings.getPopupJavaScript());

PageParameters parameters = new PageParameters();
parameters.add(id, (String)textField.getConvertedInput());

// TODO ** open the Popup here with the pageParameters
  }
};

But I don't know if this is even the right direction.
Is this even possible?


regards Thomas
-- 
View this message in context: 
http://www.nabble.com/How-to-open-a-popup-in-onSubmit%28%29-of-a-Form-tp14435932p14435932.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]