PDA

View Full Version : [2.1.1] BeanModelFactory return null



diegolovison
9 Feb 2010, 2:51 AM
public class A extends BaseModelData implements BeanModelTag { ... }




public class B extends BaseModelData implements BeanModelTag { ... }




final BeanModelFactory factoryA = BeanModelLookup.get().getFactory(A.class); // return null
final BeanModelFactory factoryB = BeanModelLookup.get().getFactory(B.class); // return null


why return null?

estefan.civera
9 Jun 2011, 9:05 AM
hi

i have the same situation...

did you solve it? thank
estevan

sven
9 Jun 2011, 10:19 AM
If you extend BaseModelData there is no need to implement BeanModelTag. You just need one of both.

estefan.civera
9 Jun 2011, 10:35 AM
Hi this is my bean class


public class PaymentDTO extends BeanModel implements Serializable{

public final static String DESCRIPTION = "description";
public final static String ID = "id";
public final static String ENABLED = "enabled";

public PaymentDTO() {
}

public PaymentDTO(Integer id, String description, Boolean enabled) {
set(ID,id);
set(DESCRIPTION, description);
set(ENABLED, enabled);
}
..


when I try to add new record I use this code


BeanModelFactory factory = BeanModelLookup.get().getFactory(PaymentDTO.class);

if(factory == null){
MessageBox.alert("factory", "factory == null", null);

}

selectedModel = factory.createModel(new PaymentDTO(1, "civera", true));

factory is always null

selectedModel is an object that incapsulate current record....
I declare it like this:


private Grid<BeanModel> grid = null;
private ListStore<BeanModel> store;
private BeanModel selectedModel;

my skype:estevan83

thank in advance estefan civera

sven
9 Jun 2011, 10:47 AM
Its not correct.

Instead of extending BeanModel you need to extend BaseModel and you also dont have to use BeanModelLookup at all.

estefan.civera
9 Jun 2011, 10:55 AM
Hi I've changed all
I estend from BaseModel but what I need to do when I try to save record?

akouznetchik
12 Jun 2011, 2:10 PM
What I do is (I pass objects back and forth via Gilead / Hibernate)

1. get POJO (that implements BeanModelTag)
2. Use BeanModelFactory to generate the BeanModel lets call it myModel
3. Use myModel.getBean() when I am ready to send it back to the server

In your case since your DTOs are already using get() and set() BaseModel style getters and setters why dont you just pass the DTO back to the server as is?