KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > springframework > web > servlet > tags > form > PasswordInputTag


1 /*
2  * Copyright 2002-2007 the original author or authors.
3  *
4  * Licensed under the Apache License, Version 2.0 (the "License");
5  * you may not use this file except in compliance with the License.
6  * You may obtain a copy of the License at
7  *
8  * http://www.apache.org/licenses/LICENSE-2.0
9  *
10  * Unless required by applicable law or agreed to in writing, software
11  * distributed under the License is distributed on an "AS IS" BASIS,
12  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13  * See the License for the specific language governing permissions and
14  * limitations under the License.
15  */

16
17 package org.springframework.web.servlet.tags.form;
18
19 import javax.servlet.jsp.JspException JavaDoc;
20
21 /**
22  * Databinding-aware JSP tag for rendering an HTML '<code>input</code>'
23  * element with a '<code>type</code>' of '<code>password</code>'.
24  *
25  * @author Rob Harrop
26  * @author Rick Evans
27  * @since 2.0
28  */

29 public class PasswordInputTag extends InputTag {
30
31     private boolean showPassword = false;
32
33
34     /**
35      * Is the password value to be rendered?
36      * @return <code>true</code> if the password value to be rendered.
37      */

38     public boolean isShowPassword() {
39         return this.showPassword;
40     }
41
42     /**
43      * Is the password value to be rendered?
44      * @param showPassword <code>true</code> if the password value is to be rendered.
45      */

46     public void setShowPassword(boolean showPassword) {
47         this.showPassword = showPassword;
48     }
49
50     /**
51      * Return '<code>password</code>' causing the rendered HTML '<code>input</code>'
52      * element to have a '<code>type</code>' of '<code>password</code>'.
53      */

54     protected String JavaDoc getType() {
55         return "password";
56     }
57
58     /**
59      * The {@link PasswordInputTag} only writes it's value if the
60      * {@link #setShowPassword(boolean) 'showPassword'} property value is
61      * {@link Boolean#TRUE true}.
62      */

63     protected void writeValue(TagWriter tagWriter) throws JspException JavaDoc {
64         if (this.showPassword) {
65             super.writeValue(tagWriter);
66         } else {
67             tagWriter.writeAttribute("value", "");
68         }
69     }
70 }
71
Popular Tags