AjaxFallbackButton doesn't update ajax components when validation fails?

2009-10-16 Thread Christian Reiter

Hi!

I've got a form in which I use some textfields and other components 
which have validators attached.

The form also has the two standard ok and cancel buttons.

One important feature of the form is that the user should be able to 
query the altitude of a geoposition.
Therefore the form has a latitude and longitude textfield and a query 
altitude button.


When there is text in latitude and in longitude and the user clicks the 
query altitude button a web service
is queried for the appropriate altitude. Then the form's model object is 
updated with the altitude.


Everything works as expected when no other component in the form fails 
validation. The altitude is sent
back to the client. But when any other component fails validation, the 
altitude text field also isn't updated.


How can I omit this behaviour and get the altitude field updated, 
regardless of the validation result of the

other components?

Here's my query-altitude-button code:

queryAltitudeButton = new AjaxFallbackButton(queryAltitudeButton, form) {

@Override
protected void onError(AjaxRequestTarget target, Form? 
form) {

queryAlti(target);
}


@Override
protected void onSubmit(AjaxRequestTarget target, Form? 
form) {

queryAlti(target);
}

private void queryAlti(AjaxRequestTarget target) {
Double alti = 
AltitudeService.getAltitude(place.getLatitude(), place.getLongitude());


if( alti != null  alti = -300.0  alti = 9000.0) {
place.setElevation(alti);
} else {
place.setElevation(null);
}

if( target != null ) {
target.addComponent(altitudeTextField);
target.addComponent(feedbackPanel);
}
}
};
queryAltitudeButton.setOutputMarkupId(true);
form.add(queryAltitudeButton);


Thanks!

chris

--


Christian Reiter|||c.rei...@gmx.net


-
To unsubscribe, e-mail: users-unsubscr...@wicket.apache.org
For additional commands, e-mail: users-h...@wicket.apache.org



Re: AjaxFallbackButton doesn't update ajax components when validation fails?

2009-10-16 Thread Ernesto Reinaldo Barreiro
Just one idea... add some AjaxBehaivior that updates altitude  field in
event onchange. So, that even if validation fails you already have
your altitude updated...
Best,

Ernesto

On Fri, Oct 16, 2009 at 9:58 AM, Christian Reiter c.rei...@gmx.net wrote:

 Hi!

 I've got a form in which I use some textfields and other components which
 have validators attached.
 The form also has the two standard ok and cancel buttons.

 One important feature of the form is that the user should be able to query
 the altitude of a geoposition.
 Therefore the form has a latitude and longitude textfield and a query
 altitude button.

 When there is text in latitude and in longitude and the user clicks the
 query altitude button a web service
 is queried for the appropriate altitude. Then the form's model object is
 updated with the altitude.

 Everything works as expected when no other component in the form fails
 validation. The altitude is sent
 back to the client. But when any other component fails validation, the
 altitude text field also isn't updated.

 How can I omit this behaviour and get the altitude field updated,
 regardless of the validation result of the
 other components?

 Here's my query-altitude-button code:

 queryAltitudeButton = new AjaxFallbackButton(queryAltitudeButton, form) {

@Override
protected void onError(AjaxRequestTarget target, Form? form) {
queryAlti(target);
}


@Override
protected void onSubmit(AjaxRequestTarget target, Form? form)
 {
queryAlti(target);
}

private void queryAlti(AjaxRequestTarget target) {
Double alti =
 AltitudeService.getAltitude(place.getLatitude(), place.getLongitude());

if( alti != null  alti = -300.0  alti = 9000.0) {
place.setElevation(alti);
} else {
place.setElevation(null);
}

if( target != null ) {
target.addComponent(altitudeTextField);
target.addComponent(feedbackPanel);
}
}
 };
 queryAltitudeButton.setOutputMarkupId(true);
 form.add(queryAltitudeButton);


 Thanks!

 chris

 --


 Christian Reiter|||c.rei...@gmx.net


 -
 To unsubscribe, e-mail: users-unsubscr...@wicket.apache.org
 For additional commands, e-mail: users-h...@wicket.apache.org




Re: AjaxFallbackButton doesn't update ajax components when validation fails?

2009-10-16 Thread t3_chris

Thanks, Ernesto!

I'll try this ASAP!




reiern70 wrote:
 
 Just one idea... add some AjaxBehaivior that updates altitude  field in
 event onchange. So, that even if validation fails you already have
 your altitude updated...
 Best,
 
 Ernesto
 

-- 
View this message in context: 
http://www.nabble.com/AjaxFallbackButton-doesn%27t-update-ajax-components-when-validation-fails--tp25921313p25923585.html
Sent from the Wicket - User mailing list archive at Nabble.com.


-
To unsubscribe, e-mail: users-unsubscr...@wicket.apache.org
For additional commands, e-mail: users-h...@wicket.apache.org