Trigger ajax-form submit when changing tabs

2008-01-17 Thread Steffen Fritzsche
Hi,

I have the following problem. I created a three individual forms each
within its own Tab (implementing AbstractTab). Each is submitted via
ajax according to the Ajax-FormPage example. All forms are backed by the
same Model-Object representing a simple Product wrapped in a
BoundCompoundPropertyModel.

On the surrounding page I have a forth form just with a submit button.
This form refers to the same Product-Object and when the button is
clicked it performs some action cleans up my Product Object and persists
it via JPA.

This is working so far, but currently I have to hit my ajax-submit
button always before switching between each of the three real forms
using the tabs.

Is there an elagant solution to trigger this ajax submit and validating
the form elements of the currently active form when the user clicks on
one of the other form-tabs. So that I do not need a visible ajax-submit
button anymore ...

Steffen


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



AW: Trigger ajax-form submit when changing tabs

2008-01-17 Thread Stefan Lindner
Once ago in Wicket 2.0 there was a static method

VAjaxFormValidatingFeedback.addToFormComponent(this, 
your field, ClientEvent.CHANGE);

I remember that there was a method to do this for all fiels in a form but I 
dont' remember exectly. But VAjaxFormValidatingFeedback wild be a good starting 
point.

Stefan

-Ursprüngliche Nachricht-
Von: Steffen Fritzsche [mailto:[EMAIL PROTECTED] 
Gesendet: Donnerstag, 17. Januar 2008 13:21
An: users@wicket.apache.org
Betreff: Trigger ajax-form submit when changing tabs

Hi,

I have the following problem. I created a three individual forms each within 
its own Tab (implementing AbstractTab). Each is submitted via ajax according to 
the Ajax-FormPage example. All forms are backed by the same Model-Object 
representing a simple Product wrapped in a BoundCompoundPropertyModel.

On the surrounding page I have a forth form just with a submit button.
This form refers to the same Product-Object and when the button is clicked it 
performs some action cleans up my Product Object and persists it via JPA.

This is working so far, but currently I have to hit my ajax-submit
button always before switching between each of the three real forms using the 
tabs.

Is there an elagant solution to trigger this ajax submit and validating the 
form elements of the currently active form when the user clicks on one of the 
other form-tabs. So that I do not need a visible ajax-submit button anymore ...

Steffen


-
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: Trigger ajax-form submit when changing tabs

2008-01-17 Thread Fabio Fioretti
If I understand your problem correctly, you could override the
newLink() method of the AjaxTabbedPanel to return an AjaxSubmitLink
instead. Something like the following:

tabPanel = new AjaxTabbedPanel(tabs, tabs){
@Override
protected WebMarkupContainer newLink(String linkId, final int index) {
return new AjaxSubmitLink(linkId, yourForm) {
@Override
protected void onSubmit(AjaxRequestTarget target, Form form) {
setSelectedTab(index);
if (target != null) {
target.addComponent(tabPanel);
}
onAjaxUpdate(target);
}

@Override
protected void onError(AjaxRequestTarget target, Form form){
AjaxUtils.error(form);
}
};
}
};


Disclaimer: the code above is based on Wicket 1.2.6.


Cheers,

Fabio Fioretti - WindoM


On Jan 17, 2008 1:21 PM, Steffen Fritzsche [EMAIL PROTECTED] wrote:
 Hi,

 I have the following problem. I created a three individual forms each
 within its own Tab (implementing AbstractTab). Each is submitted via
 ajax according to the Ajax-FormPage example. All forms are backed by the
 same Model-Object representing a simple Product wrapped in a
 BoundCompoundPropertyModel.

 On the surrounding page I have a forth form just with a submit button.
 This form refers to the same Product-Object and when the button is
 clicked it performs some action cleans up my Product Object and persists
 it via JPA.

 This is working so far, but currently I have to hit my ajax-submit
 button always before switching between each of the three real forms
 using the tabs.

 Is there an elagant solution to trigger this ajax submit and validating
 the form elements of the currently active form when the user clicks on
 one of the other form-tabs. So that I do not need a visible ajax-submit
 button anymore ...

 Steffen


 -
 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]