第七色在线视频,2021少妇久久久久久久久久,亚洲欧洲精品成人久久av18,亚洲国产精品特色大片观看完整版,孙宇晨将参加特朗普的晚宴

為了賬號(hào)安全,請(qǐng)及時(shí)綁定郵箱和手機(jī)立即綁定
已解決430363個(gè)問(wèn)題,去搜搜看,總會(huì)有你想問(wèn)的

如何在vaadin 10中創(chuàng)建表并從mysql數(shù)據(jù)庫(kù)中獲取數(shù)據(jù)

如何在vaadin 10中創(chuàng)建表并從mysql數(shù)據(jù)庫(kù)中獲取數(shù)據(jù)

暮色呼如 2023-04-26 17:00:29
我正在使用 vaadin 做一個(gè)項(xiàng)目,我是新手。我想在垂直布局中創(chuàng)建一個(gè)包含 2 或 3 列的表,并通過(guò)我的 Myqsl 數(shù)據(jù)庫(kù)獲取值。誰(shuí)能幫忙解決這個(gè)問(wèn)題。謝謝你的時(shí)間。
查看完整描述

1 回答

?
回首憶惘然

TA貢獻(xiàn)1847條經(jīng)驗(yàn) 獲得超11個(gè)贊

示例示例:

import com.vaadin.flow.component.button.Button;

import com.vaadin.flow.component.grid.Grid;

import com.vaadin.flow.component.orderedlayout.VerticalLayout;

import com.vaadin.flow.component.textfield.TextField;

import com.vaadin.flow.data.binder.Binder;

import com.vaadin.flow.router.Route;


@Route("")

public class VaadinUI extends VerticalLayout {


? ? private final CustomerService service;

? ? private Customer customer;


? ? private Grid<Customer> grid = new Grid<>(Customer.class);

? ? private TextField firstName = new TextField("First name");

? ? private TextField lastName = new TextField("Last name");

? ? private Button save = new Button("Save", e -> saveCustomer());


? ? public VaadinUI(CustomerService service) {

? ? ? ? this.service = service;


? ? ? ? grid.setColumns("firstName", "lastName");

? ? ? ? grid.addSelectionListener(e -> updateForm());


? ? ? ? add(grid, firstName, lastName, save);

? ? ? ? setMargin(true);

? ? ? ? setSpacing(true);

? ? ? ? updateGrid();

? ? }


? ? private void updateGrid() {

? ? ? ? grid.setItems(service.findAll());

? ? ? ? setFormVisible(false);

? ? }


? ? private void updateForm() {

? ? ? ? if (grid.asSingleSelect().isEmpty()) {

? ? ? ? ? ? setFormVisible(false);

? ? ? ? } else {

? ? ? ? ? ? customer = grid.asSingleSelect().getValue();

? ? ? ? ? ? Binder<Customer> binder = new Binder<>(Customer.class);

? ? ? ? ? ? binder.bindInstanceFields(this);

? ? ? ? ? ? binder.setBean(customer);

? ? ? ? ? ? setFormVisible(true);

? ? ? ? }

? ? }


? ? private void setFormVisible(boolean visible) {

? ? ? ? firstName.setVisible(visible);

? ? ? ? lastName.setVisible(visible);

? ? ? ? save.setVisible(visible);

? ? }


? ? private void saveCustomer() {

? ? ? ? service.update(customer);

? ? ? ? updateGrid();

? ? }


}

使用 WebUI 和 MySQL 實(shí)現(xiàn) Vaadin 10 的完整示例:


https://github.com/alejandro-du/mysql-jdbc-vaadin/tree/vaadin10


查看完整回答
反對(duì) 回復(fù) 2023-04-26
  • 1 回答
  • 0 關(guān)注
  • 116 瀏覽
慕課專欄
更多

添加回答

舉報(bào)

0/150
提交
取消
微信客服

購(gòu)課補(bǔ)貼
聯(lián)系客服咨詢優(yōu)惠詳情

幫助反饋 APP下載

慕課網(wǎng)APP
您的移動(dòng)學(xué)習(xí)伙伴

公眾號(hào)

掃描二維碼
關(guān)注慕課網(wǎng)微信公眾號(hào)