If the user
decides to subscribe and clicks on the check box, the form gets submitted and the
subscribe property receives a new value, true. We'll want the page to remember
this value, so the subscribe property should be made persistent.
Since the page class has no event handlers that could potentially redirect the user
to another page, the same page will be redisplayed again, but since this time the
value of the subscribe property will be true, the body of the If component will be
shown, meaning the text box will accept the user's email address.
All we need to do to enable all this logic is to add a subscribe persistent property to
the Registration page class and another property to store the email address, which
means adding the following fragment of code:
@Persist
private boolean subscribe;
private String email;
public boolean isSubscribe()
{
return subscribe;
}
public void setSubscribe(boolean subscribe)
{
System.out.println("Setting subscribe: " + subscribe);
this.subscribe = subscribe;
}
public String getEmail()
{
return email;
}
public void setEmail(String email)
{
this.email = email;
}
The output statement in the setter method is, of course, optional.
Pages:
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156