Is there a way to implent TableFactory interface with specific fields related to propertyId ?
I only get one type of field since i'm using a generic class for all my tables, and the i'm missing CheckBox boolean value (groovy code):
class DefaultTableFieldFactory implements TableFieldFactory {
@Override
public Field<?> createField(Container container, Object itemId, Object propertyId, Component component) {
TextField t = new TextField()
switch(propertyId) {
case "firstname": t.setNullRepresentation("");
case "lastname": t.setNullRepresentation("");
case "mobile": t.setNullRepresentation("");
case "tel": t.setNullRepresentation("");
case "email": t.setNullRepresentation("");
default: break;
}
t.setWidth("95px")
return t
}
}
So i need to use this class above which implments DefaultTableFieldfactory in order to have the null representation as "" (instead of "null" ) in my whole application.
The goal is to provide for my custom components (more than 30) this null representation in a single place, I want to use this class as my default factory for every table, and connect it like i've done before:
def contacts = (Grails.get(FundService)).getAllContacts(fundId)
def cContainer = new BeanItemContainer<Contact>(Contact.class,contacts)
def t = new Table()
t.containerDataSource = cContainer
t.setTableFieldFactory(new DefaultTableFieldFactory())
See Question&Answers more detail:
os 与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…