group of test apps
Revisión | 5517184481da55ff103f07bedbdd4cfafe190141 (tree) |
---|---|
Tiempo | 2014-01-29 12:06:20 |
Autor | astoria-d <astoria-d@mail...> |
Commiter | astoria-d |
added jsf-test[1-3]
@@ -0,0 +1,23 @@ | ||
1 | +package motoSample; | |
2 | + | |
3 | +import java.io.*; | |
4 | + | |
5 | +public class YenToDoller implements Serializable{ | |
6 | + int yen; | |
7 | + int doller; | |
8 | + //コンストラクタ | |
9 | + public YenToDoller(){} | |
10 | + //yenのゲッター | |
11 | + public int getYen(){ | |
12 | + return yen; | |
13 | + } | |
14 | + //yenのセッター | |
15 | + public void setYen(int yen){ | |
16 | + this.yen=yen; | |
17 | + } | |
18 | + //dollerのゲッター | |
19 | + public int getDoller(){ | |
20 | + doller=yen/110; | |
21 | + return doller; | |
22 | + } | |
23 | +} |
@@ -0,0 +1,12 @@ | ||
1 | +<?xml version="1.0"?> | |
2 | +<!DOCTYPE faces-config PUBLIC | |
3 | + "-//Sun Microsystems, Inc.//DTD JavaServer Faces Config 1.1//EN" | |
4 | + "http://java.sun.com/dtd/web-facesconfig_1_1.dtd"> | |
5 | + | |
6 | +<faces-config> | |
7 | + <managed-bean> | |
8 | + <managed-bean-name>YenToDoller</managed-bean-name> | |
9 | + <managed-bean-class>motoSample.YenToDoller</managed-bean-class> | |
10 | + <managed-bean-scope>session</managed-bean-scope> | |
11 | + </managed-bean> | |
12 | +</faces-config> |
@@ -0,0 +1,25 @@ | ||
1 | +<?xml version='1.0' encoding='UTF-8'?> | |
2 | + | |
3 | +<web-app version="2.5" | |
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_2_5.xsd"> | |
7 | + | |
8 | + <display-name>hellojsf</display-name> | |
9 | + <description>JSF start guide</description> | |
10 | + | |
11 | + <!-- Faces Servlet --> | |
12 | + <servlet> | |
13 | + <servlet-name>Faces Servlet</servlet-name> | |
14 | + <servlet-class>javax.faces.webapp.FacesServlet</servlet-class> | |
15 | + <load-on-startup>1</load-on-startup> | |
16 | + </servlet> | |
17 | + | |
18 | + | |
19 | + <!-- Faces Servlet Mapping --> | |
20 | + <servlet-mapping> | |
21 | + <servlet-name>Faces Servlet</servlet-name> | |
22 | + <url-pattern>*.jsf</url-pattern> | |
23 | + </servlet-mapping> | |
24 | + | |
25 | +</web-app> |
@@ -0,0 +1,82 @@ | ||
1 | +<project default="dist" basedir="."> | |
2 | + | |
3 | +<!-- TODO: set project name here... --> | |
4 | + <property name="proj_name" value="jsf-test1" /> | |
5 | + | |
6 | + <!-- set global properties for this build --> | |
7 | + <property environment="env"/> | |
8 | + <property name="top" value="."/> | |
9 | + <property name="src" value="."/> | |
10 | + <property name="build" value="build"/> | |
11 | + <property name="dist" value="dist"/> | |
12 | + <property name="war_dir" value="${dist}/lib"/> | |
13 | + <property name="war_file" value="${war_dir}/${proj_name}.war"/> | |
14 | + | |
15 | + <property name="webinf" value="${top}/WEB-INF"/> | |
16 | + <property name="web.xml" value="${webinf}/web.xml"/> | |
17 | + <property name="classes" value="${webinf}/classes"/> | |
18 | + <property name="lib" value="${top}/WEB-INF/lib"/> | |
19 | + | |
20 | + <property name="deploy" value="${env.JBOSS_HOME}/standalone/deployments"/> | |
21 | + | |
22 | + | |
23 | + <target name="clean"> | |
24 | + <!-- Delete our the ${build} and ${dist} directory trees --> | |
25 | + <delete dir="${build}"/> | |
26 | + <delete dir="${dist}"/> | |
27 | + <delete dir="${war_dir}"/> | |
28 | + </target> | |
29 | + | |
30 | + <target name="init"> | |
31 | + <!-- Create the build directory structure used by compile and dist --> | |
32 | + <mkdir dir="${build}"/> | |
33 | + <mkdir dir="${dist}"/> | |
34 | + <mkdir dir="${war_dir}"/> | |
35 | + </target> | |
36 | + | |
37 | + <target name="compile" depends="init"> | |
38 | + <!-- Compile the java code from ${src} into ${build} --> | |
39 | + <javac | |
40 | + srcdir="${top}/${src}" | |
41 | + destdir="${build}" | |
42 | + debug="true" | |
43 | + classpath=""/> | |
44 | + | |
45 | + </target> | |
46 | + | |
47 | + <target name="dist" depends="compile"> | |
48 | + | |
49 | + <!-- Put everything in a war file --> | |
50 | + <war warfile="${war_file}" webxml="${web.xml}"> | |
51 | + <!-- include all facelets in root level, and all .properties files anywhere --> | |
52 | + | |
53 | + <fileset dir="${top}/${src}"> | |
54 | + <include name="*.jsp"/> | |
55 | + <include name="**/*.properties"/> | |
56 | + </fileset> | |
57 | + | |
58 | + <!-- include all tag libraries in WEB-INF, and all .xml config files, | |
59 | + but not web.xml (that's handled separately) --> | |
60 | + <webinf dir="${webinf}"> | |
61 | + <include name="*.tld"/> | |
62 | + <include name="*.xml"/> | |
63 | + <exclude name="web.xml"/> | |
64 | + </webinf> | |
65 | + | |
66 | + <!-- include all libraries in WEB-INF/lib --> | |
67 | + <lib dir="${lib}"/> | |
68 | + | |
69 | + <!-- include all compiled classes --> | |
70 | + <classes dir="${build}"/> | |
71 | + | |
72 | + </war> | |
73 | + </target> | |
74 | + | |
75 | + <target name="deploy"> | |
76 | + <!-- Copy the war file to the JBoss deploy directory --> | |
77 | + <copy file="${war_file}" todir="${deploy}"/> | |
78 | + </target> | |
79 | + | |
80 | + <target name="all" depends="clean,dist,deploy"/> | |
81 | + | |
82 | +</project> |
@@ -0,0 +1,18 @@ | ||
1 | +<%@ page contentType="text/html;charset=Shift_JIS" %> | |
2 | +<%@ taglib uri="http://java.sun.com/jsf/html" prefix="h" %> | |
3 | +<%@ taglib uri="http://java.sun.com/jsf/core" prefix="f" %> | |
4 | + | |
5 | +<html> | |
6 | +<head><title>YEN to DOLLER</title></head> | |
7 | +<body> | |
8 | +<f:view> | |
9 | +<h2>日本円を米ドルに換算</h2> | |
10 | +<h:form> | |
11 | +日本円を入力して下さい: | |
12 | +<h:inputText id="number" value="#{YenToDoller.yen}"/> | |
13 | +<h:commandButton value="計算"/> | |
14 | +<p>米ドルでは<h:outputText id="output" value="#{YenToDoller.doller}"/>ドルです。 | |
15 | +</h:form> | |
16 | +</f:view> | |
17 | +</body> | |
18 | +</html> |
@@ -0,0 +1 @@ | ||
1 | +this project is jsf 1.0 / jsp type project. |
@@ -0,0 +1,41 @@ | ||
1 | +package motoSample; | |
2 | + | |
3 | +import java.io.Serializable; | |
4 | +import javax.faces.bean.ManagedBean; | |
5 | +import javax.faces.bean.SessionScoped; | |
6 | +import javax.faces.component.html.HtmlInputText; | |
7 | +import javax.faces.component.html.HtmlOutputText; | |
8 | + | |
9 | + | |
10 | +@ManagedBean | |
11 | +@SessionScoped | |
12 | +public class YenToDoller implements Serializable { | |
13 | + HtmlInputText yen; | |
14 | + HtmlOutputText doller; | |
15 | + //コンストラクタ | |
16 | + public YenToDoller(){} | |
17 | + | |
18 | + //yenのゲッター | |
19 | + public HtmlInputText getYen(){ | |
20 | + return yen; | |
21 | + } | |
22 | + //yenのセッター | |
23 | + public void setYen(HtmlInputText yen){ | |
24 | + this.yen=yen; | |
25 | + //doller.setValue(Integer.parseInt((String)yen.getValue()) / 110); | |
26 | + } | |
27 | + | |
28 | + //dollerのゲッター | |
29 | + public HtmlOutputText getDoller(){ | |
30 | + return doller; | |
31 | + } | |
32 | + public void setDoller(HtmlOutputText doller){ | |
33 | + this.doller=doller; | |
34 | + //doller.setValue(Integer.parseInt((String)yen.getValue()) / 110); | |
35 | + } | |
36 | + | |
37 | + | |
38 | + public void calc() { | |
39 | + doller.setValue(Integer.parseInt((String)yen.getValue()) / 110); | |
40 | + } | |
41 | +} |
@@ -0,0 +1,16 @@ | ||
1 | +<?xml version="1.0" encoding="UTF-8"?> | |
2 | + | |
3 | +<faces-config version="2.0" xmlns="http://java.sun.com/xml/ns/javaee" | |
4 | + xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" | |
5 | + xsi:schemaLocation=" | |
6 | + http://java.sun.com/xml/ns/javaee | |
7 | + http://java.sun.com/xml/ns/javaee/web-facesconfig_2_0.xsd"> | |
8 | + | |
9 | + <managed-bean> | |
10 | + <managed-bean-name>YenToDoller</managed-bean-name> | |
11 | + <managed-bean-class>motoSample.YenToDoller</managed-bean-class> | |
12 | + <managed-bean-scope>session</managed-bean-scope> | |
13 | + </managed-bean> | |
14 | + | |
15 | +</faces-config> | |
16 | + | |
\ No newline at end of file |
@@ -0,0 +1,25 @@ | ||
1 | +<?xml version='1.0' encoding='UTF-8'?> | |
2 | + | |
3 | +<web-app version="2.5" | |
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_2_5.xsd"> | |
7 | + | |
8 | + <display-name>hellojsf</display-name> | |
9 | + <description>JSF start guide</description> | |
10 | + | |
11 | + <!-- Faces Servlet --> | |
12 | + <servlet> | |
13 | + <servlet-name>Faces Servlet</servlet-name> | |
14 | + <servlet-class>javax.faces.webapp.FacesServlet</servlet-class> | |
15 | + <load-on-startup>1</load-on-startup> | |
16 | + </servlet> | |
17 | + | |
18 | + | |
19 | + <!-- Faces Servlet Mapping --> | |
20 | + <servlet-mapping> | |
21 | + <servlet-name>Faces Servlet</servlet-name> | |
22 | + <url-pattern>*.jsf</url-pattern> | |
23 | + </servlet-mapping> | |
24 | + | |
25 | +</web-app> |
@@ -0,0 +1,86 @@ | ||
1 | +<project default="dist" basedir="."> | |
2 | + | |
3 | +<!-- TODO: set project name here... --> | |
4 | + <property name="proj_name" value="jsf-test2" /> | |
5 | + | |
6 | + <!-- set global properties for this build --> | |
7 | + <property environment="env"/> | |
8 | + <property name="top" value="."/> | |
9 | + <property name="src" value="."/> | |
10 | + <property name="build" value="build"/> | |
11 | + <property name="dist" value="dist"/> | |
12 | + <property name="war_dir" value="${dist}/lib"/> | |
13 | + <property name="war_file" value="${war_dir}/${proj_name}.war"/> | |
14 | + | |
15 | + <property name="webinf" value="${top}/WEB-INF"/> | |
16 | + <property name="web.xml" value="${webinf}/web.xml"/> | |
17 | + <property name="classes" value="${webinf}/classes"/> | |
18 | + <property name="lib" value="${top}/WEB-INF/lib"/> | |
19 | + | |
20 | + <property name="deploy" value="${env.JBOSS_HOME}/standalone/deployments"/> | |
21 | + | |
22 | + | |
23 | +<!-- JSF 2.0 annotation resolve --> | |
24 | + <property name="jsf" value="${env.JBOSS_HOME}\modules\javax\faces\api\main\jboss-jsf-api_2.1_spec-2.0.0.Final.jar"/> | |
25 | + | |
26 | + | |
27 | + <target name="clean"> | |
28 | + <!-- Delete our the ${build} and ${dist} directory trees --> | |
29 | + <delete dir="${build}"/> | |
30 | + <delete dir="${dist}"/> | |
31 | + <delete dir="${war_dir}"/> | |
32 | + </target> | |
33 | + | |
34 | + <target name="init"> | |
35 | + <!-- Create the build directory structure used by compile and dist --> | |
36 | + <mkdir dir="${build}"/> | |
37 | + <mkdir dir="${dist}"/> | |
38 | + <mkdir dir="${war_dir}"/> | |
39 | + </target> | |
40 | + | |
41 | + <target name="compile" depends="init"> | |
42 | + <!-- Compile the java code from ${src} into ${build} --> | |
43 | + <javac | |
44 | + srcdir="${top}/${src}" | |
45 | + destdir="${build}" | |
46 | + debug="true" | |
47 | + classpath="${jsf}"/> | |
48 | + | |
49 | + </target> | |
50 | + | |
51 | + <target name="dist" depends="compile"> | |
52 | + | |
53 | + <!-- Put everything in a war file --> | |
54 | + <war warfile="${war_file}" webxml="${web.xml}"> | |
55 | + <!-- include all facelets in root level, and all .properties files anywhere --> | |
56 | + | |
57 | + <fileset dir="${top}/${src}"> | |
58 | + <include name="*.xhtml"/> | |
59 | + <include name="**/*.properties"/> | |
60 | + </fileset> | |
61 | + | |
62 | + <!-- include all tag libraries in WEB-INF, and all .xml config files, | |
63 | + but not web.xml (that's handled separately) --> | |
64 | + <webinf dir="${webinf}"> | |
65 | + <include name="*.tld"/> | |
66 | + <include name="*.xml"/> | |
67 | + <exclude name="web.xml"/> | |
68 | + </webinf> | |
69 | + | |
70 | + <!-- include all libraries in WEB-INF/lib --> | |
71 | + <lib dir="${lib}"/> | |
72 | + | |
73 | + <!-- include all compiled classes --> | |
74 | + <classes dir="${build}"/> | |
75 | + | |
76 | + </war> | |
77 | + </target> | |
78 | + | |
79 | + <target name="deploy"> | |
80 | + <!-- Copy the war file to the JBoss deploy directory --> | |
81 | + <copy file="${war_file}" todir="${deploy}"/> | |
82 | + </target> | |
83 | + | |
84 | + <target name="all" depends="clean,dist,deploy"/> | |
85 | + | |
86 | +</project> |
@@ -0,0 +1,28 @@ | ||
1 | +<?xml version="1.0" encoding="Shift_JIS" ?> | |
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:f="http://java.sun.com/jsf/core" | |
7 | + xmlns:h="http://java.sun.com/jsf/html"> | |
8 | +<head> | |
9 | +<meta http-equiv="Content-Type" content="text/html; charset=Shift_JIS" /> | |
10 | +<title>Insert title here</title> | |
11 | +</head> | |
12 | + | |
13 | + | |
14 | +<body> | |
15 | +<f:view> | |
16 | +<h2>日本円を米ドルに換算</h2> | |
17 | +<h:form> | |
18 | +日本円を入力して下さい: | |
19 | +<h:inputText binding="${YenToDoller.yen}"/> | |
20 | +<h:commandButton value="計算" action="${YenToDoller.calc}" /> | |
21 | + | |
22 | +<p>米ドルでは<h:outputText binding="${YenToDoller.doller}"/>ドルです。</p> | |
23 | + | |
24 | + | |
25 | +</h:form> | |
26 | +</f:view> | |
27 | +</body> | |
28 | +</html> |
@@ -0,0 +1,4 @@ | ||
1 | +this project is jsf 2.0 / xhtml (facelets) type project. | |
2 | +no annotation is used in this project. faces-config.xml will specify the full class name. | |
3 | + | |
4 | + |
@@ -0,0 +1,25 @@ | ||
1 | +<?xml version="1.0" encoding="UTF-8"?> | |
2 | +<!-- | |
3 | + JBoss, Home of Professional Open Source | |
4 | + Copyright 2013, Red Hat, Inc. and/or its affiliates, and individual | |
5 | + contributors by the @authors tag. See the copyright.txt in the | |
6 | + distribution for a full listing of individual contributors. | |
7 | + | |
8 | + Licensed under the Apache License, Version 2.0 (the "License"); | |
9 | + you may not use this file except in compliance with the License. | |
10 | + You may obtain a copy of the License at | |
11 | + http://www.apache.org/licenses/LICENSE-2.0 | |
12 | + Unless required by applicable law or agreed to in writing, software | |
13 | + distributed under the License is distributed on an "AS IS" BASIS, | |
14 | + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | |
15 | + See the License for the specific language governing permissions and | |
16 | + limitations under the License. | |
17 | +--> | |
18 | +<!-- This file can be an empty text file (0 bytes) --> | |
19 | +<!-- We're declaring the schema to save you time if you do have to configure | |
20 | + this in the future --> | |
21 | +<beans xmlns="http://java.sun.com/xml/ns/javaee" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" | |
22 | + xsi:schemaLocation=" | |
23 | + http://java.sun.com/xml/ns/javaee | |
24 | + http://java.sun.com/xml/ns/javaee/beans_1_0.xsd"> | |
25 | +</beans> |
@@ -0,0 +1,199 @@ | ||
1 | +package motoSample; | |
2 | + | |
3 | +import java.io.Serializable; | |
4 | +import javax.faces.bean.ManagedBean; | |
5 | +import javax.faces.bean.ViewScoped; | |
6 | +import javax.faces.bean.ManagedProperty; | |
7 | +import javax.faces.context.FacesContext; | |
8 | +import javax.servlet.http.HttpServletRequest; | |
9 | + | |
10 | +import java.util.logging.Logger; | |
11 | +import javax.inject.Inject; | |
12 | +import java.sql.Connection; | |
13 | +import java.sql.SQLException; | |
14 | +import java.sql.ResultSet; | |
15 | +import java.sql.Statement; | |
16 | +import java.sql.PreparedStatement; | |
17 | + | |
18 | + | |
19 | +import java.util.ArrayList; | |
20 | +import javax.faces.model.SelectItem; | |
21 | +import javax.faces.event.ValueChangeEvent; | |
22 | +import javax.annotation.PostConstruct; | |
23 | + | |
24 | +import java.util.Date; | |
25 | +import java.text.SimpleDateFormat; | |
26 | + | |
27 | + | |
28 | +@ManagedBean | |
29 | +@ViewScoped | |
30 | +public class ChatBean implements Serializable { | |
31 | + | |
32 | + @Inject | |
33 | + private Logger log; | |
34 | + | |
35 | + @Inject | |
36 | + private FacesContext context; | |
37 | + | |
38 | + //inject user bean | |
39 | + @ManagedProperty("#{userBean}") | |
40 | + private UserBean userBean; | |
41 | + | |
42 | + private String msg; | |
43 | + private String chatRoom; | |
44 | + private int oldestChatId; | |
45 | + private ArrayList<ChatMessage> msgList; | |
46 | + | |
47 | + public final static int LIST_LOAD_SIZE = 10; | |
48 | + | |
49 | + public void setMsg(String msg) { | |
50 | + this.msg = msg; | |
51 | + } | |
52 | + public String getMsg() { | |
53 | + return ""; | |
54 | + } | |
55 | + public int getOldestChatId() { | |
56 | + return oldestChatId; | |
57 | + } | |
58 | + public void setOldestChatId(int oldestChatId) { | |
59 | + this.oldestChatId = oldestChatId; | |
60 | + } | |
61 | + | |
62 | + public void setChatRoom(String chatRoom) { | |
63 | + this.chatRoom = chatRoom; | |
64 | + } | |
65 | + public void chatRoomChanged(ValueChangeEvent e) { | |
66 | + //chat room is changed. initialize the msg list. | |
67 | + chatRoom = e.getNewValue().toString(); | |
68 | + log.info("chat room changed: " + this.chatRoom); | |
69 | + initMsgList(); | |
70 | + } | |
71 | + public String getChatRoom() { | |
72 | + return chatRoom; | |
73 | + } | |
74 | + | |
75 | + //userBean injection. setter only. | |
76 | + public void setUserBean(UserBean userBean) { | |
77 | + this.userBean = userBean; | |
78 | + } | |
79 | + | |
80 | + ///chat list data | |
81 | + public class ChatMessage { | |
82 | + private String uname; | |
83 | + private String msg; | |
84 | + private String date; | |
85 | + public String getUname() { | |
86 | + return uname; | |
87 | + } | |
88 | + public String getMsg() { | |
89 | + return msg; | |
90 | + } | |
91 | + public String getDate() { | |
92 | + return date; | |
93 | + } | |
94 | + } | |
95 | + | |
96 | + private void initMsgList(){ | |
97 | + log.info("initMsgList: " + chatRoom); | |
98 | + try { | |
99 | + Connection conn = Resources.getConnection(); | |
100 | + String uid = userBean.getUid(); | |
101 | + String sqlString = "select user_id, message, msg_date, msg_id from tb_chat_msg where chat_room=\'" + chatRoom +"\' order by msg_id desc"; | |
102 | + | |
103 | + Statement statement = conn.createStatement(); | |
104 | + ResultSet rs = statement.executeQuery(sqlString); | |
105 | + | |
106 | + if (msgList == null) { | |
107 | + msgList = new ArrayList<ChatMessage>(); | |
108 | + } | |
109 | + else { | |
110 | + msgList.clear(); | |
111 | + } | |
112 | + int load_cnt = 0; | |
113 | + while (rs.next()) { | |
114 | + ChatMessage m = new ChatMessage(); | |
115 | + m.uname = rs.getString("user_id"); | |
116 | + m.msg = rs.getString("message"); | |
117 | + m.date = rs.getString("msg_date"); | |
118 | + oldestChatId = rs.getInt("msg_id"); | |
119 | + msgList.add(0, m); | |
120 | + if (++load_cnt == LIST_LOAD_SIZE) | |
121 | + break; | |
122 | + } | |
123 | + | |
124 | + rs.close(); | |
125 | + conn.close(); | |
126 | + } | |
127 | + catch (SQLException se) { | |
128 | + log.severe("sql err!!!"); | |
129 | + } | |
130 | + } | |
131 | + | |
132 | + public ArrayList<ChatMessage> getMsgList(){ | |
133 | + //log.info("getMsgList: " + chatRoom); | |
134 | + return msgList; | |
135 | + } | |
136 | + | |
137 | + public void doPost() { | |
138 | + //skip empty message.... | |
139 | + if (msg.equals("")) | |
140 | + return; | |
141 | + | |
142 | + Date d = new Date(); | |
143 | + SimpleDateFormat df = new SimpleDateFormat("yyyy/MM/dd HH:mm:ss"); | |
144 | + | |
145 | + /* | |
146 | + log.info("user = " + userBean.getUid()); | |
147 | + log.info("chat room = " + chatRoom); | |
148 | + log.info("date = " + df.format(d)); | |
149 | + */ | |
150 | + | |
151 | + try { | |
152 | + Connection conn = Resources.getConnection(); | |
153 | + String sqlString = "insert into tb_chat_msg (user_id , chat_room , message , msg_date, deleted) values (?, ?, ?, ?, ?)"; | |
154 | + //log.info("sql = " + sqlString); | |
155 | + | |
156 | + PreparedStatement ps= conn.prepareStatement(sqlString); | |
157 | + ps.setString(1, userBean.getUid()); | |
158 | + ps.setString(2, chatRoom); | |
159 | + ps.setString(3, msg); | |
160 | + ps.setString(4, df.format(d)); | |
161 | + ps.setString(5, "false"); | |
162 | + | |
163 | + int cnt = ps.executeUpdate(); | |
164 | + log.info(cnt + " records inserted."); | |
165 | + | |
166 | + conn.close(); | |
167 | + | |
168 | + //add msgList... | |
169 | + ChatMessage m = new ChatMessage(); | |
170 | + m.uname = userBean.getUid(); | |
171 | + m.msg = msg; | |
172 | + m.date = df.format(d); | |
173 | + msgList.add(m); | |
174 | + } | |
175 | + catch (SQLException se) { | |
176 | + log.severe("sql err!!!"); | |
177 | + } | |
178 | + | |
179 | + } | |
180 | + | |
181 | + @PostConstruct | |
182 | + public void postInit() { | |
183 | + //log.info("PostConstruct userBean: " + userBean); | |
184 | + //log.info("PostConstruct getFlights: " + userBean.getFlights()); | |
185 | + ArrayList<SelectItem> flights = userBean.getFlights(); | |
186 | + if (flights != null) { | |
187 | + chatRoom = userBean.getFlights().get(0).getValue().toString(); | |
188 | + | |
189 | + log.info("method: " + ((HttpServletRequest) context.getExternalContext().getRequest()).getMethod()); | |
190 | + if (((HttpServletRequest) context.getExternalContext().getRequest()).getMethod().equals("GET")) { | |
191 | + log.info("get access. init chat list"); | |
192 | + //in get access, the chat room is not selected.. | |
193 | + initMsgList(); | |
194 | + } | |
195 | + } | |
196 | + | |
197 | + //log.info("PostConstruct: " + chatRoom); | |
198 | + } | |
199 | +} |
@@ -0,0 +1,63 @@ | ||
1 | +package motoSample; | |
2 | + | |
3 | +import java.io.IOException; | |
4 | +import java.util.logging.Logger; | |
5 | + | |
6 | + | |
7 | +import javax.servlet.Filter; | |
8 | +import javax.servlet.FilterChain; | |
9 | +import javax.servlet.FilterConfig; | |
10 | +import javax.servlet.ServletException; | |
11 | +import javax.servlet.ServletRequest; | |
12 | +import javax.servlet.ServletResponse; | |
13 | +import javax.servlet.http.HttpSession; | |
14 | +import javax.servlet.http.HttpServletRequest; | |
15 | +import javax.servlet.http.HttpServletResponse; | |
16 | + | |
17 | + | |
18 | +/** | |
19 | + * Filter checks if LoginBean has loginIn property set to true. | |
20 | + * If it is not set then request is being redirected to the login.xhml page. | |
21 | + * | |
22 | + * @author itcuties | |
23 | + * | |
24 | + */ | |
25 | +public class LoginFilter implements Filter { | |
26 | + Logger logger = Logger.getLogger(getClass().getName()); | |
27 | + | |
28 | + /** | |
29 | + * Checks if user is logged in. If not it redirects to the login.xhtml page. | |
30 | + */ | |
31 | + public void doFilter(ServletRequest request, ServletResponse response, FilterChain chain) throws IOException, ServletException { | |
32 | + | |
33 | + HttpSession session = ((HttpServletRequest)request).getSession(); | |
34 | + // Get the userBean from session attribute | |
35 | + UserBean ubean = (UserBean)session.getAttribute("userBean"); | |
36 | + | |
37 | + logger.info("cpath:" + ((HttpServletRequest) request).getContextPath()); | |
38 | + logger.info("uri:" + ((HttpServletRequest) request).getRequestURI()); | |
39 | + | |
40 | + String req_url = ((HttpServletRequest) request).getRequestURI().replace(((HttpServletRequest) request).getContextPath(), ""); | |
41 | + logger.info("request_url:" + req_url); | |
42 | + session.setAttribute("request_url", req_url); | |
43 | + | |
44 | + // For the first application request there is no userBean in the session so user needs to log in | |
45 | + // For other requests userBean is present but we need to check if user has logged in successfully | |
46 | + if (ubean == null || !ubean.isLoggedIn()) { | |
47 | + String contextPath = ((HttpServletRequest)request).getContextPath(); | |
48 | + ((HttpServletResponse)response).sendRedirect(contextPath + "/login.jsf"); | |
49 | + } | |
50 | + | |
51 | + chain.doFilter(request, response); | |
52 | + | |
53 | + } | |
54 | + | |
55 | + public void init(FilterConfig config) throws ServletException { | |
56 | + // Nothing to do here! | |
57 | + } | |
58 | + | |
59 | + public void destroy() { | |
60 | + // Nothing to do here! | |
61 | + } | |
62 | + | |
63 | +} |
@@ -0,0 +1,11 @@ | ||
1 | +package motoSample; | |
2 | + | |
3 | +import javax.inject.Named; | |
4 | + | |
5 | +@Named | |
6 | +public class MessageServerBean { | |
7 | + | |
8 | + public String getMessage() { | |
9 | + return "Hello World!"; | |
10 | + } | |
11 | +} |
@@ -0,0 +1,63 @@ | ||
1 | +package motoSample; | |
2 | + | |
3 | +import javax.inject.Inject; | |
4 | +import javax.enterprise.inject.Produces; | |
5 | +import javax.enterprise.inject.spi.InjectionPoint; | |
6 | +import java.util.logging.Logger; | |
7 | + | |
8 | +import javax.enterprise.context.RequestScoped; | |
9 | +import javax.faces.context.FacesContext; | |
10 | + | |
11 | +import javax.naming.InitialContext; | |
12 | +import javax.naming.NamingException; | |
13 | +import javax.sql.DataSource; | |
14 | +import java.sql.Connection; | |
15 | +import java.sql.SQLException; | |
16 | + | |
17 | + | |
18 | +import javax.faces.context.FacesContext; | |
19 | +import javax.faces.context.ExternalContext; | |
20 | +import javax.servlet.http.HttpServletRequest; | |
21 | +import javax.servlet.http.HttpSession; | |
22 | + | |
23 | +public class Resources { | |
24 | + | |
25 | + private static Logger log = Logger.getLogger(Resources.class.getName()); | |
26 | + | |
27 | + //injection producer.... | |
28 | + @Produces | |
29 | + public Logger produceLog(InjectionPoint injectionPoint) { | |
30 | + return Logger.getLogger(injectionPoint.getMember().getDeclaringClass().getName()); | |
31 | + } | |
32 | + | |
33 | + @Produces | |
34 | + @RequestScoped | |
35 | + public FacesContext produceFacesContext() { | |
36 | + return FacesContext.getCurrentInstance(); | |
37 | + } | |
38 | + | |
39 | + public static Connection getConnection() { | |
40 | + try { | |
41 | + InitialContext ctx = new InitialContext(); | |
42 | + DataSource ds = (DataSource) ctx.lookup("java:jboss/datasource/jsf-test3"); | |
43 | + Connection conn = ds.getConnection(); | |
44 | + return conn; | |
45 | + } | |
46 | + catch (NamingException ne) { | |
47 | + log.severe("context not found!!!"); | |
48 | + } | |
49 | + catch (SQLException se) { | |
50 | + log.severe("sql get connection err!!!"); | |
51 | + } | |
52 | + return null; | |
53 | + } | |
54 | + | |
55 | + | |
56 | + public static HttpSession getSession() { | |
57 | + FacesContext context = FacesContext.getCurrentInstance(); | |
58 | + ExternalContext exContext = context.getExternalContext(); | |
59 | + HttpServletRequest req = (HttpServletRequest) exContext.getRequest(); | |
60 | + HttpSession session = req.getSession(); | |
61 | + return session; | |
62 | + } | |
63 | +} |
@@ -0,0 +1,134 @@ | ||
1 | +package motoSample; | |
2 | + | |
3 | +import java.io.Serializable; | |
4 | +import javax.faces.bean.ManagedBean; | |
5 | +import javax.faces.bean.SessionScoped; | |
6 | + | |
7 | +import java.util.logging.Logger; | |
8 | +import javax.inject.Inject; | |
9 | +import java.sql.Connection; | |
10 | +import java.sql.SQLException; | |
11 | +import java.sql.ResultSet; | |
12 | +import java.sql.Statement; | |
13 | + | |
14 | +import javax.servlet.http.HttpSession; | |
15 | + | |
16 | +import java.util.ArrayList; | |
17 | +import javax.faces.model.SelectItem; | |
18 | + | |
19 | +@ManagedBean | |
20 | +@SessionScoped | |
21 | +public class UserBean implements Serializable { | |
22 | + | |
23 | + @Inject | |
24 | + private Logger log; | |
25 | + | |
26 | + private String uid; | |
27 | + private String pwd; | |
28 | + private String uname; | |
29 | + | |
30 | + private ArrayList<SelectItem> flights; | |
31 | + | |
32 | + private boolean login = false; | |
33 | + | |
34 | + public boolean isLoggedIn() { | |
35 | + return login; | |
36 | + } | |
37 | + | |
38 | + public String getUid() { | |
39 | + return uid; | |
40 | + } | |
41 | + public String getPwd() { | |
42 | + return pwd; | |
43 | + } | |
44 | + public String getUname() { | |
45 | + return uname; | |
46 | + } | |
47 | + public void setUid(String uid) { | |
48 | + this.uid = uid; | |
49 | + } | |
50 | + public void setPwd(String pwd) { | |
51 | + this.pwd = pwd; | |
52 | + } | |
53 | + | |
54 | + public ArrayList<SelectItem> getFlights() { | |
55 | + return flights; | |
56 | + } | |
57 | + | |
58 | + private void initUserFlights(Connection conn) { | |
59 | + if (flights == null) { | |
60 | + flights = new ArrayList<SelectItem>(); | |
61 | + } | |
62 | + flights.clear(); | |
63 | + | |
64 | + try { | |
65 | + String sqlString = "select flight_name from tb_user_flights where user_id=\'" + uid +"\'"; | |
66 | + Statement statement = conn.createStatement(); | |
67 | + ResultSet rs = statement.executeQuery(sqlString); | |
68 | + while(rs.next()) { | |
69 | + String ft = rs.getString("flight_name"); | |
70 | + flights.add(new SelectItem(ft, ft)); | |
71 | + } | |
72 | + statement.close(); | |
73 | + } | |
74 | + catch (SQLException se) { | |
75 | + log.severe("sql flight err!!!"); | |
76 | + } | |
77 | + } | |
78 | + | |
79 | + public String doLogin() { | |
80 | + | |
81 | + try { | |
82 | + Connection conn = Resources.getConnection(); | |
83 | + | |
84 | + String sqlString = "select user_password, user_name from tb_users where user_id=\'" + uid +"\'"; | |
85 | + | |
86 | + Statement statement = conn.createStatement(); | |
87 | + statement.setQueryTimeout(30); // set timeout to 30 sec. | |
88 | + | |
89 | + ResultSet rs = statement.executeQuery(sqlString); | |
90 | + if(rs.next()) | |
91 | + { | |
92 | + // read the result set | |
93 | + String db_pwd = rs.getString("user_password"); | |
94 | + //log.info("pwd = " + db_pwd); | |
95 | + //log.info("name = " + rs.getString("user_name")); | |
96 | + | |
97 | + if (pwd.equals(db_pwd)) { | |
98 | + login = true; | |
99 | + this.uname = rs.getString("user_name"); | |
100 | + statement.close(); | |
101 | + | |
102 | + initUserFlights(conn); | |
103 | + | |
104 | + conn.close(); | |
105 | + | |
106 | + HttpSession session = Resources.getSession(); | |
107 | + | |
108 | + ///after login, redirect to the user specified url. | |
109 | + return session.getAttribute("request_url").toString() + "?faces-redirect=true"; | |
110 | + } | |
111 | + | |
112 | + } | |
113 | + else { | |
114 | + log.info("uid " + uid + "not found..."); | |
115 | + } | |
116 | + | |
117 | + statement.close(); | |
118 | + conn.close(); | |
119 | + } | |
120 | + catch (SQLException se) { | |
121 | + log.severe("sql err!!!"); | |
122 | + } | |
123 | + /* | |
124 | + */ | |
125 | + | |
126 | + return ""; | |
127 | + } | |
128 | + | |
129 | + public String doLogout() { | |
130 | + login = false; | |
131 | + return "/login.jsf"; | |
132 | + } | |
133 | + | |
134 | +} |
@@ -0,0 +1,39 @@ | ||
1 | +package motoSample; | |
2 | + | |
3 | +import java.io.Serializable; | |
4 | +import javax.faces.bean.ManagedBean; | |
5 | +import javax.faces.bean.RequestScoped; | |
6 | +import javax.inject.Named; | |
7 | + | |
8 | + | |
9 | +@ManagedBean | |
10 | +@RequestScoped | |
11 | +public class YenToDoller implements Serializable { | |
12 | + String yen; | |
13 | + String doller; | |
14 | + //コンストラクタ | |
15 | + public YenToDoller(){} | |
16 | + | |
17 | + //yenのゲッター | |
18 | + public String getYen(){ | |
19 | + return yen; | |
20 | + } | |
21 | + //yenのセッター | |
22 | + public void setYen(String yen){ | |
23 | + this.yen=yen; | |
24 | + //doller.setValue(Integer.parseInt((String)yen.getValue()) / 110); | |
25 | + } | |
26 | + | |
27 | + //dollerのゲッター | |
28 | + public String getDoller(){ | |
29 | + return doller; | |
30 | + } | |
31 | + public void setDoller(String doller){ | |
32 | + this.doller=doller; | |
33 | + } | |
34 | + | |
35 | + | |
36 | + public void calc() { | |
37 | + doller = Integer.toString(Integer.parseInt(yen) / 110); | |
38 | + } | |
39 | +} |
@@ -0,0 +1,10 @@ | ||
1 | +<?xml version="1.0" encoding="UTF-8"?> | |
2 | + | |
3 | +<datasources xmlns="http://www.jboss.org/ironjacamar/schema" | |
4 | + xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" | |
5 | + xsi:schemaLocation="http://www.jboss.org/ironjacamar/schema http://docs.jboss.org/ironjacamar/schema/datasources_1_0.xsd"> | |
6 | + <datasource jndi-name="java:jboss/datasource/jsf-test3" pool-name="jsf-test3-pool" enabled="true" > | |
7 | + <connection-url>jdbc:sqlite:C:/Users/dmotooka/AppData/sqlite/moto-test2.db</connection-url> | |
8 | + <driver>sqlite</driver> | |
9 | + </datasource> | |
10 | +</datasources> |
@@ -0,0 +1,26 @@ | ||
1 | +<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" | |
2 | +"http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> | |
3 | +<html xmlns="http://www.w3.org/1999/xhtml" | |
4 | + xmlns:h="http://java.sun.com/jsf/html" | |
5 | + xmlns:composite="http://java.sun.com/jsf/composite" | |
6 | + xmlns:f="http://java.sun.com/jsf/core" | |
7 | + xmlns:ui="http://java.sun.com/jsf/facelets"> | |
8 | +<h:head> | |
9 | +<meta http-equiv="Content-Type" content="text/html; charset=UTF-8" /> | |
10 | + | |
11 | +<title> | |
12 | + <ui:insert name="pageTitle">JFS Template</ui:insert> | |
13 | +</title> | |
14 | +</h:head> | |
15 | + | |
16 | +<body> | |
17 | + | |
18 | + <div id="pageHeader" style="FONT-FAMILY: 'Britannic Bold'; BACKGROUND-COLOR: #800000; color:#FFF"> | |
19 | + <h1>moto chat app</h1> | |
20 | + </div> | |
21 | + | |
22 | + <!-- c. 各ページで異なるコンテンツを表示する領域 --> | |
23 | + <ui:insert name="body">ページごとのコンテンツ</ui:insert> | |
24 | + | |
25 | +</body> | |
26 | +</html> | |
\ No newline at end of file |
@@ -0,0 +1,48 @@ | ||
1 | +<?xml version='1.0' encoding='UTF-8'?> | |
2 | + | |
3 | +<web-app version="2.5" | |
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_2_5.xsd"> | |
7 | + | |
8 | + <display-name>hellojsf</display-name> | |
9 | + <description>JSF start guide</description> | |
10 | + | |
11 | + <!-- Faces Servlet --> | |
12 | + <servlet> | |
13 | + <servlet-name>Faces Servlet</servlet-name> | |
14 | + <servlet-class>javax.faces.webapp.FacesServlet</servlet-class> | |
15 | + <load-on-startup>1</load-on-startup> | |
16 | + </servlet> | |
17 | + | |
18 | + | |
19 | + <!-- Faces Servlet Mapping --> | |
20 | + <servlet-mapping> | |
21 | + <servlet-name>Faces Servlet</servlet-name> | |
22 | + <url-pattern>*.jsf</url-pattern> | |
23 | + </servlet-mapping> | |
24 | + | |
25 | + | |
26 | + <!-- Login filter --> | |
27 | + <filter> | |
28 | + <filter-name>LoginFilter</filter-name> | |
29 | + <filter-class>motoSample.LoginFilter</filter-class> | |
30 | + </filter> | |
31 | + <!-- all files under /secured/* are filtered by login filter --> | |
32 | + <filter-mapping> | |
33 | + <filter-name>LoginFilter</filter-name> | |
34 | + <url-pattern>/secured/*</url-pattern> | |
35 | + </filter-mapping> | |
36 | + | |
37 | + <!-- block .xhtml access --> | |
38 | + <security-constraint> | |
39 | + <display-name>XHTML Security</display-name> | |
40 | + <web-resource-collection> | |
41 | + <web-resource-name>Protected Area</web-resource-name> | |
42 | + <url-pattern>*.xhtml</url-pattern> | |
43 | + </web-resource-collection> | |
44 | + <auth-constraint> | |
45 | + </auth-constraint> | |
46 | + </security-constraint> | |
47 | + | |
48 | +</web-app> |
@@ -0,0 +1,88 @@ | ||
1 | +<project default="dist" basedir="."> | |
2 | + | |
3 | +<!-- TODO: set project name here... --> | |
4 | + <property name="proj_name" value="jsf-test3" /> | |
5 | + | |
6 | + <!-- set global properties for this build --> | |
7 | + <property environment="env"/> | |
8 | + <property name="top" value="."/> | |
9 | + <property name="src" value="."/> | |
10 | + <property name="build" value="build"/> | |
11 | + <property name="dist" value="dist"/> | |
12 | + <property name="war_dir" value="${dist}/lib"/> | |
13 | + <property name="war_file" value="${war_dir}/${proj_name}.war"/> | |
14 | + | |
15 | + <property name="webinf" value="${top}/WEB-INF"/> | |
16 | + <property name="web.xml" value="${webinf}/web.xml"/> | |
17 | + <property name="classes" value="${webinf}/classes"/> | |
18 | + <property name="lib" value="${top}/WEB-INF/lib"/> | |
19 | + <property name="deploy" value="${env.JBOSS_HOME}/standalone/deployments"/> | |
20 | + | |
21 | + | |
22 | +<!-- JSF jar files --> | |
23 | + <property name="jsf" value="${env.JBOSS_HOME}\modules\javax\faces\api\main\jboss-jsf-api_2.1_spec-2.0.0.Final.jar"/> | |
24 | + <property name="inject" value="${env.JBOSS_HOME}\modules\javax\inject\api\main\javax.inject-1.jar"/> | |
25 | + <property name="servlet" value="${env.JBOSS_HOME}\modules\javax\servlet\api\main\jboss-servlet-api_3.0_spec-1.0.0.Final.jar"/> | |
26 | + <property name="cdi" value="${env.JBOSS_HOME}\modules\javax\enterprise\api\main\cdi-api-1.0-SP4.jar"/> | |
27 | + | |
28 | + | |
29 | + <target name="clean"> | |
30 | + <!-- Delete our the ${build} and ${dist} directory trees --> | |
31 | + <delete dir="${build}"/> | |
32 | + <delete dir="${dist}"/> | |
33 | + <delete dir="${war_dir}"/> | |
34 | + </target> | |
35 | + | |
36 | + <target name="init"> | |
37 | + <!-- Create the build directory structure used by compile and dist --> | |
38 | + <mkdir dir="${build}"/> | |
39 | + <mkdir dir="${dist}"/> | |
40 | + <mkdir dir="${war_dir}"/> | |
41 | + </target> | |
42 | + | |
43 | + <target name="compile" depends="init"> | |
44 | + <!-- Compile the java code from ${src} into ${build} --> | |
45 | + <javac | |
46 | + srcdir="${top}/${src}" | |
47 | + destdir="${build}" | |
48 | + debug="true" | |
49 | + classpath="${jsf}:${inject}:${servlet}:${cdi}"/> | |
50 | + | |
51 | + </target> | |
52 | + | |
53 | + <target name="dist" depends="compile"> | |
54 | + | |
55 | + <!-- Put everything in a war file --> | |
56 | + <war warfile="${war_file}" webxml="${web.xml}"> | |
57 | + <!-- include all facelets in root level, and all .properties files anywhere --> | |
58 | + | |
59 | + <fileset dir="${top}/${src}"> | |
60 | + <include name="**/*.xhtml"/> | |
61 | + <include name="**/*.properties"/> | |
62 | + </fileset> | |
63 | + | |
64 | + <!-- include all .xml config files, | |
65 | + but not web.xml (that's handled separately) --> | |
66 | + <webinf dir="${webinf}"> | |
67 | + <include name="*.xml"/> | |
68 | + <include name="templates/*.xhtml"/> | |
69 | + <exclude name="web.xml"/> | |
70 | + </webinf> | |
71 | + | |
72 | + <!-- include all libraries in WEB-INF/lib --> | |
73 | + <lib dir="${lib}"/> | |
74 | + | |
75 | + <!-- include all compiled classes --> | |
76 | + <classes dir="${build}"/> | |
77 | + | |
78 | + </war> | |
79 | + </target> | |
80 | + | |
81 | + <target name="deploy"> | |
82 | + <!-- Copy the war file to the JBoss deploy directory --> | |
83 | + <copy file="${war_file}" todir="${deploy}"/> | |
84 | + </target> | |
85 | + | |
86 | + <target name="all" depends="clean,dist,deploy"/> | |
87 | + | |
88 | +</project> |
@@ -0,0 +1,90 @@ | ||
1 | +data source registration | |
2 | + | |
3 | +step 1: register sqlite jdbc driver. | |
4 | + | |
5 | +on the cli command line: | |
6 | +[disconnected /] connect | |
7 | + | |
8 | +[standalone@localhost:9999 /] /subsystem=datasources/jdbc-driver=sqlite:add(driver-name="sqlite",driver-module-name="org.sqlite",driver-class-name=org.sqlite.JDBC) | |
9 | + | |
10 | + | |
11 | +step 2: register datasource | |
12 | +[standalone@localhost:9999 /] data-source add --name=jsf-test3 --connection-url="jdbc:sqlite:C:/Users/dmotooka/AppData/sqlite/moto-test2.db" --jndi-name=java:jboss/datasource/jsf-test3 --driver-name="sqlite" | |
13 | + | |
14 | +step 3: enable datasource | |
15 | +[standalone@localhost:9999 /] data-source enable --name=jsf-test3 | |
16 | + | |
17 | + | |
18 | +if you include WEB-INF/*-ds.xml following like xml file, you don't need step 2 and 3. | |
19 | +But anyway you will need step 1. | |
20 | + | |
21 | + | |
22 | +<?xml version="1.0" encoding="UTF-8"?> | |
23 | +<datasources xmlns="http://www.jboss.org/ironjacamar/schema" | |
24 | + xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" | |
25 | + xsi:schemaLocation="http://www.jboss.org/ironjacamar/schema http://docs.jboss.org/ironjacamar/schema/datasources_1_0.xsd"> | |
26 | + <datasource jndi-name="java:jboss/datasource/jsf-test3" pool-name="jsf-test3-pool" enabled="true" > | |
27 | + <connection-url>jdbc:sqlite:C:/Users/dmotooka/AppData/sqlite/moto-test2.db</connection-url> | |
28 | + <driver>sqlite</driver> | |
29 | + </datasource> | |
30 | +</datasources> | |
31 | + | |
32 | + | |
33 | +------------------- | |
34 | + | |
35 | +**check the driver: | |
36 | +[standalone@localhost:9999 /] cd subsystem=datasources/jdbc-driver=sqlite | |
37 | +[standalone@localhost:9999 jdbc-driver=sqlite] :read-resource | |
38 | +{ | |
39 | + "outcome" => "success", | |
40 | + "result" => { | |
41 | + "driver-class-name" => "org.sqlite.JDBC", | |
42 | + "driver-module-name" => "org.sqlite", | |
43 | + "driver-name" => "sqlite" | |
44 | + } | |
45 | +} | |
46 | + | |
47 | + | |
48 | +**list installed driver: | |
49 | +[standalone@localhost:9999 /] /subsystem=datasources:installed-drivers-list | |
50 | +{ | |
51 | + "outcome" => "success", | |
52 | + "result" => [ | |
53 | + { | |
54 | + "driver-name" => "h2", | |
55 | + "deployment-name" => undefined, | |
56 | + "driver-module-name" => "com.h2database.h2", | |
57 | + "module-slot" => "main", | |
58 | + "driver-datasource-class-name" => "", | |
59 | + "driver-xa-datasource-class-name" => "org.h2.jdbcx.JdbcDataSource", | |
60 | + "driver-class-name" => "org.h2.Driver", | |
61 | + "driver-major-version" => 1, | |
62 | + "driver-minor-version" => 3, | |
63 | + "jdbc-compliant" => true | |
64 | + }, | |
65 | + { | |
66 | + "driver-name" => "sqlite", | |
67 | + "deployment-name" => undefined, | |
68 | + "driver-module-name" => "org.sqlite", | |
69 | + "module-slot" => "main", | |
70 | + "driver-datasource-class-name" => "", | |
71 | + "driver-xa-datasource-class-name" => "", | |
72 | + "driver-class-name" => "org.sqlite.JDBC", | |
73 | + "driver-major-version" => 3, | |
74 | + "driver-minor-version" => 7, | |
75 | + "jdbc-compliant" => false | |
76 | + } | |
77 | + ] | |
78 | +} | |
79 | + | |
80 | + | |
81 | +------------------- | |
82 | +**remove installed datasource: | |
83 | +[standalone@localhost:9999 data-source=jsf-test3] cd subsystem=datasources/data-source=jsf-test3 | |
84 | +[standalone@localhost:9999 /] :remove | |
85 | + | |
86 | +**remove installed driver: | |
87 | +[standalone@localhost:9999 /] cd /subsystem=datasources/jdbc-driver=sqlite | |
88 | +[standalone@localhost:9999 /] :remove | |
89 | + | |
90 | + |
@@ -0,0 +1,24 @@ | ||
1 | +<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> | |
2 | +<html xmlns="http://www.w3.org/1999/xhtml" | |
3 | + xmlns:h="http://java.sun.com/jsf/html" | |
4 | + xmlns:f="http://java.sun.com/jsf/core" | |
5 | + xmlns:ui="http://java.sun.com/jsf/facelets"> | |
6 | + | |
7 | + <ui:composition template="/WEB-INF/templates/moto-template.xhtml"> | |
8 | + <ui:define name="pageTitle">log in</ui:define> | |
9 | + <ui:define name="pageHeader" /> | |
10 | + <ui:define name="body"> | |
11 | + | |
12 | + <h:form> | |
13 | + | |
14 | +user id : <h:inputText value="#{userBean.uid}"/> | |
15 | +password : <h:inputSecret value="#{userBean.pwd}"/> | |
16 | + | |
17 | +<h:commandButton value="login" action="#{userBean.doLogin}" /> | |
18 | + | |
19 | + | |
20 | + </h:form> | |
21 | + </ui:define> | |
22 | + </ui:composition> | |
23 | + | |
24 | +</html> | |
\ No newline at end of file |
@@ -0,0 +1,57 @@ | ||
1 | +<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> | |
2 | +<html xmlns="http://www.w3.org/1999/xhtml" | |
3 | + xmlns:h="http://java.sun.com/jsf/html" | |
4 | + xmlns:f="http://java.sun.com/jsf/core" | |
5 | + xmlns:ui="http://java.sun.com/jsf/facelets"> | |
6 | + | |
7 | + <ui:composition template="/WEB-INF/templates/moto-template.xhtml"> | |
8 | + <ui:define name="pageTitle">jsf chat app</ui:define> | |
9 | + <ui:define name="pageHeader" /> | |
10 | + <ui:define name="body"> | |
11 | + | |
12 | + user : #{userBean.uname} <br /> | |
13 | + | |
14 | + <h:form> | |
15 | + chat room : | |
16 | + <h:selectOneMenu id="charRoom" value="#{chatBean.chatRoom}" onchange="submit()" | |
17 | + valueChangeListener="#{chatBean.chatRoomChanged}" > | |
18 | + <f:selectItems value="#{userBean.flights}"/> | |
19 | + </h:selectOneMenu> | |
20 | + <br /> | |
21 | + | |
22 | + <h:panelGroup rendered="#{empty chatBean.msgList}"> | |
23 | + <em>No chat log.</em> | |
24 | + </h:panelGroup> | |
25 | + <h:dataTable id="msgList" var="_chat" value="#{chatBean.msgList}" | |
26 | + rendered="#{not empty chatBean.msgList}" > | |
27 | + <h:column> | |
28 | + <f:facet name="header">user name</f:facet> | |
29 | + #{_chat.uname} | |
30 | + </h:column> | |
31 | + <h:column> | |
32 | + <f:facet name="header">msg</f:facet> | |
33 | + #{_chat.msg} | |
34 | + </h:column> | |
35 | + <h:column> | |
36 | + <f:facet name="header">date</f:facet> | |
37 | + #{_chat.date} | |
38 | + </h:column> | |
39 | + </h:dataTable> | |
40 | + <br /> | |
41 | + | |
42 | + input text: <h:inputText id="msg" value="#{chatBean.msg}"/> | |
43 | + | |
44 | + <h:commandButton value="post" action="#{chatBean.doPost}" > | |
45 | + <f:ajax execute="charRoom msg" render="msgList msg" /> | |
46 | + </h:commandButton> | |
47 | + </h:form> | |
48 | + | |
49 | + <h:form> | |
50 | + <h:commandButton value="log out" action="#{userBean.doLogout}" /> | |
51 | + </h:form> | |
52 | + | |
53 | + | |
54 | + </ui:define> | |
55 | + </ui:composition> | |
56 | + | |
57 | +</html> |
@@ -0,0 +1,34 @@ | ||
1 | +<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> | |
2 | +<html xmlns="http://www.w3.org/1999/xhtml" | |
3 | + xmlns:h="http://java.sun.com/jsf/html" | |
4 | + xmlns:f="http://java.sun.com/jsf/core" | |
5 | + xmlns:ui="http://java.sun.com/jsf/facelets"> | |
6 | + | |
7 | + <ui:composition template="/WEB-INF/templates/moto-template.xhtml"> | |
8 | + <ui:define name="pageTitle">log in</ui:define> | |
9 | + <ui:define name="pageHeader">Header</ui:define> | |
10 | + <ui:define name="body"> | |
11 | + | |
12 | + Hello from Facelets | |
13 | + <br/> | |
14 | + Message is: #{messageServerBean.message} | |
15 | + <br/> | |
16 | + Message Server Bean is: #{messageServerBean} | |
17 | + | |
18 | + <h:form> | |
19 | + | |
20 | + | |
21 | +<h2>日本円を米ドルに換算</h2> | |
22 | + | |
23 | +日本円を入力して下さい: | |
24 | +<h:inputText value="#{yenToDoller.yen}"/> | |
25 | + | |
26 | +<h:commandButton value="計算" action="#{yenToDoller.calc}" /> | |
27 | + | |
28 | +<p>米ドルでは<h:outputText value="#{yenToDoller.doller}"/>ドルです。</p> | |
29 | + | |
30 | + </h:form> | |
31 | + </ui:define> | |
32 | + </ui:composition> | |
33 | + | |
34 | +</html> | |
\ No newline at end of file |
@@ -0,0 +1,3 @@ | ||
1 | +this project is jsf 2.0 / xhtml (facelets) with named annotation type project. | |
2 | +no faces-config.xml is needed. | |
3 | + |