javafx.bean.property lost after model be injected to controller

56 views
Skip to first unread message

Gogo Cao

unread,
Jan 27, 2015, 2:57:21 AM1/27/15
to dataf...@googlegroups.com

version: [io.datafx : 8.0] 

you can see it in the attachment. it's a complete eclipse project.

Issue desc:

1. lost property value after model be injected to controller
 I add a field name: simpleValue ,and extra class: SimpleValue which is with simple String.
  
@FlowScoped
public class DataModel {
   
private int counter = 0;
   
   
private ObjectProperty<SimpleValue> simpleValue = new SimpleObjectProperty<SimpleValue>();


   
public DataModel() {
        counter
++;
       
print("ctor");
   
}


   
public void print(String from) {
       
System.out.println(from + ": counter = " + counter + " simple value: " + getSimpleValue());
   
}


   
public final ObjectProperty<SimpleValue> simpleValueProperty() {
       
return this.simpleValue;
   
}


   
public final de.zwieblum.dataFx.SimpleValue getSimpleValue() {
       
return this.simpleValueProperty().get();
   
}


   
public final void setSimpleValue(
           
final de.zwieblum.dataFx.SimpleValue simpleValue) {
       
System.out.println("set value:" + simpleValue);
       
this.simpleValueProperty().set(simpleValue);
   
}

    
And controller:

@FXMLController("wizardView1.fxml")

public class WizardView1Controller {

    @Inject

    private DataModel model;

    

    @FXMLViewFlowContext

    ViewFlowContext context;


    @PostConstruct

    public void init() {

        model.setSimpleValue(new SimpleValue("simple value - from wizard #1"));  // this should have value, right??        

        this.model.print("wizard #1");

    }

}





  after a run the app, this is the result:

ctor: counter = 1 simple value: null
ctor
: counter = 1 simple value: null
WizardController: counter = 1 simple value: null  // and it is null!
ctor
: counter = 1 simple value: null
ctor
: counter = 1 simple value: null
set value:SimpleValue [name=simple value - from wizard #1]  //value is not null
wizard
#1: counter = 1 simple value: null   //why null?


   I think the simple value here, should not be null. right?

2. and why variable: counter remain 1 ? ,shouldn't it be ++ like , 1,2,3,4 ...

Am I lose something? Any help would be appreciated. 

 Thank you
datafx-model-inject-error.zip
Reply all
Reply to author
Forward
0 new messages