- Vaadin 7 UI Design By Example:Beginner’s Guide
- Alejandro Duarte
- 223字
- 2021-08-13 16:17:40
Time for action – running the test set
Implement your runSelectedTest
method. This method will be called when the user presses the Time it! button:
public void runSelectedTest() { Long times = Long.parseLong(textField.getValue()); Collection<String> results = TestSetExecutor.execute( (TestSet) combo.getValue(), times); showResults(results); }
What just happened?
Here, we're converting the string stored in the text field to a Long
number using Long.parseLong
(a potential exception, NumberFormatException
, pokes its head).
Once we have the Long
value, we execute the results using a helper class in the biz
package (TestSetExecutor
). This helper class has an execute
method that expects the TestSet
to execute and the number of iterations to perform for each test in the TestSet
. The execute
method returns all the results as a collection of strings that we can proudly show to the user. As proudly as Susan when she presented her code.
Have a go hero – add a validation to Time It
When converting the value in textField
, the method parseLong
will throw an evil NumberFormatException
if the string to parse is not a number. Try it! Use "Time It" and type a wrong numeric expression in the text field. Now try making "Time It" a production-ready application by adding the missing validation (inside the isValid
method) to show a proper error message when incorrect input is given for the textField
component.
- 零基礎(chǔ)搭建量化投資系統(tǒng):以Python為工具
- HBase從入門到實戰(zhàn)
- Servlet/JSP深入詳解
- Effective Python Penetration Testing
- C語言課程設(shè)計
- NGINX Cookbook
- 深入剖析Java虛擬機(jī):源碼剖析與實例詳解(基礎(chǔ)卷)
- 鴻蒙OS應(yīng)用編程實戰(zhàn)
- Zabbix Performance Tuning
- Java Web從入門到精通(第2版)
- Python Programming for Arduino
- 百萬在線:大型游戲服務(wù)端開發(fā)
- 網(wǎng)絡(luò)綜合布線與組網(wǎng)實戰(zhàn)指南
- 精益軟件開發(fā)管理之道
- Mastering Clojure