Skip to content

Commit cb66252

Browse files
committed
Fixes issue #15 - Add h:inputSecret example
1 parent c1b193d commit cb66252

File tree

5 files changed

+128
-0
lines changed

5 files changed

+128
-0
lines changed

jsf/inputSecret/README.md

+3
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
# A h:inputSecret example
2+
3+
This example demonstrates how to use h:inputSecret.

jsf/inputSecret/pom.xml

+25
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
<?xml version="1.0" encoding="UTF-8"?>
2+
3+
<project xmlns="http://maven.apache.org/POM/4.0.0"
4+
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
5+
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
6+
<modelVersion>4.0.0</modelVersion>
7+
<parent>
8+
<artifactId>project</artifactId>
9+
<groupId>jakartaee.examples.jsf</groupId>
10+
<version>8-SNAPSHOT</version>
11+
</parent>
12+
<artifactId>inputSecret</artifactId>
13+
<packaging>war</packaging>
14+
<name>A h:inputSecret example</name>
15+
<dependencies>
16+
<dependency>
17+
<groupId>javax</groupId>
18+
<artifactId>javaee-web-api</artifactId>
19+
<scope>provided</scope>
20+
</dependency>
21+
</dependencies>
22+
<properties>
23+
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
24+
</properties>
25+
</project>
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,58 @@
1+
/*
2+
* Permission to use, copy, modify, and/or distribute this software for any
3+
* purpose with or without fee is hereby granted.
4+
*
5+
* THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR(S) DISCLAIMS ALL WARRANTIES
6+
* WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
7+
* MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR(S) BE LIABLE FOR
8+
* ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
9+
* WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION
10+
* OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN
11+
* CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
12+
*/
13+
package jakartaee.examples.jsf.inputSecret;
14+
15+
import javax.inject.Named;
16+
import javax.enterprise.context.RequestScoped;
17+
18+
/**
19+
* A request scoped bean for using with the h:inputSecret example.
20+
*
21+
* @author Manfred Riem ([email protected])
22+
*/
23+
@Named
24+
@RequestScoped
25+
public class InputSecretBean {
26+
27+
/**
28+
* Stores the part.
29+
*/
30+
private String secret;
31+
32+
/**
33+
* Get the secret.
34+
*
35+
* @return the secret.
36+
*/
37+
public String getSecret() {
38+
return secret;
39+
}
40+
41+
/**
42+
* Set the secret.
43+
*
44+
* @param secret the secret.
45+
*/
46+
public void setSecret(String secret) {
47+
this.secret = secret;
48+
}
49+
50+
/**
51+
* Submit.
52+
*
53+
* @return ""
54+
*/
55+
public String submit() {
56+
return "";
57+
}
58+
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
<?xml version="1.0" encoding="UTF-8"?>
2+
3+
<web-app version="3.0"
4+
xmlns="http://java.sun.com/xml/ns/javaee"
5+
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
6+
xsi:schemaLocation="http://java.sun.com/xml/ns/javaee http://java.sun.com/xml/ns/javaee/web-app_3_0.xsd">
7+
<servlet>
8+
<servlet-name>Faces Servlet</servlet-name>
9+
<servlet-class>javax.faces.webapp.FacesServlet</servlet-class>
10+
<load-on-startup>1</load-on-startup>
11+
</servlet>
12+
<servlet-mapping>
13+
<servlet-name>Faces Servlet</servlet-name>
14+
<url-pattern>*.xhtml</url-pattern>
15+
</servlet-mapping>
16+
<welcome-file-list>
17+
<welcome-file>index.xhtml</welcome-file>
18+
</welcome-file-list>
19+
</web-app>
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
<?xml version='1.0' encoding='UTF-8' ?>
2+
3+
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
4+
5+
<html xmlns="http://www.w3.org/1999/xhtml"
6+
xmlns:h="http://xmlns.jcp.org/jsf/html">
7+
<h:head>
8+
<title>InputSecret example</title>
9+
</h:head>
10+
<h:body>
11+
<p>
12+
This example demonstrates the use of h:inputSecret. Enter your text,
13+
which should not be visible until you submit it and get it echoed
14+
back to you.
15+
</p>
16+
<h:form enctype="multipart/form-data">
17+
<h:inputSecret value="#{inputSecretBean.secret}"/>
18+
<h:commandButton value="Submit" action="#{inputSecretBean.submit}"/>
19+
</h:form>
20+
<br/>
21+
This was your secret text: <h:outputText value="#{inputSecretBean.secret}"/>
22+
</h:body>
23+
</html>

0 commit comments

Comments
 (0)