Java Code Examples for com.vaadin.flow.component.html.Paragraph#setId()
The following examples show how to use
com.vaadin.flow.component.html.Paragraph#setId() .
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: DevModeConfigView.java From flow with Apache License 2.0 | 5 votes |
public DevModeConfigView() { Paragraph productionMode = new Paragraph(String.valueOf(VaadinService .getCurrent().getDeploymentConfiguration().isProductionMode())); productionMode.setId("productionMode"); Paragraph devModeLiveReloadEnabled = new Paragraph( String.valueOf(VaadinService.getCurrent() .getDeploymentConfiguration().isDevModeLiveReloadEnabled())); devModeLiveReloadEnabled.setId("devModeLiveReloadEnabled"); add(productionMode, devModeLiveReloadEnabled); }
Example 2
Source File: KeyboardEventView.java From flow with Apache License 2.0 | 5 votes |
public KeyboardEventView() { input.setId("input"); Paragraph paragraph = new Paragraph(); paragraph.setId("paragraph"); ComponentUtil.addListener(input, KeyDownEvent.class, event -> { /* for each event, sets a string "keyvalue:codevalue;" to the paragraph. For 'Q' the string would be "Q:KeyQ" */ String keyText = String.join(",", event.getKey().getKeys()); String codeText = (event.getCode().isPresent() ? String.join(",", event.getCode().get().getKeys()) : ""); paragraph.setText(keyText + ":" + codeText); }); add(input, paragraph); Paragraph keyUpParagraph = new Paragraph(); keyUpParagraph.setId("keyUpParagraph"); ComponentUtil.addListener(input, KeyUpEvent.class, event -> keyUpParagraph .setText(String.join(",", event.getKey().getKeys()))); sendInvalidKeyUp.setId("sendInvalidKeyUp"); sendInvalidKeyUp.addClickListener(event -> { getUI().ifPresent(ui -> ui.getPage().executeJs( "$0.dispatchEvent(new KeyboardEvent('keyup', {}))", input.getElement())); }); add(sendInvalidKeyUp, keyUpParagraph); UI.getCurrent().getSession().setErrorHandler(event -> keyUpParagraph .setText(event.getThrowable().getMessage())); }
Example 3
Source File: DefaultValueInitializationComponent.java From flow with Apache License 2.0 | 5 votes |
public DefaultValueInitializationComponent() { valueParagraph = new Paragraph(); valueParagraph.setId("value"); updateParagraph = new Paragraph(); updateParagraph.setId("counter"); updateParagraphs(); add(valueParagraph, updateParagraph); }
Example 4
Source File: DomEventFilterView.java From flow with Apache License 2.0 | 4 votes |
public DomEventFilterView() { Element space = new Element("input"); space.setAttribute("id", "space"); space.addEventListener("keypress", e -> addMessage("Space listener triggered")) .setFilter("event.key == ' ' || event.key == 'Spacebar'"); // The key is called 'Spacebar' on IE11 Element debounce = new Element("input"); debounce.setAttribute("id", "debounce"); debounce.addEventListener("input", e -> addMessage("Trailing: " + e.getEventData().getString("element.value"))) .debounce(1000).addEventData("element.value"); debounce.addEventListener("input", e -> addMessage("Leading: " + e.getEventData().getString("element.value"))) .debounce(1000, DebouncePhase.LEADING); debounce.addEventListener("input", e -> addMessage("Throttle: " + e.getEventData().getString("element.value"))) .throttle(1000); DebounceComponent component = new DebounceComponent(); component.setId("debounce-component"); component.addInputListener( e -> addMessage("Component: " + e.getValue()), 1000); messages.setAttribute("id", "messages"); getElement().appendChild(space, debounce, component.getElement(), messages); // tests for#5090 final AtomicReference<DomListenerRegistration> atomicReference = new AtomicReference<>(); final Paragraph resultParagraph = new Paragraph(); resultParagraph.setId("result-paragraph"); NativeButton removalButton = new NativeButton("Remove DOM listener", event -> { resultParagraph.setText("REMOVED"); atomicReference.get().remove(); }); removalButton.setId("listener-removal-button"); Input listenerInput = new Input(ValueChangeMode.ON_CHANGE); listenerInput.setId("listener-input"); /* The event.preventDefault() is here to make sure that the listener has been cleaned on the client-side as well. The server-side cleaning is not really in question. */ ComponentUtil.addListener(listenerInput, KeyDownEvent.class, event -> resultParagraph.setText("A"), registration -> { atomicReference.set(registration); registration.setFilter("event.key === 'a' && " + "(event.preventDefault() || true)"); }); ComponentUtil.addListener(listenerInput, KeyDownEvent.class, event -> resultParagraph.setText("B"), registration -> registration.setFilter("event.key === 'b' && " + "(event.preventDefault() || true)")); add(listenerInput, removalButton, resultParagraph); }
Example 5
Source File: FactoryExporter.java From flow with Apache License 2.0 | 4 votes |
public InterfaceBasedComponent() { Paragraph paragraph = new Paragraph("Hello world"); paragraph.setId("paragraph"); add(paragraph); }