Don't like ads? PRO users don't see any ads ;-)
Guest

Untitled

By: a guest on Aug 11th, 2012  |  syntax: None  |  size: 1.01 KB  |  hits: 9  |  expires: Never
download  |  raw  |  embed  |  report abuse  |  print
Text below is selected. Please press Ctrl+C to copy to your clipboard. (⌘+C on Mac)
  1. Java, FX data validation with complex interdependency
  2. class Product{
  3.   StringProperty prop1;
  4.   StringProperty prop2;
  5.   .........
  6. }
  7.  
  8. class Controller{
  9.    GridPane pane;
  10.    Product _product;
  11.    init(){};
  12.    ObservableList readXMLBuildOptionsList(){
  13.      //build options from xml
  14.      return optionlist;
  15.    }
  16.    buildGui(){
  17.       pane = new GridPane();
  18.       Rules rule = new Rules();
  19.       //For each optionList in master list
  20.       //Create combo that matches up to properties of object
  21.       ComboBox box = new ComboBox(observableList);
  22.       box.addChangeListener(new ChangeListener(){
  23.  
  24.             @Override
  25.             public void changed(ObservableValue arg0, Object arg1, Object arg2) {
  26.                 if (arg1 != arg2) {
  27.                     rule.validate(arg0, arg1, arg2);
  28.                 }
  29.             }
  30.         });
  31.    }
  32. }
  33.  
  34. class Rules{
  35.    void validate(ObservableValue arg0, Object arg1, Object arg2){
  36.       //some validation across all fields?
  37.       //Change invalid options in other fields to red colored text
  38.     }
  39. }