aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorJohannes Dahlström <johannesd@vaadin.com>2016-07-13 14:32:03 +0300
committerArtur Signell <artur@vaadin.com>2016-08-05 10:19:44 +0300
commit5b7d159969b9f5e4cea45a17f4ed371afa241bb8 (patch)
treebb0c97de4a2a95593c778ba9b2e98b3076a576b1
parent05d5160ce558dc6f18e1bb96f1ba0679e0a283d1 (diff)
downloadvaadin-framework-5b7d159969b9f5e4cea45a17f4ed371afa241bb8.tar.gz
vaadin-framework-5b7d159969b9f5e4cea45a17f4ed371afa241bb8.zip
Vaadin 8 example code changes: Server-Side Components - Common Component Features
Change-Id: Ibdf8fa97cdc4cb9f65c83ea01bb8d6c26dcb2ade
-rw-r--r--documentation/components/components-features.asciidoc55
1 files changed, 22 insertions, 33 deletions
diff --git a/documentation/components/components-features.asciidoc b/documentation/components/components-features.asciidoc
index 625d9b8820..af15d8e250 100644
--- a/documentation/components/components-features.asciidoc
+++ b/documentation/components/components-features.asciidoc
@@ -377,45 +377,37 @@ final Locale[] locales = Locale.getAvailableLocales();
// language of the application can not be done before
// this (and the selection) component are attached to
// the application.
-final ComboBox select = new ComboBox("Select a language") {
+ComboBox<Locale> select = new ComboBox<>("Select a language") {
@Override
public void attach() {
super.attach();
setValue(getLocale());
}
};
-for (int i=0; i<locales.length; i++) {
- select.addItem(locales[i]);
- select.setItemCaption(locales[i],
- locales[i].getDisplayName(displayLocale));
-
- // Automatically select the current locale
- if (locales[i].equals(getLocale()))
- select.setValue(locales[i]);
-}
+
+select.setItems(Arrays.asList(locales));
+select.setCaptionGenerator(locale -> locale.getDisplayName(displayLocale));
+select.setValue(getLocale());
+
layout.addComponent(select);
// Locale code of the selected locale
-final Label localeCode = new Label("");
+Label localeCode = new Label("");
layout.addComponent(localeCode);
// A date field which language the selection will change
-final InlineDateField date =
+InlineDateField date =
new InlineDateField("Calendar in the selected language");
date.setResolution(Resolution.DAY);
layout.addComponent(date);
// Handle language selection
-select.addValueChangeListener(new Property.ValueChangeListener() {
- public void valueChange(ValueChangeEvent event) {
- Locale locale = (Locale) select.getValue();
- date.setLocale(locale);
- localeCode.setValue("Locale code: " +
- locale.getLanguage() + "_" +
- locale.getCountry());
- }
+select.onValueChange(locale -> {
+ date.setLocale(locale);
+ localeCode.setValue("Locale code: " +
+ locale.getLanguage() + "_" +
+ locale.getCountry());
});
-select.setImmediate(true);
----
See the http://demo.vaadin.com/book-examples-vaadin7/book#component.features.locale.selection[on-line example, window="_blank"].
@@ -472,18 +464,14 @@ Client-side state modifications will not be communicated to the server-side and,
more importantly, server-side field components will not accept changes to the
value of a read-only [classname]#Field# component. The latter is an important
security feature, because a malicious user can not fabricate state changes in a
-read-only field. This is handled at the level of [classname]#AbstractField# in
-[methodname]#setValue()#, so you can not change the value programmatically
-either. Calling [methodname]#setValue()# on a read-only field results in
-[classname]#Property.ReadOnlyException#.
-
-Also notice that while the read-only status applies automatically to the
-property value of a field, it does not apply to other component variables. A
-read-only component can accept some other variable changes from the client-side
+read-only field.
+
+Also notice that while the read-only status applies automatically to the value
+of a field, it does not apply to other component variables. A
+read-only component can accept some other state changes from the client-side
and some of such changes could be acceptable, such as change in the scroll bar
-position of a [classname]#Table#. Custom widgets should check the read-only
-state for variables bound to business
-data.
+position of a [classname]#Table#. Custom components should check the read-only
+state for variables bound to business data.
////
TODO: Note this also in the Advanced: Security section.
@@ -691,7 +679,8 @@ component allows inputting text, the focus and insertion point are indicated by
a cursor. Pressing the Tab key moves the focus to the component next in the
__focus order__.
-Focusing is supported by all [classname]#Field# components and also by the [classname]#Upload# component.
+Focusing is supported by all [classname]#Field# and [classname]#Select# components and also by
+components such as [classname]#Button#, [classname]#Upload#, and [classname]#TabSheet#.
The focus order or __tab index__ of a component is defined as a positive integer
value, which you can set with [methodname]#setTabIndex()# and get with
='#n326'>326 327 328 329 330 331 332 333 334 335 336 337 338 339 340 341 342 343 344 345 346 347 348 349 350 351 352 353 354 355 356 357 358 359 360 361 362 363 364 365 366 367 368 369 370 371 372 373 374 375 376 377 378 379 380 381 382 383 384 385 386 387 388 389 390 391 392 393 394 395 396 397 398 399 400 401 402 403 404 405 406 407 408 409 410 411 412 413 414 415 416 417 418 419 420 421 422 423 424 425 426 427 428 429 430 431 432 433 434 435 436 437 438 439 440 441 442 443 444 445 446 447 448 449 450 451 452 453 454 455 456 457 458 459 460 461 462 463 464 465 466 467 468 469 470 471 472 473 474 475 476 477 478 479 480 481 482 483 484 485 486 487 488 489 490 491 492 493 494 495 496 497 498 499 500 501 502 503 504 505 506 507 508 509 510 511 512 513 514 515 516 517 518 519 520 521 522 523 524 525 526 527 528 529 530 531 532 533 534 535 536 537 538 539 540 541 542 543 544 545 546 547 548 549 550 551 552 553 554 555 556 557 558 559 560 561 562 563 564 565 566 567 568 569 570 571 572 573 574 575 576 577 578 579 580 581 582 583 584 585 586 587 588 589 590 591 592 593 594 595 596 597 598 599 600 601 602 603 604 605 606 607 608 609 610 611 612 613 614 615 616 617 618 619 620 621 622 623 624 625 626 627 628 629 630 631 632 633 634 635 636 637 638 639 640 641 642 643 644 645 646 647 648 649 650 651 652 653 654 655 656 657 658 659 660 661 662 663 664 665 666 667 668 669 670 671 672 673 674 675 676 677 678 679 680 681 682 683 684 685 686 687 688 689 690 691 692 693 694 695 696 697 698 699 700 701 702 703 704 705 706 707 708 709 710 711 712 713 714 715 716 717 718 719 720 721 722 723 724 725 726 727 728 729 730 731 732 733 734 735 736 737 738 739 740 741 742 743 744 745 746 747 748 749 750 751 752 753 754 755 756 757 758 759 760 761