Java Code Examples for com.vaadin.flow.component.textfield.TextField#setValueChangeMode()
The following examples show how to use
com.vaadin.flow.component.textfield.TextField#setValueChangeMode() .
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: UsersView.java From radman with MIT License | 6 votes |
UserFormDialog() { TextField username = new TextField("Username"); username.setValueChangeMode(ValueChangeMode.EAGER); TextField description = new TextField("Description"); description.setValueChangeMode(ValueChangeMode.EAGER); binder = new BeanValidationBinder<>(RadiusUserDto.class); binder.bind(username, "username"); binder.bind(description, "description"); HorizontalLayout controlsLayout = new HorizontalLayout(); controlsLayout.setJustifyContentMode(FlexComponent.JustifyContentMode.END); controlsLayout.add(new Button("Cancel", event -> setOpened(false))); controlsLayout.add(getConfirmBtn()); controlsLayout.setWidthFull(); add(new H3(getDialogTitle())); add(new FormLayout(username, description)); add(new Hr()); add(controlsLayout); }
Example 2
Source File: UserGroupsView.java From radman with MIT License | 6 votes |
UserGroupFormDialog() { TextField username = new TextField("Name"); username.setValueChangeMode(ValueChangeMode.EAGER); TextField description = new TextField("Description"); description.setValueChangeMode(ValueChangeMode.EAGER); binder = new BeanValidationBinder<>(RadiusGroupDto.class); binder.bind(username, "name"); binder.bind(description, "description"); HorizontalLayout controlsLayout = new HorizontalLayout(); controlsLayout.setJustifyContentMode(FlexComponent.JustifyContentMode.END); controlsLayout.add(new Button("Cancel", event -> setOpened(false))); controlsLayout.add(getConfirmBtn()); controlsLayout.setWidthFull(); add(new H3(getDialogTitle())); add(new FormLayout(username, description)); add(new Hr()); add(controlsLayout); }
Example 3
Source File: NasGroupsView.java From radman with MIT License | 6 votes |
NasGroupFormDialog(NasService nasService) { this.nasService = nasService; TextField groupname = new TextField("Group name"); groupname.setValueChangeMode(ValueChangeMode.EAGER); TextField nasIpAddress = new TextField("IP address"); nasIpAddress.setValueChangeMode(ValueChangeMode.EAGER); TextField nasPortId = new TextField("Port ID"); nasPortId.setValueChangeMode(ValueChangeMode.EAGER); binder = new BeanValidationBinder<>(NasGroupDto.class); binder.bind(groupname, "groupName"); binder.bind(nasIpAddress, "nasIpAddress"); binder.bind(nasPortId, "nasPortId"); HorizontalLayout controlsLayout = new HorizontalLayout(); controlsLayout.setJustifyContentMode(FlexComponent.JustifyContentMode.END); controlsLayout.add(new Button("Cancel", event -> setOpened(false))); controlsLayout.add(getConfirmBtn()); controlsLayout.setWidthFull(); add(new H3(getDialogTitle())); add(new FormLayout(groupname, nasIpAddress, nasPortId)); add(new Hr()); add(controlsLayout); }
Example 4
Source File: AuthView.java From radman with MIT License | 5 votes |
private AbstractSinglePropertyField<? extends AbstractField<?, ?>, String> buildTextValueField() { binder.removeBinding("value"); TextField valueField = new TextField("Value"); valueField.setValueChangeMode(ValueChangeMode.EAGER); valueField.setClearButtonVisible(false); binder.bind(valueField, "value"); return valueField; }
Example 5
Source File: UserToGroupView.java From radman with MIT License | 4 votes |
private void buildView() { setHeightFull(); setSpacing(false); RoleDto role = securityService.getLoggedUserRole(); Grid<RadiusUserToGroupDto> grid = new Grid<>(RadiusUserToGroupDto.class, false); grid.addColumns("username", "groupName", "userInRadman", "groupInRadman"); DataProvider<RadiusUserToGroupDto, Object> dataProvider = new SpringDataProviderBuilder<>( (pageable, o) -> userService.pageRadiusUserToGroupRecords(filter, pageable), value -> userService.countRadiusUserToGroupRecords(filter)) .withDefaultSort("username", SortDirection.ASCENDING) .build(); grid.setDataProvider(dataProvider); grid.setSortableColumns("username", "groupName"); grid.setColumnReorderingAllowed(true); grid.setMinHeight("500px"); grid.setHeight("100%"); Button addUserToGroup = new Button("Add user to group", event -> { AddUserToGroupDialog addDialog = new AddUserToGroupDialog( (source, bean) -> grid.getDataProvider().refreshAll()); addDialog.startAdding(); }); addUserToGroup.setEnabled(role == RoleDto.ADMIN); ConfirmationDialog deleteDialog = new ConfirmationDialog(); deleteDialog.setTitle("Delete User to Group mapping"); deleteDialog.setDescription("Are you sure?"); deleteDialog.setConfirmButtonCaption("Delete"); deleteDialog.setConfirmListener(() -> { Optional<RadiusUserToGroupDto> optional = grid.getSelectionModel().getFirstSelectedItem(); try { optional.ifPresent(userService::removeRadiusUserFromGroup); grid.getDataProvider().refreshAll(); } catch (Exception e) { log.warn("Failed to delete user to group mapping. Reason = '{}'", e.getMessage()); ErrorNotification.show("Error", "Ooops, something went wrong, try again please"); } deleteDialog.setOpened(false); }); Button removeUserFromGroup = new Button("Remove user from group", event -> deleteDialog.setOpened(true)); removeUserFromGroup.setEnabled(false); grid.asSingleSelect().addValueChangeListener(event -> removeUserFromGroup.setEnabled(Objects.nonNull(event.getValue()) && role == RoleDto.ADMIN)); TextField search = new TextField(event -> { filter.setSearchText(event.getValue()); grid.getDataProvider().refreshAll(); }); search.setValueChangeMode(ValueChangeMode.EAGER); search.setPlaceholder("Search..."); add(new H4("Data from Radius DB - \"radusergroup\" table")); HorizontalLayout horizontalLayout = new HorizontalLayout(); horizontalLayout.setDefaultVerticalComponentAlignment(FlexComponent.Alignment.BASELINE); horizontalLayout.add(new H3("Users to Groups")); horizontalLayout.add(addUserToGroup); horizontalLayout.add(removeUserFromGroup); horizontalLayout.add(search); add(horizontalLayout); add(grid); }
Example 6
Source File: NasView.java From radman with MIT License | 4 votes |
NasFormDialog(NasService nasService) { this.nasService = nasService; TextField name = new TextField("Name"); name.setValueChangeMode(ValueChangeMode.EAGER); TextField shortName = new TextField("Short name"); shortName.setValueChangeMode(ValueChangeMode.EAGER); TextField type = new TextField("Type"); type.setValueChangeMode(ValueChangeMode.EAGER); NumberField port = new NumberField("Port"); port.setValueChangeMode(ValueChangeMode.EAGER); PasswordField secret = new PasswordField("Secret"); secret.setValueChangeMode(ValueChangeMode.EAGER); TextField server = new TextField("Server"); server.setValueChangeMode(ValueChangeMode.EAGER); TextField community = new TextField("Community"); community.setValueChangeMode(ValueChangeMode.EAGER); TextArea description = new TextArea("Description"); description.setValueChangeMode(ValueChangeMode.EAGER); FormLayout formLayout = new FormLayout(); formLayout.setWidthFull(); formLayout.setMaxWidth("700px"); formLayout.add(name, shortName, server, port, secret, type, community, description); formLayout.setResponsiveSteps( new FormLayout.ResponsiveStep("0px", 1), new FormLayout.ResponsiveStep("450px", 2)); HorizontalLayout controlsLayout = new HorizontalLayout(); controlsLayout.setJustifyContentMode(FlexComponent.JustifyContentMode.END); controlsLayout.add(new Button("Cancel", event -> setOpened(false))); controlsLayout.add(getConfirmBtn()); controlsLayout.setWidthFull(); add(new H3(getDialogTitle())); add(formLayout); add(new Hr()); add(controlsLayout); binder = new BeanValidationBinder<>(NasDto.class); binder.bind(name, "nasName"); binder.bind(shortName, "shortName"); binder.bind(type, "type"); binder.forField(port) .withConverter(new DoubleToIntegerConverter("Port must be number " + "between 1 and " + 65535 + ".")) .bind("ports"); binder.bind(secret, "secret"); binder.bind(server, "server"); binder.bind(community, "community"); binder.bind(description, "description"); }
Example 7
Source File: AccountingView.java From radman with MIT License | 4 votes |
private void buildView() { setHeightFull(); setSpacing(false); Grid<AccountingDto> grid = new Grid<>(AccountingDto.class, false); grid.addColumns("username", "callingStationId", "nasIpAddress", "serviceType"); grid.addColumn(new LocalDateTimeRenderer<>((ValueProvider<AccountingDto, LocalDateTime>) accountingDto -> { if (Objects.isNull(accountingDto.getAcctStartTime())) { return null; } return LocalDateTime.ofInstant(accountingDto.getAcctStartTime().toInstant(), TimeZone.getDefault().toZoneId()); })).setSortProperty("acctStartTime").setHeader("Acct Start Time"); grid.addColumn(new LocalDateTimeRenderer<>((ValueProvider<AccountingDto, LocalDateTime>) accountingDto -> { if (Objects.isNull(accountingDto.getAcctStopTime())) { return null; } return LocalDateTime.ofInstant(accountingDto.getAcctStopTime().toInstant(), TimeZone.getDefault().toZoneId()); })).setSortProperty("acctStopTime").setHeader("Acct Stop Time"); grid.addColumns("acctTerminateCause", "framedIpAddress", "framedProtocol"); grid.addColumns("acctAuthentic", "acctInputOctets", "acctInterval", "acctOutputOctets", "acctSessionId"); grid.addColumn(accountingDto -> { if (Objects.isNull(accountingDto.getAcctSessionTime())) { return null; } return DurationFormatUtils.formatDurationHMS(accountingDto.getAcctSessionTime()); }).setSortProperty("acctSessionTime").setHeader("Acct Session Time"); grid.addColumns("acctUniqueId", "acctUpdateTime", "calledStationId", "connectInfoStart", "connectInfoStop", "nasPortId", "nasPortType", "radAcctId", "realm"); DataProvider<AccountingDto, Object> dataProvider = new SpringDataProviderBuilder<>( (pageable, o) -> accountingService.pageAccountingRecords(filter, pageable), value -> accountingService.countAccountingRecords(filter)) .withDefaultSort("acctStartTime", SortDirection.DESCENDING) .build(); grid.setDataProvider(dataProvider); grid.getColumns().forEach(column -> column.setResizable(true)); grid.setColumnReorderingAllowed(true); grid.setMinHeight("500px"); grid.setHeight("100%"); TextField search = new TextField(event -> { filter.setSearchText(event.getValue()); grid.getDataProvider().refreshAll(); }); search.setValueChangeMode(ValueChangeMode.EAGER); search.setPlaceholder("Search..."); SetAcctStopTimeDialog setAcctStopTimeDialog = new SetAcctStopTimeDialog((source, bean) -> grid.getDataProvider().refreshItem(bean)); Button setAcctStopTimeButton = new Button("Set Acct Stop Time", event -> { Optional<AccountingDto> optional = grid.getSelectionModel().getFirstSelectedItem(); optional.ifPresent(setAcctStopTimeDialog::set); }); setAcctStopTimeButton.setEnabled(false); grid.asSingleSelect().addValueChangeListener(event -> setAcctStopTimeButton.setEnabled(Objects.nonNull(event.getValue()))); Checkbox onlyActiveSessions = new Checkbox("Filter only active sessions"); onlyActiveSessions.setValue(filter.isSearchOnlyActiveSessions()); onlyActiveSessions.addValueChangeListener(event -> { filter.setSearchOnlyActiveSessions(event.getValue()); grid.getDataProvider().refreshAll(); }); add(new H4("Data from Radius DB - \"radacct\" table")); HorizontalLayout horizontalLayout = new HorizontalLayout(); horizontalLayout.setDefaultVerticalComponentAlignment(FlexComponent.Alignment.BASELINE); horizontalLayout.add(new H3("Accounting")); horizontalLayout.add(setAcctStopTimeButton); horizontalLayout.add(search); horizontalLayout.add(onlyActiveSessions); add(horizontalLayout); add(grid); }
Example 8
Source File: AccountingView.java From radman with MIT License | 4 votes |
SetAcctStopTimeDialog(UpdateListener<AccountingDto> updateListener) { VerticalLayout verticalLayout = new VerticalLayout(); verticalLayout.setPadding(false); verticalLayout.setMargin(false); timestampField = new TextField("Timestamp"); timestampField.setErrorMessage("Timestamp number is required"); timestampField.setValueChangeMode(ValueChangeMode.EAGER); timestampField.addValueChangeListener(event -> isValid(event.getValue())); checkboxNow = new Checkbox("Now"); Button setBtn = new Button("Set"); Button cancelBtn = new Button("Cancel", event -> setOpened(false)); checkboxNow.addValueChangeListener(event -> { if (event.getValue()) { timestampField.setValue(String.valueOf(Instant.now().getEpochSecond())); } timestampField.setEnabled(!event.getValue()); }); timestampField.addValueChangeListener(event -> setBtn.setEnabled(Objects.nonNull(event.getValue()))); setBtn.setEnabled(false); setBtn.addClickListener(event -> { if (isValid(timestampField.getValue())) { try { long timestamp = Long.valueOf(timestampField.getValue()); AccountingDto updatedAccountingDto = accountingService.setAcctStopTime(accountingDto, new Date(timestamp * 1000)); updateListener.onUpdated(this, updatedAccountingDto); setOpened(false); } catch (NotFoundException e) { e.printStackTrace(); } } }); HorizontalLayout controls = new HorizontalLayout(); controls.add(cancelBtn, setBtn); verticalLayout.add(new H3("Set Acct Stop Time"), timestampField, checkboxNow, new Hr(), controls); verticalLayout.setHorizontalComponentAlignment(Alignment.END, controls); add(verticalLayout); }