I have some data in a column that can either be a 1 or 2, and is stored as an int. How can I replace this with a string?
Thanks
EDIT: Just to clarify, I don’t want to change it in the database, only on display level.
I have some data in a column that can either be a 1 or 2, and is stored as an int. How can I replace this with a string?
Thanks
EDIT: Just to clarify, I don’t want to change it in the database, only on display level.
Fixed with a generated column. Still struggling to understand when I need to inject and entity vs when to use entity.getXYZ().
package uk.co.lanware.reportal.web.checkresults;
import com.haulmont.cuba.gui.components.*;
import com.haulmont.cuba.gui.xml.layout.ComponentsFactory;
import uk.co.test.reportal.entity.CheckResults;
import com.haulmont.cuba.core.entity.Entity;
import javax.inject.Inject;
import java.util.List;
import java.util.Map;
public class CheckResultsBrowse extends AbstractLookup {
@Inject
private Table<CheckResults> checkResultsesTable;
@Inject
private ComponentsFactory componentsFactory;
@Override
public void init(Map<String, Object> params) {
checkResultsesTable.addGeneratedColumn("Check Result", entity -> {
Label field = componentsFactory.createComponent(Label.class);
if (entity.getResult() == 1) {
field.setValue("Passed");
} else {
field.setValue("Failed");
}
return field;
});
}
}