You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@wicket.apache.org by gmparker2000 <gr...@brovada.com> on 2014/01/08 15:51:30 UTC
Determine which submit buttons was pressed
I have a form with two AjaxButtons. I need to know which button was pressed
before form validation takes place. By the time the onSubmit or onError
methods on AjaxButton are called, its to late for what I need. Is there
anything that can be done to identify the button prior to the process method
of the form being called? I suppose a hidden input identifying the button
could be added to the form and altered using Javascript prior to the
request.
--
View this message in context: http://apache-wicket.1842946.n4.nabble.com/Determine-which-submit-buttons-was-pressed-tp4663550.html
Sent from the Users forum 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: Determine which submit buttons was pressed
Posted by gmparker2000 <gr...@brovada.com>.
Maybe I'm missing something but it seems to me that the submittingComponent
parameter passed to process is just an anonymously generated class that
implements IFormSubmitter. Although it is not null when process is called,
it only gives me access to the form and whether or not default form
processing is enabled. Is there someway that this can lead me to the button
that triggered the submit?
--
View this message in context: http://apache-wicket.1842946.n4.nabble.com/Determine-which-submit-buttons-was-pressed-tp4663550p4663582.html
Sent from the Users forum 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: Determine which submit buttons was pressed
Posted by Martin Grigorov <mg...@apache.org>.
Hi,
On Wed, Jan 8, 2014 at 6:14 PM, gmparker2000 <gr...@brovada.com>wrote:
> I had tried that but unfortunately at the point I'm trying to make the
> determination this call returns null.
>
>
> Form myForm = new EasyForm("myForm") {
> public void process(IFormSubmitter submittingComponent) {
>
Wicket passes the submitting component as argument to this method. ^^
> // this returns null
> IFormSubmitter btn = this.findSubmittingButton();
>
> if (btn == ...) {
> // do something before validation
> }
>
> super.process(submittingComponent);
> }
>
>
> The only way I could make this work so far is something like this:
>
> public void process(IFormSubmitter submittingComponent) {
> IFormSubmitter btn = this.findSubmittingButton();
> String qs = this.getRequest().getUrl().getQueryString();
>
> if (qs.contains("myButtonName")) {
>
Can you show us all GET and POST parameters ?
> // do something
> }
>
> super.process(submittingComponent);
> }
>
> This is ugly. Hoping there is a better way.
>
> --
> View this message in context:
> http://apache-wicket.1842946.n4.nabble.com/Determine-which-submit-buttons-was-pressed-tp4663550p4663554.html
> Sent from the Users forum 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: Determine which submit buttons was pressed
Posted by gmparker2000 <gr...@brovada.com>.
I had tried that but unfortunately at the point I'm trying to make the
determination this call returns null.
Form myForm = new EasyForm("myForm") {
public void process(IFormSubmitter submittingComponent) {
// this returns null
IFormSubmitter btn = this.findSubmittingButton();
if (btn == ...) {
// do something before validation
}
super.process(submittingComponent);
}
The only way I could make this work so far is something like this:
public void process(IFormSubmitter submittingComponent) {
IFormSubmitter btn = this.findSubmittingButton();
String qs = this.getRequest().getUrl().getQueryString();
if (qs.contains("myButtonName")) {
// do something
}
super.process(submittingComponent);
}
This is ugly. Hoping there is a better way.
--
View this message in context: http://apache-wicket.1842946.n4.nabble.com/Determine-which-submit-buttons-was-pressed-tp4663550p4663554.html
Sent from the Users forum 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: Determine which submit buttons was pressed
Posted by Martin Grigorov <mg...@apache.org>.
Hi,
See org.apache.wicket.markup.html.form.Form#findSubmittingButton
Martin Grigorov
Wicket Training and Consulting
On Wed, Jan 8, 2014 at 4:51 PM, gmparker2000 <gr...@brovada.com>wrote:
> I have a form with two AjaxButtons. I need to know which button was
> pressed
> before form validation takes place. By the time the onSubmit or onError
> methods on AjaxButton are called, its to late for what I need. Is there
> anything that can be done to identify the button prior to the process
> method
> of the form being called? I suppose a hidden input identifying the button
> could be added to the form and altered using Javascript prior to the
> request.
>
> --
> View this message in context:
> http://apache-wicket.1842946.n4.nabble.com/Determine-which-submit-buttons-was-pressed-tp4663550.html
> Sent from the Users forum 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
>
>