This is because the persistent property, subscribe, was assigned the value true. This value is stored into the session, and we have provided no way to revert it back to false. Of course, you can invalidate the session by closing the browser window, but that wouldn't be a natural thing to do. To solve this problem, let's add another Checkbox component next to the TextField used for email, like this:
t:value="email"/> t:value="unsubscribe" onclick="this.form.submit()"/> I don't want to subscribe
We also need to add another property, unsubscribe, to the Registration page class: private boolean unsubscribe; public boolean isUnsubscribe() { return unsubscribe; Simple Components [ 116 ] } public void setUnsubscribe(boolean unsubscribe) { this.unsubscribe = unsubscribe; } When the user clicks on the new check box, the form will be submitted and the unsubscribe property of the page class will become true. Now what we want is to set the subscribe property to false whenever unsubscribe is set to true. But, where do we implement this logic? The most natural place will be the form submission handler.