java - Clean statement for value passing with afterburner fx in JavaFX? -


i use afterburner.fx framework javafx program follows,

namemodel used sharing state between views or implementation of business logic.

public class namemodel {      private final stringproperty name = new simplestringproperty();      public string getname() {         return name.get();     }      public void setname(string value) {         name.set(value);     }      public stringproperty nameproperty() {         return name;     } } 

schoolpresenter used enter value namemodel.if name in model value starting character starts "a",i pass name classapresenter , similar names starting character b, c ...for classb,classc...

public class schoolpresenter implements initializable {     @fxml     private stackpane stackpane;      @inject namemodel namemodel;     private classaview classaview;     private classbview classbview;     private classcview classcview;     .............................     private classnview classnview;      @fxml     void txtname(actionevent event) {         string name=txtname.gettext();         if (!name.isempty()) {          //my program runs fine not wrong         //if have n classes, , declarations same classes below         //the program confusing         //please me collapse code              if(name.startwith("a")){                 if (classaview == null) {                     classaview = new classaview();                     classapresenter classapresenter = (classapresenter) classaview.getpresenter();                     classapresenter.initnamemodel(namemodel);                      stackpane.getchildren().add(classaview.getview());                 }             }else if(name.startwith("b")){                     classbview = new classbview();                      classbpresenter classapresenter = (classbpresenter) classbview.getpresenter();                     classbpresenter.initnamemodel(namemodel);                      stackpane.getchildren().add(classbview.getview());             }else if.............//              namemodel.setname(txtname.gettext());         }     } } 

the classapresenter, classbpresenter ...classnpresenter structured follows

public class classapresenter  implements initializable {      private namemodel namemodel;      public void initdomainmodel(namemodel namemodel) {         // ensure model set once:         if (this.namemodel != null) {             throw new illegalstateexception("model can initialized once");         }         this.namemodel = namemodel;     } } 


Comments

Popular posts from this blog

php - Vagrant up error - Uncaught Reflection Exception: Class DOMDocument does not exist -

vue.js - Create hooks for automated testing -

.htaccess - ERR_TOO_MANY_REDIRECTS htaccess -