In the setter method, we are printing out the
value to be set to the standard output, to make sure everything works properly.
The Foundations of Tapestry
[ 58 ]
Do you know that you can have your IDE generating getter and setter
methods automatically? Just provide the private field, and then, in
NetBeans, select Refactor | Encapsulate Fields..., or in Eclipse select
Source | Generate Getters and Setters.... The dialog that opens then
should be easy to understand.
Run the application, and you will see that the Start page looks like this:
As you see, the initial value is displayed in the text box, exactly as we wanted. Now
enter some different value into the text box and click on the Submit button.
You will see some output on the console (in Eclipse, it will be in the Console view, in
NetBeans??”in Bundled Tomcat view), something like this, depending on the message
you have entered:
Setting the message: hi there!
You will notice that the message you have just entered was replaced by the initial
value. Why is that? Well, we didn't instruct Tapestry to remember the new value,
did we? So it forgot immediately and displayed the initial value again. In fact, we
have just witnessed an important Tapestry mechanism at work, but to understand it
better, let's consider a more realistic scenario.
Pages:
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85