Mercurial > dive4elements > river
changeset 1565:87f5ed6960e8
Improved form validation.
flys-client/trunk@3817 c6561f87-3c4e-4783-a992-168aeb5c3f6f
author | Felix Wolfsteller <felix.wolfsteller@intevation.de> |
---|---|
date | Mon, 30 Jan 2012 08:57:43 +0000 |
parents | 3606f2caf93e |
children | c408074c6409 |
files | flys-client/ChangeLog flys-client/src/main/java/de/intevation/flys/client/client/ui/chart/ManualPointsEditor.java |
diffstat | 2 files changed, 12 insertions(+), 33 deletions(-) [+] |
line wrap: on
line diff
--- a/flys-client/ChangeLog Mon Jan 30 08:38:18 2012 +0000 +++ b/flys-client/ChangeLog Mon Jan 30 08:57:43 2012 +0000 @@ -1,3 +1,9 @@ +2012-01-30 Felix Wolfsteller <felix.wolfsteller@intevation.de> + + * src/main/java/de/intevation/flys/client/client/ui/chart/ManualPointsEditor.java: + Added basic validation of entered values at a higher level. Removed + TODOs, cosmetics. + 2012-01-30 Felix Wolfsteller <felix.wolfsteller@intevation.de> * src/main/java/de/intevation/flys/client/client/ui/chart/ManualPointsEditor.java:
--- a/flys-client/src/main/java/de/intevation/flys/client/client/ui/chart/ManualPointsEditor.java Mon Jan 30 08:38:18 2012 +0000 +++ b/flys-client/src/main/java/de/intevation/flys/client/client/ui/chart/ManualPointsEditor.java Mon Jan 30 08:57:43 2012 +0000 @@ -149,7 +149,6 @@ Button cancel = new Button(MSG.label_cancel()); cancel.addClickHandler(this); - // TODO refactor. accept.addClickHandler(new ClickHandler() { public void onClick(ClickEvent e) { okClicked(); @@ -286,7 +285,7 @@ else { JSONArray data = new JSONArray(); - String nameString = record.getAttributeAsString("name"); + String nameString = record.getAttributeAsString(PointRecord.ATTRIBUTE_NAME); // Apply default name if none set. if (nameString == null || nameString.equals("")) { String xString = record.getAttributeAsString( @@ -345,7 +344,6 @@ }); } else { - // TODO i18n? GWT.log("Dialog not valid"); SC.warn(MSG.error_dialog_not_valid()); } @@ -454,38 +452,13 @@ } - // TODO validate entered values (CellFormatter). + /** Return false if x or y attribute is missing. */ protected boolean isDialogValid() { boolean valid = true; - /* - for (int i = 0; i < tabs.getNumTabs(); i++) { - Tab t = tabs.getTab(i); - Canvas container = t.getPane(); - Canvas[] children = container.getChildren(); - for (Canvas c: children) { - valid = validateCanvas(c); - if(!valid) { - return valid; - } - } - } - */ - return valid; - } - - - protected boolean validateCanvas(Canvas c) { - boolean valid = true; - if(c instanceof DynamicForm) { - DynamicForm f = (DynamicForm) c; - return !f.hasErrors(); - } - else if(c.getChildren().length > 0) { - for (Canvas child: c.getChildren()) { - valid = validateCanvas(child); - if(!valid) { - return valid; - } + for (ListGridRecord record : listGrid.getRecords()) { + if (record.getAttributeAsDouble(PointRecord.ATTRIBUTE_X) == null + || record.getAttributeAsDouble(PointRecord.ATTRIBUTE_Y) == null) { + return false; } } return valid;