01: // Copyright 2007 The Apache Software Foundation
02: //
03: // Licensed under the Apache License, Version 2.0 (the "License");
04: // you may not use this file except in compliance with the License.
05: // You may obtain a copy of the License at
06: //
07: // http://www.apache.org/licenses/LICENSE-2.0
08: //
09: // Unless required by applicable law or agreed to in writing, software
10: // distributed under the License is distributed on an "AS IS" BASIS,
11: // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12: // See the License for the specific language governing permissions and
13: // limitations under the License.
14:
15: package org.apache.tapestry.integration.app1.pages;
16:
17: import org.apache.tapestry.annotations.Component;
18: import org.apache.tapestry.annotations.Inject;
19: import org.apache.tapestry.annotations.Retain;
20: import org.apache.tapestry.corelib.components.Form;
21: import org.apache.tapestry.corelib.components.PasswordField;
22: import org.apache.tapestry.integration.app1.services.UserAuthenticator;
23:
24: public class PasswordFieldDemo {
25: @Retain
26: private String _userName;
27:
28: // Normally not retained, just want to prove that the output value is always the blank string.
29: @Retain
30: private String _password;
31:
32: @Inject
33: private UserAuthenticator _authenticator;
34:
35: @Component(id="password")
36: private PasswordField _passwordField;
37:
38: @Component
39: private Form _form;
40:
41: String onSuccess() {
42: if (!_authenticator.isValid(_userName, _password)) {
43: _form.recordError(_passwordField,
44: "Invalid user name or password.");
45: return null;
46: }
47:
48: return "PostLogin";
49: }
50:
51: public String getPassword() {
52: return _password;
53: }
54:
55: public void setPassword(String password) {
56: _password = password;
57: }
58:
59: public String getUserName() {
60: return _userName;
61: }
62:
63: public void setUserName(String userName) {
64: _userName = userName;
65: }
66:
67: }
|