Search in sources :

Example 21 with Customer

use of dataaccess.ex1.entity.Customer in project jmix-docs by Haulmont.

the class CustomerService method createCustomer.

// end::transaction-template-inject[]
// tag::transaction-template-without-result[]
public void createCustomer() {
    transactionTemplate.executeWithoutResult(status -> {
        Customer customer = dataManager.create(Customer.class);
        customer.setName("Alice");
        dataManager.save(customer);
    });
}
Also used : Customer(dataaccess.ex1.entity.Customer)

Example 22 with Customer

use of dataaccess.ex1.entity.Customer in project jmix-docs by Haulmont.

the class ActionScreen method onInit.

// end::inject-sayHelloBtn[]
// tag::on-init-start[]
@Subscribe
public void onInit(InitEvent event) {
    // end::on-init-start[]
    // tag::create-action-set[]
    createAction.setOpenMode(OpenMode.DIALOG);
    createAction.setScreenClass(CustomerEdit.class);
    // end::create-action-set[]
    // tag::edit-action-set[]
    editAction.setOpenMode(OpenMode.DIALOG);
    editAction.setScreenClass(CustomerEdit.class);
    // end::edit-action-set[]
    // tag::bulk-action-set[]
    custTableBulk.setOpenMode(OpenMode.THIS_TAB);
    custTableBulk.setIncludeProperties(Arrays.asList("rewardPoints", "email"));
    custTableBulk.setColumnsMode(ColumnsMode.ONE_COLUMN);
    // end::bulk-action-set[]
    // tag::remove-action-set[]
    removeAction.setConfirmation(true);
    removeAction.setConfirmationTitle("Removing customer...");
    removeAction.setConfirmationMessage("Do you really want to remove the customer?");
    // end::remove-action-set[]
    // tag::view-action-set[]
    viewAction.setOpenMode(OpenMode.DIALOG);
    viewAction.setScreenClass(CustomerEdit.class);
    // end::view-action-set[]
    // tag::tagLookup-action-set[]
    tagLookupAction.setOpenMode(OpenMode.DIALOG);
    tagLookupAction.setScreenClass(CustomerBrowse.class);
    // end::tagLookup-action-set[]
    // tag::base-action-button[]
    sayHelloBtn.setAction(new BaseAction("hello") {

        @Override
        public boolean isPrimary() {
            return true;
        }

        @Override
        public void actionPerform(Component component) {
            notifications.create().withCaption("Hello!").withType(Notifications.NotificationType.TRAY).show();
        }
    });
    sayGoodbyeBtn.setAction(new BaseAction("goodbye").withPrimary(true).withHandler(e -> notifications.create().withCaption("Goodbye!").withType(Notifications.NotificationType.TRAY).show()));
// end::base-action-button[]
// tag::on-init-end[]
}
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) BaseAction(io.jmix.ui.action.BaseAction)

Example 23 with Customer

use of dataaccess.ex1.entity.Customer in project jmix-docs by Haulmont.

the class DataManagerResourceTest method setUp.

@BeforeEach
void setUp() {
    Customer customer = dataManager.create(Customer.class);
    customer.setName("test-customer-1");
    customer.setConfidentialInfo("111");
    authenticator.withSystem(() -> dataManager.save(customer));
    customerId = customer.getId();
}
Also used : Customer(security.ex1.entity.Customer) BeforeEach(org.junit.jupiter.api.BeforeEach)

Example 24 with Customer

use of dataaccess.ex1.entity.Customer in project jmix-docs by Haulmont.

the class TableScreen method onTableSelectEventSelection.

@Subscribe("tableSelectEvent")
public void onTableSelectEventSelection(Table.SelectionEvent<Customer> event) {
    Customer customer = tableSelectEvent.getSingleSelected();
    notifications.create().withCaption("You selected " + customer.getFirstName() + " " + customer.getLastName() + " customer").show();
}
Also used : Customer(ui.ex1.entity.Customer)

Example 25 with Customer

use of dataaccess.ex1.entity.Customer in project jmix-docs by Haulmont.

the class CustomerBrowseData method createCustomer.

// end::find-by-name[]
// tag::create-customer[]
private void createCustomer() {
    Customer customer = metadata.create(Customer.class);
    customer.setFirstName("John");
    customer.setLastName("Doe");
    customersDc.getMutableItems().add(customer);
}
Also used : Customer(ui.ex1.entity.Customer)

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