Vaadin has a high quality component set for building mobile and desktop web applications in modern browsers
web-padawan on test-refactor
test: avoid using imeouts if po… (compare)
web-padawan on test-refactor
test: refactor open and close h… test: cleanup no longer used he… (compare)
mvn jetty:run
to when the command exits.
public class MainView extends VerticalLayout {
private CustomerService service ;
public Customer customer = new Customer();
private Binder<Customer> binder = new Binder<>(Customer.class);
private Grid<Customer> grid = new Grid(Customer.class);
private Button save = new Button("Save", e -> {
try {
binder.writeBean(customer);
saveCustomer();
updateGrid();
binder.readBean(new Customer());
} catch (ValidationException ex) {
ex.printStackTrace();
}
});
public MainView(CustomerService service) {
this.service = service;
add(
new H1("הוסף לקוח"),
buildForm(),
grid
);
updateGrid(); // update the grid with the sql data
setSizeFull();
}
private void saveCustomer() throws ValidationException {
service.update(customer);
}
private Component buildForm() {
TextField firstName = new TextField("First Name");
TextField lastName = new TextField("Last Name");
TextField id = new TextField("ID");
TextField company= new TextField("Company");
TextField address = new TextField("Address");
TextField phone = new TextField("phone");
TextField created = new TextField("created");
TextField email = new TextField("Email");
Div errorsLayout = new Div();
binder.forField(firstName)
.bind(
Customer::getFirstName,Customer::setFirstName
);
binder.forField(lastName)
.bind(
Customer::getLastName,Customer::setLastName
);
Button reload = new Button("reload", e ->{
try{
binder.readBean(customer);
} catch (Exception ex) {
ex.printStackTrace();
}
});
// Configure UI components
save.setThemeName("primary");
// Wrap components in layouts
HorizontalLayout formLayout = new HorizontalLayout(grid,firstName,lastName,save,reload);
Div wrapperLayout = new Div(formLayout, errorsLayout);
formLayout.setDefaultVerticalComponentAlignment(Alignment.BASELINE);
wrapperLayout.setWidth("100%");
grid.setColumnReorderingAllowed(true);
return wrapperLayout;
}
private void updateGrid() {
List<Customer> customers = service.findAll();
grid.setItems(customers);
}
public List<Customer> findAll() {
return jdbcTemplate.query(
"SELECT ID, FirstName, LastName FROM customer",
(rs, rowNum) -> new Customer(rs.getLong("ID"),
rs.getString("FirstName"), rs.getString("LastName")));
}
For example, just having this:
import { TextFieldElement } from '@vaadin/vaadin-text-field/src/vaadin-text-field';
export class AxiansTextField extends TextFieldElement {}
makes
<vaadin-custom-element label="Custom">
<vaadin-text-field></vaadin-text-field>
</vaadin-custom-element>
like this:
extends TextFieldElement
, then the field appears again :open_mouth:
label-suffix
). I’m using the technique of template-injection I’ve seen in the Vaadin’s text-field elements, but I guess I’m missing something: when importing the custom element, original elements break.
TextFieldElement
: the styles get lost in the original field.
src/vaadin-text-field.js
before the styles, styles don’t get applied!
MemoryBuffer buffer = new MemoryBuffer();
Upload upload = new Upload(buffer);
upload.addSucceededListener(e -> {
SecurityContext context = SecurityContextHolder.getContext();
context.getAuthentication(); // null
});
<vaadin-text-field>
would be import '@vaadin/vaadin-text-field/theme/material/vaadin-text-field.js';
. Note that you shouldn't mix Lumo and Material themed Vaadin components on the same page.
material-color-light
instead of material-light-color
.
DataSeriesItem3d point = new DataSeriesItem3d(x, y, z);
if (x > y && x > z) {
higherX.add(point);
} else if (y > x && y > z) {
higherY.add(point);
} else {
higherZ.add(point);
}
}
}