Search in sources :

Example 31 with Customer

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[]
}
Also used : Customer(gridexport.ex1.entity.Customer) CustomExporter(gridexport.ex1.screen.exporter.CustomExporter) CustomExportAction(gridexport.ex1.screen.exporter.CustomExportAction)

Example 32 with Customer

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[]
}
Also used : Customer(datamodel.ex1.entity.Customer) KeyValueEntity(io.jmix.core.entity.KeyValueEntity) BigDecimal(java.math.BigDecimal) Test(org.junit.jupiter.api.Test) SpringBootTest(org.springframework.boot.test.context.SpringBootTest)

Example 33 with Customer

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;
}
Also used : Customer(ui.ex1.entity.Customer)

Example 34 with 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();
}
Also used : Customer(ui.ex1.entity.Customer) CustomerEdit(ui.ex1.screen.entity.customer.CustomerEdit)

Example 35 with Customer

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();
}
Also used : CollectionLoader(io.jmix.ui.model.CollectionLoader) java.util(java.util) Customer(ui.ex1.entity.Customer) BulkEditors(io.jmix.ui.bulk.BulkEditors) Dialogs(io.jmix.ui.Dialogs) io.jmix.ui.action.list(io.jmix.ui.action.list) TagLookupAction(io.jmix.ui.action.tagpicker.TagLookupAction) Autowired(org.springframework.beans.factory.annotation.Autowired) Metadata(io.jmix.core.Metadata) ParamsMap(io.jmix.core.common.util.ParamsMap) CustomerEdit(ui.ex1.screen.entity.customer.CustomerEdit) ColumnsMode(io.jmix.ui.app.bulk.ColumnsMode) Notifications(io.jmix.ui.Notifications) io.jmix.ui.screen(io.jmix.ui.screen) ScreenBuilders(io.jmix.ui.ScreenBuilders) CustomerBrowse(ui.ex1.screen.entity.customer.CustomerBrowse) RemoveOperation(io.jmix.ui.RemoveOperation) Action(io.jmix.ui.action.Action) BaseAction(io.jmix.ui.action.BaseAction) Named(javax.inject.Named) MetaProperty(io.jmix.core.metamodel.model.MetaProperty) DialogAction(io.jmix.ui.action.DialogAction) io.jmix.ui.component(io.jmix.ui.component) Customer(ui.ex1.entity.Customer) CustomerEdit(ui.ex1.screen.entity.customer.CustomerEdit)

Aggregations

Customer (ui.ex1.entity.Customer)34 Customer (dataaccess.ex1.entity.Customer)25 BeforeEach (org.junit.jupiter.api.BeforeEach)10 Test (org.junit.jupiter.api.Test)10 Autowired (org.springframework.beans.factory.annotation.Autowired)10 SpringBootTest (org.springframework.boot.test.context.SpringBootTest)10 CustomerEdit (ui.ex1.screen.entity.customer.CustomerEdit)10 Action (io.jmix.ui.action.Action)8 BaseAction (io.jmix.ui.action.BaseAction)8 io.jmix.ui.screen (io.jmix.ui.screen)8 Named (javax.inject.Named)8 Order (dataaccess.ex1.entity.Order)7 Metadata (io.jmix.core.Metadata)6 ParamsMap (io.jmix.core.common.util.ParamsMap)6 Notifications (io.jmix.ui.Notifications)6 ScreenBuilders (io.jmix.ui.ScreenBuilders)6 DialogAction (io.jmix.ui.action.DialogAction)6 io.jmix.ui.component (io.jmix.ui.component)6 BigDecimal (java.math.BigDecimal)6 TransactionalEventListener (org.springframework.transaction.event.TransactionalEventListener)6