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

Reply via email to