Você não pode selecionar mais de 25 tópicos Os tópicos devem começar com uma letra ou um número, podem incluir traços ('-') e podem ter até 35 caracteres.

CheckBoxRpcCount.java 2.0KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162
  1. /*
  2. * Copyright 2000-2014 Vaadin Ltd.
  3. *
  4. * Licensed under the Apache License, Version 2.0 (the "License"); you may not
  5. * use this file except in compliance with the License. You may obtain a copy of
  6. * the License at
  7. *
  8. * http://www.apache.org/licenses/LICENSE-2.0
  9. *
  10. * Unless required by applicable law or agreed to in writing, software
  11. * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
  12. * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
  13. * License for the specific language governing permissions and limitations under
  14. * the License.
  15. */
  16. package com.vaadin.tests.components.checkbox;
  17. import com.vaadin.server.VaadinRequest;
  18. import com.vaadin.shared.MouseEventDetails;
  19. import com.vaadin.shared.ui.checkbox.CheckBoxServerRpc;
  20. import com.vaadin.tests.components.AbstractTestUI;
  21. import com.vaadin.ui.CheckBox;
  22. import com.vaadin.ui.Label;
  23. public class CheckBoxRpcCount extends AbstractTestUI {
  24. @Override
  25. protected void setup(VaadinRequest request) {
  26. final Label countLabel = new Label("No RPC calls made yet.");
  27. countLabel.setId("count-label");
  28. addComponent(countLabel);
  29. CheckBox cb = new CheckBox("Click me to start counting...") {
  30. {
  31. // Register a new RPC that counts the number of invocations.
  32. registerRpc(new CheckBoxServerRpc() {
  33. private int rpcCount = 0;
  34. @Override
  35. public void setChecked(boolean checked,
  36. MouseEventDetails mouseEventDetails) {
  37. rpcCount++;
  38. countLabel.setValue(rpcCount + " RPC call(s) made.");
  39. }
  40. });
  41. }
  42. };
  43. addComponent(cb);
  44. }
  45. @Override
  46. protected String getTestDescription() {
  47. return "Test for verifying that no extra RPC calls are made when clicking on CheckBox label.";
  48. }
  49. @Override
  50. protected Integer getTicketNumber() {
  51. return 8259;
  52. }
  53. }