You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@wicket.apache.org by Tito <nj...@gmail.com> on 2012/01/31 13:07:19 UTC

Re: Add items and then submit a form

Hi, I'm working again on this. And I realized that I have a problem with
this method.

The problem is when I submit the form that adds items, the main form does't
keep its state. I mean if I a complete something like 'name' then click
'add item' the name desapear because it is not submitted.

Do you understand my problem?

But if I nest forms it works but the problem are validations on main form
when inner form is submitted.

Thanks in advance

Tito

On Tue, Dec 20, 2011 at 8:38 AM, Tito <nj...@gmail.com> wrote:

> Great!!
> It works ok!
>
> Thank you very much.
>
> On Tue, Dec 20, 2011 at 6:21 AM, Andrea Del Bene <ad...@ciseonweb.it>wrote:
>
>> This should not be a big deal. Wicket lets you put form submitting button
>> outside form itself. All you have to do to make it work is to pass the form
>> to component's constructor.
>>
>>
>> HTML code:
>>
>>
>> <form wicket:id="form1">
>>
>> </form>
>>
>> <form wicket:id="form2">
>> <input  type="submit" value="form2" wicket:id="submit2"/>
>>
>> </form>
>>
>> <input type="submit" value="form1"  wicket:id="submit1"/>
>>
>>
>> Java code:
>>
>>
>>
>> add(form1 = new Form("form1"){
>>           @Override
>>        protected void onSubmit() {
>>            super.onSubmit();
>>            System.out.println("form1");
>>        }
>>       });
>>
>>    add(new SubmitLink("submit1", form1));
>>
>>    Form form2;
>>
>>    add(form2 =new Form("form2"){
>>            @Override
>>            protected void onSubmit() {
>>                super.onSubmit();
>>                System.out.println("form2");
>>            }
>>       });
>>
>>    form2.add(new SubmitLink("submit2"));
>>
>>
>>
>> Button "submit1" is outside its form and you have two separated form.
>>
>>
>>
>>  I think you are right.
>>> Using an AjaxButton it works a litle more like I want.
>>>
>>> Nevertheless I still have a problem, because outer form submits inner
>>> form.
>>>
>>> In my case I think that I need two separated forms, but the problem is
>>> how
>>> to put add button y save button in the correct place. I mean, the layout
>>> is
>>> what you mentioned but the behavior is more like two separated forms.
>>> Thank you!
>>>
>>> On Mon, Dec 19, 2011 at 2:04 PM, Andrea Del Bene<ad...@ciseonweb.it>*
>>> *wrote:
>>>
>>
>>
>> ------------------------------**------------------------------**---------
>> To unsubscribe, e-mail: users-unsubscribe@wicket.**apache.org<us...@wicket.apache.org>
>> For additional commands, e-mail: users-help@wicket.apache.org
>>
>>
>

Re: Add items and then submit a form

Posted by Tito <nj...@gmail.com>.
Well, I solved the problem.
Just submitting the form that adds items by ajax in order to avoid the
reload of the entire page and keep fields of the other form.

Thanks!

Tito

On Tue, Jan 31, 2012 at 9:07 AM, Tito <nj...@gmail.com> wrote:

> Hi, I'm working again on this. And I realized that I have a problem with
> this method.
>
> The problem is when I submit the form that adds items, the main form
> does't keep its state. I mean if I a complete something like 'name' then
> click 'add item' the name desapear because it is not submitted.
>
> Do you understand my problem?
>
> But if I nest forms it works but the problem are validations on main form
> when inner form is submitted.
>
> Thanks in advance
>
> Tito
>
> On Tue, Dec 20, 2011 at 8:38 AM, Tito <nj...@gmail.com> wrote:
>
>> Great!!
>> It works ok!
>>
>> Thank you very much.
>>
>> On Tue, Dec 20, 2011 at 6:21 AM, Andrea Del Bene <ad...@ciseonweb.it>wrote:
>>
>>> This should not be a big deal. Wicket lets you put form submitting
>>> button outside form itself. All you have to do to make it work is to pass
>>> the form to component's constructor.
>>>
>>>
>>> HTML code:
>>>
>>>
>>> <form wicket:id="form1">
>>>
>>> </form>
>>>
>>> <form wicket:id="form2">
>>> <input  type="submit" value="form2" wicket:id="submit2"/>
>>>
>>> </form>
>>>
>>> <input type="submit" value="form1"  wicket:id="submit1"/>
>>>
>>>
>>> Java code:
>>>
>>>
>>>
>>> add(form1 = new Form("form1"){
>>>           @Override
>>>        protected void onSubmit() {
>>>            super.onSubmit();
>>>            System.out.println("form1");
>>>        }
>>>       });
>>>
>>>    add(new SubmitLink("submit1", form1));
>>>
>>>    Form form2;
>>>
>>>    add(form2 =new Form("form2"){
>>>            @Override
>>>            protected void onSubmit() {
>>>                super.onSubmit();
>>>                System.out.println("form2");
>>>            }
>>>       });
>>>
>>>    form2.add(new SubmitLink("submit2"));
>>>
>>>
>>>
>>> Button "submit1" is outside its form and you have two separated form.
>>>
>>>
>>>
>>>  I think you are right.
>>>> Using an AjaxButton it works a litle more like I want.
>>>>
>>>> Nevertheless I still have a problem, because outer form submits inner
>>>> form.
>>>>
>>>> In my case I think that I need two separated forms, but the problem is
>>>> how
>>>> to put add button y save button in the correct place. I mean, the
>>>> layout is
>>>> what you mentioned but the behavior is more like two separated forms.
>>>> Thank you!
>>>>
>>>> On Mon, Dec 19, 2011 at 2:04 PM, Andrea Del Bene<ad...@ciseonweb.it>
>>>> **wrote:
>>>>
>>>
>>>
>>> ------------------------------**------------------------------**
>>> ---------
>>> To unsubscribe, e-mail: users-unsubscribe@wicket.**apache.org<us...@wicket.apache.org>
>>> For additional commands, e-mail: users-help@wicket.apache.org
>>>
>>>
>>
>