Last active
October 28, 2020 20:45
-
-
Save lofidewanto/aa10420110c0e92619542fca64bc4272 to your computer and use it in GitHub Desktop.
IndexedDB with Patterns - Composite UI
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
package com.github.lofi.client; | |
import static org.jboss.elemento.Elements.br; | |
... | |
import java.util.logging.Logger; | |
... | |
@Singleton | |
public class ProductComposite { | |
private static Logger logger = Logger.getLogger(ProductComposite.class.getName()); | |
private ProductService productService; | |
private Element panelElement; | |
@Inject | |
public ProductComposite(ProductService productService) { | |
this.productService = productService; | |
} | |
public void renderView() { | |
panelElement = DomGlobal.document.getElementById("panel"); | |
HtmlContentBuilder<HTMLLabelElement> label = label().textContent("Try this to add data... ") | |
.add(button().textContent("Click to add data!").on(click, | |
event -> onProductCreated())).add(br()); | |
panelElement.appendChild(label.element()); | |
} | |
void onProductCreated() { | |
Product createdProduct = productService.createProduct(); | |
Integer calculatedPriceWithAmount = createdProduct.getCalculatedPriceWithAmount(); | |
if (calculatedPriceWithAmount >= 350) { | |
logger.info("getCalculatedPriceWithAmount >= 350: " + calculatedPriceWithAmount); | |
InputBuilder<HTMLInputElement> input = renderInputElements(); | |
input.element().value = calculatedPriceWithAmount.toString(); | |
} else { | |
logger.info("getCalculatedPriceWithAmount: " + calculatedPriceWithAmount); | |
} | |
} | |
... |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment