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 <[email protected]> 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 ||| [email protected] > > > --------------------------------------------------------------------- > To unsubscribe, e-mail: [email protected] > For additional commands, e-mail: [email protected] > >
