Search in sources :

Example 1 with ProductPart

use of datamodel.ex1.entity.ProductPart in project jmix-docs by Haulmont.

the class ProductEdit method onPartsTableCreate.

@Subscribe("partsTable.create")
public void onPartsTableCreate(Action.ActionPerformedEvent event) {
    ProductPart part = dataContext.create(ProductPart.class);
    partsDc.getMutableItems().add(part);
}
Also used : ProductPart(datamodel.ex1.entity.ProductPart)

Example 2 with ProductPart

use of datamodel.ex1.entity.ProductPart in project jmix-docs by Haulmont.

the class ProductEntityEventListener method onProductLoading.

@EventListener
void onProductLoading(EntityLoadingEvent<Product> event) {
    Product product = event.getEntity();
    try {
        ProductPart[] productPartsArray = objectMapper.readValue(product.getParts(), ProductPart[].class);
        product.setPartsList(productPartsArray == null ? null : Arrays.asList(productPartsArray));
    } catch (JsonProcessingException e) {
        throw new RuntimeException("Error reading JSON", e);
    }
}
Also used : Product(datamodel.ex1.entity.Product) ProductPart(datamodel.ex1.entity.ProductPart) JsonProcessingException(com.fasterxml.jackson.core.JsonProcessingException) EventListener(org.springframework.context.event.EventListener)

Aggregations

ProductPart (datamodel.ex1.entity.ProductPart)2 JsonProcessingException (com.fasterxml.jackson.core.JsonProcessingException)1 Product (datamodel.ex1.entity.Product)1 EventListener (org.springframework.context.event.EventListener)1