Mercurial > dive4elements > river
comparison flys-client/src/main/java/de/intevation/flys/client/client/ui/LocationDistancePanel.java @ 59:a3d235c63195
Save the data explicitly in the LocationDistancePanel and WQInputPanel before returning the user input to avoid a nullpointer exception.
flys-client/trunk@1519 c6561f87-3c4e-4783-a992-168aeb5c3f6f
author | Ingo Weinzierl <ingo.weinzierl@intevation.de> |
---|---|
date | Fri, 18 Mar 2011 13:45:34 +0000 |
parents | d018995fbee7 |
children | 4784ca718476 |
comparison
equal
deleted
inserted
replaced
58:d018995fbee7 | 59:a3d235c63195 |
---|---|
221 * This method returns the selected data. | 221 * This method returns the selected data. |
222 * | 222 * |
223 * @return the selected/inserted data. | 223 * @return the selected/inserted data. |
224 */ | 224 */ |
225 public Data[] getData() { | 225 public Data[] getData() { |
226 // XXX If we have entered a value and click right afterwards on the | |
227 // 'next' button, the BlurEvent is not fired, and the values are not | |
228 // saved. So, we gonna save those values explicitly. | |
229 if (isLocationMode()) { | |
230 Canvas member = container.getMember(0); | |
231 if (member instanceof DoubleArrayPanel) { | |
232 DoubleArrayPanel form = (DoubleArrayPanel) member; | |
233 saveLocationValues(form); | |
234 } | |
235 } | |
236 else { | |
237 Canvas member = container.getMember(0); | |
238 if (member instanceof DoubleRangePanel) { | |
239 DoubleRangePanel form = (DoubleRangePanel) member; | |
240 saveDistanceValues(form); | |
241 } | |
242 } | |
243 | |
226 return new Data[] { getDataFrom(), getDataTo(), getDataStep() }; | 244 return new Data[] { getDataFrom(), getDataTo(), getDataStep() }; |
227 } | 245 } |
228 | 246 |
229 | 247 |
230 /** | 248 /** |
388 } | 406 } |
389 | 407 |
390 if (field.equals(DoubleArrayPanel.FIELD_NAME)) { | 408 if (field.equals(DoubleArrayPanel.FIELD_NAME)) { |
391 DoubleArrayPanel p = (DoubleArrayPanel) event.getForm(); | 409 DoubleArrayPanel p = (DoubleArrayPanel) event.getForm(); |
392 | 410 |
393 if (p.validateForm(item)) { | 411 saveLocationValue(p, item); |
394 setLocationValues(p.getInputValues(item)); | |
395 } | |
396 } | 412 } |
397 else { | 413 else { |
398 DoubleRangePanel p = (DoubleRangePanel) event.getForm(); | 414 DoubleRangePanel p = (DoubleRangePanel) event.getForm(); |
399 | 415 |
400 if (p.validateForm(item)) { | 416 saveDistanceValue(p, item); |
401 setFrom(p.getFrom()); | 417 } |
402 setTo(p.getTo()); | 418 } |
403 setStep(p.getStep()); | 419 |
420 | |
421 /** | |
422 * Validates and stores all values entered in the location mode. | |
423 * | |
424 * @param p The DoubleArrayPanel. | |
425 */ | |
426 protected void saveLocationValues(DoubleArrayPanel p) { | |
427 FormItem[] formItems = p.getFields(); | |
428 | |
429 for (FormItem item: formItems) { | |
430 if (item.getFieldName().equals(DoubleArrayPanel.FIELD_NAME)) { | |
431 saveLocationValue(p, item); | |
404 } | 432 } |
433 } | |
434 } | |
435 | |
436 | |
437 /** | |
438 * Validates and stores all values entered in the distance mode. | |
439 * | |
440 * @param p The DoubleRangePanel. | |
441 */ | |
442 protected void saveDistanceValues(DoubleRangePanel p) { | |
443 FormItem[] formItems = p.getFields(); | |
444 | |
445 for (FormItem item: formItems) { | |
446 saveDistanceValue(p, item); | |
447 } | |
448 } | |
449 | |
450 | |
451 /** | |
452 * Validates and stores a value entered in the location mode. | |
453 * | |
454 * @param p The DoubleArrayPanel. | |
455 * @param item The item that needs to be validated. | |
456 */ | |
457 protected void saveLocationValue(DoubleArrayPanel p, FormItem item) { | |
458 if (p.validateForm(item)) { | |
459 setLocationValues(p.getInputValues(item)); | |
460 } | |
461 } | |
462 | |
463 | |
464 /** | |
465 * Validates and stores value entered in the distance mode. | |
466 * | |
467 * @param p The DoubleRangePanel. | |
468 * @param item The item that needs to be validated. | |
469 */ | |
470 protected void saveDistanceValue(DoubleRangePanel p, FormItem item) { | |
471 if (p.validateForm(item)) { | |
472 setFrom(p.getFrom()); | |
473 setTo(p.getTo()); | |
474 setStep(p.getStep()); | |
405 } | 475 } |
406 } | 476 } |
407 | 477 |
408 | 478 |
409 /** | 479 /** |