You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@wicket.apache.org by Brill Pappin <br...@pappin.ca> on 2009/05/25 15:30:08 UTC

Re: adjusting form model on submit with AjaxButton -- Was: closing a ModalWindow from a forms onSubmit?

There  has got to be a solution for this.

The problem with using an AjaxButton is that the onSubmit is called  
*after* the form is submitted, but since there are multiple submit  
buttons that change the model object just before submit, I need to  
adjust the model before the form is submitted.

If I use a normal Button, I can adjust the form model but can't close  
the ModalWindow since I have no ajax target.

- Brill

On 24-May-09, at 6:36 PM, Brill Pappin wrote:

> I likely could but am trying to avoid that, because then I have to  
> call it for every button in the form (there are 4 now, all set a  
> state and allow the event to propagate to the forms onSubmit().
> Is there no way to know the current context from the component itself?
>
>
> - Brill
>
> On 24-May-09, at 5:55 PM, James Carman wrote:
>
>> Can you submit the form via ajax?
>>
>> On May 24, 2009 2:08 PM, "Brill Pappin" <br...@pappin.ca> wrote:
>>
>> I have a form in a model window
>> How do I close the ModalWindow in the form's onSubmit() method  
>> without the
>> AjaxRequestTarget?
>>
>> - Brill
>


Re: adjusting form model on submit with AjaxButton -- Was: closing a ModalWindow from a forms onSubmit?

Posted by Brill Pappin <br...@pappin.ca>.
Ok, so  have resolved my issue by reorganizing and refactoring a  
complex form so as not to use submit buttons to determine final state.
However I do have one idea I didn't try (and won't at this point  
because I need to get on with things).

I remember in the bad old days of JSP, one project i was one used  
multiple buttons extensively.
When the buttons all had the same name, the one that was actually  
clicked would have its value set for the name of the input (just like  
a checkbox would).

I was thinking that you could use a Check Group (or something like it)  
to create a group of buttons, similar to what is described here:
http://wicketstuff.org/wicket13/compref/?wicket:bookmarkablePage=:org.apache.wicket.examples.compref.CheckGroupPage
A quick look at the code suggests that it would work.
You would capture the value of the buttons in your form model like any  
other input.

If i ever have time I'll write up a SubmitButtonGroup component  
(unless someone else needs it first and writes one).

- Brill

On 25-May-09, at 9:30 AM, Brill Pappin wrote:

> There  has got to be a solution for this.
>
> The problem with using an AjaxButton is that the onSubmit is called  
> *after* the form is submitted, but since there are multiple submit  
> buttons that change the model object just before submit, I need to  
> adjust the model before the form is submitted.
>
> If I use a normal Button, I can adjust the form model but can't  
> close the ModalWindow since I have no ajax target.
>
> - Brill
>
> On 24-May-09, at 6:36 PM, Brill Pappin wrote:
>
>> I likely could but am trying to avoid that, because then I have to  
>> call it for every button in the form (there are 4 now, all set a  
>> state and allow the event to propagate to the forms onSubmit().
>> Is there no way to know the current context from the component  
>> itself?
>>
>>
>> - Brill
>>
>> On 24-May-09, at 5:55 PM, James Carman wrote:
>>
>>> Can you submit the form via ajax?
>>>
>>> On May 24, 2009 2:08 PM, "Brill Pappin" <br...@pappin.ca> wrote:
>>>
>>> I have a form in a model window
>>> How do I close the ModalWindow in the form's onSubmit() method  
>>> without the
>>> AjaxRequestTarget?
>>>
>>> - Brill
>>
>