use of datamodel.ex1.entity.Customer in project jmix-docs by Haulmont.
the class TableScreen method onInit.
// end::inject-tableClick[]
// tag::onInit-start[]
@Subscribe
public void onInit(InitEvent event) {
// end::onInit-start[]
customersTable.addGeneratedColumn("aaa", entity -> null);
// tag::add-base-action[]
customersTable.addAction(new AboutSingleAction());
// end::add-base-action[]
// tag::add-ItemTrackingAction[]
customersTable.addAction(new ItemTrackingAction("about") {
@Nullable
@Override
public String getCaption() {
return "About";
}
@Override
public void actionPerform(Component component) {
notifications.create().withCaption("Hello " + customersTable.getSelected().iterator().next()).withType(Notifications.NotificationType.TRAY).show();
}
});
// end::add-ItemTrackingAction[]
// tag::table-set-style-name[]
tableBorderless.setStyleName(ThemeClassNames.TABLE_BORDERLESS);
// end::table-set-style-name[]
// tag::column-value-provider[]
printableTableExcelExport.addColumnValueProvider("firstName", context -> {
// <1>
Customer customer = context.getEntity();
return "Name: " + customer.getFirstName();
});
// end::column-value-provider[]
printableTableExcelExport.addColumnValueProvider("fullName", context -> {
Customer customer = context.getEntity();
return customer.getFirstName() + " " + customer.getLastName();
});
// tag::table-add-printable[]
/*printableTable.addPrintable("firstName", new Table.Printable<Customer, String>() {
@Override
public String getValue(Customer item) {
return "Name: " + item.getFirstName();
}
});*/
// end::table-add-printable[]
// tag::printable-column-generator[]
/*printableTable.addGeneratedColumn("fullName", new Table.PrintableColumnGenerator<Customer, String>() {
@Override
public String getValue(Customer item) {
return item.getFirstName() + " " + item.getLastName();
}
@Override
public Component generateCell(Customer entity) {
Label label = uiComponents.create(Label.NAME);
label.setValue(entity.getFirstName() + " " + entity.getLastName());
return label;
}
});*/
// end::printable-column-generator[]
// tag::item-click-action[]
tableClick.setItemClickAction(new BaseAction("itemClickAction").withHandler(actionPerformedEvent -> {
Customer customer = tableClick.getSingleSelected();
if (customer != null) {
notifications.create().withCaption("Item clicked for: " + customer.getFirstName() + "" + customer.getLastName()).show();
}
}));
// end::item-click-action[]
// tag::enter-press-action[]
tableClick.setEnterPressAction(new BaseAction("enterPressAction").withHandler(actionPerformedEvent -> {
Customer customer = tableClick.getSingleSelected();
if (customer != null) {
notifications.create().withCaption("Enter pressed for: " + customer.getFirstName() + "" + customer.getLastName()).show();
}
}));
// end::enter-press-action[]
// tag::programmatic-binding[]
customersTable1.setItems(new ContainerTableItems<>(customersDc));
// end::programmatic-binding[]
// tag::onInit-end[]
}
use of datamodel.ex1.entity.Customer in project jmix-docs by Haulmont.
the class TextFieldScreen method onInit.
// end::text-field-change-event[]
// tag::conversion-text-field[]
// tag::styled-text-field[]
// tag::event-mode[]
@Subscribe
protected void onInit(InitEvent initEvent) {
// end::event-mode[]
// end::conversion-text-field[]
// end::styled-text-field[]
// tag::conversion-text-field[]
textField.setConversionErrorMessage("This field can work only with Integers");
// end::conversion-text-field[]
// tag::styled-text-field[]
styledField.setStyleName("align-center");
// end::styled-text-field[]
// tag::event-mode[]
shortTextField.setTextChangeEventMode(TextInputField.TextChangeEventMode.LAZY);
// end::event-mode[]
Customer customer = metadata.create(Customer.class);
customer.setFirstName("John");
customer.setLastName("Bates");
customer.setAge(35);
customerDc.setItem(customer);
// tag::conversion-text-field[]
// tag::styled-text-field[]
// tag::event-mode[]
}
use of datamodel.ex1.entity.Customer in project jmix-docs by Haulmont.
the class LabelScreen method onInit.
// end::html-label[]
// tag::html-label[]
// tag::dynamic-label[]
// tag::styled-label[]
@Subscribe
protected void onInit(InitEvent event) {
// end::dynamic-label[]
// end::html-label[]
// end::styled-label[]
// InstanceContainer initialization. It is usually done automatically if the screen is
// inherited from StandardEditor and is used as an entity editor.
Customer customer = metadata.create(Customer.class);
customer.setFirstName("John");
customerDc.setItem(customer);
// tag::dynamic-label[]
dynamicLabel.setValue("Some value");
// end::dynamic-label[]
// tag::html-label[]
htmlLabel.setHtmlEnabled(true);
htmlLabel.setHtmlSanitizerEnabled(true);
htmlLabel.setValue(UNSAFE_HTML);
// end::html-label[]
// tag::styled-label[]
styledLabel.setStyleName("bold");
// end::styled-label[]
formattedLabel.setValue("Label, which should be formatted to uppercase");
// tag::html-label[]
// tag::dynamic-label[]
// tag::styled-label[]
}
use of datamodel.ex1.entity.Customer in project jmix-docs by Haulmont.
the class CustomerEditData method onCustomerDcItemPropertyChange.
// tag::property-change[]
@Subscribe(id = "customerDc", target = Target.DATA_CONTAINER)
public void onCustomerDcItemPropertyChange(InstanceContainer.ItemPropertyChangeEvent<Customer> event) {
Customer customer = event.getItem();
String changedProperty = event.getProperty();
Object currentValue = event.getValue();
Object previousValue = event.getPrevValue();
// ...
}
use of datamodel.ex1.entity.Customer in project jmix-docs by Haulmont.
the class CustomerEditData method onCustomerDcItemChange.
// end::property-change[]
// tag::item-change[]
@Subscribe(id = "customerDc", target = Target.DATA_CONTAINER)
public void onCustomerDcItemChange(InstanceContainer.ItemChangeEvent<Customer> event) {
Customer customer = event.getItem();
Customer previouslySelectedCustomer = event.getPrevItem();
// ...
}
Aggregations