use of dataaccess.ex1.entity.Customer in project jmix-docs by Haulmont.
the class CustomerBrowse method onInit.
// end::actions[]
// tag::on-init-start[]
@Subscribe
protected void onInit(InitEvent event) {
// end::on-init-start[]
// tag::set-caption[]
customersTableExcel.setCaption("Export to Excel");
// end::set-caption[]
// tag::set-caption-json[]
customersTableJson.setCaption("Export to JSON");
// end::set-caption-json[]
// tag::add-column-value-provider[]
customersTableExcel.addColumnValueProvider("isEmail", context -> {
Customer customer = context.getEntity();
return customer.getEmail() != null;
});
// end::add-column-value-provider[]
customersTableJson.addColumnValueProvider("isEmail", context -> {
Customer customer = context.getEntity();
return customer.getEmail() != null;
});
customersTableJson.addColumnValueProvider("age", context -> {
Customer customer = context.getEntity();
return "Age is " + customer.getAge();
});
// tag::custom-action[]
CustomExportAction customAction = actions.create(CustomExportAction.class);
customAction.setTableExporter(applicationContext.getBean(CustomExporter.class));
customAction.setTarget(customersTable);
customAction.setApplicationContext(applicationContext);
customBtn.setAction(customAction);
// end::custom-action[]
// tag::on-init-end[]
}
use of dataaccess.ex1.entity.Customer in project jmix-docs by Haulmont.
the class KeyValueTest method test.
@Test
void test() {
// tag::load[]
List<KeyValueEntity> entities = dataManager.loadValues("select e.customer, sum(e.amount) from sample_Order e group by e.customer").properties("customer", "total").list();
// end::load[]
assertEquals(2, entities.size());
// tag::get-value[]
for (KeyValueEntity entity : entities) {
Customer customer = entity.getValue("customer");
BigDecimal totalAmount = entity.getValue("total");
// ...
}
// end::get-value[]
}
use of dataaccess.ex1.entity.Customer in project jmix-docs by Haulmont.
the class ActionScreen method custTableCreateNewEntitySupplier.
// end::screen-configurer[]
// tag::new-entity-supplier[]
@Install(to = "custTable.create", subject = "newEntitySupplier")
private Customer custTableCreateNewEntitySupplier() {
Customer customer = metadata.create(Customer.class);
customer.setFirstName("Sean");
customer.setLastName("White");
return customer;
}
use of dataaccess.ex1.entity.Customer in project jmix-docs by Haulmont.
the class ActionScreen method onCustomersTableCreate.
// end::action-performed-event[]
// tag::action-performed-event-2[]
@Subscribe("customersTable.create")
public void onCustomersTableCreate(Action.ActionPerformedEvent event) {
screenBuilders.editor(customersTable).newEntity().withOpenMode(OpenMode.DIALOG).withScreenClass(CustomerEdit.class).withAfterCloseListener(afterScreenCloseEvent -> {
if (afterScreenCloseEvent.closedWith(StandardOutcome.COMMIT)) {
Customer committedCustomer = (afterScreenCloseEvent.getSource()).getEditedEntity();
System.out.println("Created " + committedCustomer);
}
}).build().show();
}
use of dataaccess.ex1.entity.Customer in project jmix-docs by Haulmont.
the class ActionScreen method onCustTableView.
// end::view-after-close-handler[]
// tag::view-action-performed-event[]
@Subscribe("custTable.view")
public void onCustTableView(Action.ActionPerformedEvent event) {
CustomerEdit customerEdit = screenBuilders.editor(custTable).withOpenMode(OpenMode.DIALOG).withScreenClass(CustomerEdit.class).withAfterCloseListener(afterScreenCloseEvent -> {
if (afterScreenCloseEvent.closedWith(StandardOutcome.COMMIT)) {
Customer committedCustomer = (afterScreenCloseEvent.getSource()).getEditedEntity();
System.out.println("Updated " + committedCustomer);
}
}).build();
customerEdit.setReadOnly(true);
customerEdit.show();
}
Aggregations