質問編集履歴
2
変更しました
title
CHANGED
File without changes
|
body
CHANGED
@@ -1,4 +1,7 @@
|
|
1
|
+
```
|
2
|
+
/*sidebar.xhtml*/
|
3
|
+
<h:form id="sort_form">
|
1
|
-
<p class="side-title"><b></b></p>
|
4
|
+
<p class="side-title"><b>あ</b></p>
|
2
5
|
<select name="sort" onchange="dropsort()">
|
3
6
|
<option value="#">選択してください</option>
|
4
7
|
<option value="2011_Top.xhtml" onclick="#{iB.setIi_nendo_id(2011)};#{ijB.setIj_nendo_id(2011)};#{joB.setJo_nendo_id(2011)}">#{nendoBean.nendo}#{res.km}</option>
|
@@ -6,9 +9,162 @@
|
|
6
9
|
<option value="2013_Top.xhtml" onclick="#{iB.setIi_nendo_id(2013)};#{ijB.setIj_nendo_id(2013)};#{joB.setJo_nendo_id(2013)}">#{nendoBean.nendo2}#{res.km}</option>
|
7
10
|
<option value="2014_Top.xhtml" onclick="#{iB.setIi_nendo_id(2014)};#{ijB.setIj_nendo_id(2014)};#{joB.setJo_nendo_id(2014)}">#{nendoBean.nendo3}#{res.km}</option>
|
8
11
|
</select>
|
12
|
+
</h:form>
|
9
|
-
---------------------------------------------------------------------------------
|
13
|
+
---------------------------------------------------------------------------------
|
14
|
+
/*igishi.js*/
|
10
|
-
|
15
|
+
//<!-- コンボボックスの値をURLに置換するjavaScript -->
|
11
|
-
|
16
|
+
function dropsort() {
|
17
|
+
var browser = document.sort_form.sort.value;
|
18
|
+
location.href = browser;
|
19
|
+
}
|
20
|
+
---------------------------------------------------------------------------------
|
12
21
|
|
22
|
+
/*IiBean.java*/
|
23
|
+
@Named(value = "iB")
|
24
|
+
@Dependent
|
25
|
+
public class IiBean {
|
26
|
+
|
27
|
+
/*変数の宣言と対応するGetter,Setterを記述する*/
|
28
|
+
static Integer ii_nendo_id=0;
|
29
|
+
static String ii_mondai_id="";
|
30
|
+
private String mondaibun;
|
31
|
+
private String mg1;
|
32
|
+
private String mg2;
|
33
|
+
private String mg3;
|
34
|
+
private String mg4;
|
35
|
+
private String mg5;
|
36
|
+
|
37
|
+
public Integer getIi_nendo_id() {
|
38
|
+
return ii_nendo_id;
|
39
|
+
}
|
40
|
+
|
41
|
+
public void setIi_nendo_id(Integer ii_nendo_id) {
|
42
|
+
IiBean.ii_nendo_id = ii_nendo_id;
|
43
|
+
}
|
44
|
+
|
45
|
+
public String getIi_mondai_id() {
|
46
|
+
return ii_mondai_id;
|
47
|
+
}
|
48
|
+
|
49
|
+
public void setIi_mondai_id(String ii_mondai_id) {
|
50
|
+
IiBean.ii_mondai_id = ii_mondai_id;
|
51
|
+
}
|
52
|
+
|
53
|
+
public String getMondaibun() {
|
54
|
+
return mondaibun;
|
55
|
+
}
|
56
|
+
|
57
|
+
public void setMondaibun(String mondaibun) {
|
58
|
+
this.mondaibun = mondaibun;
|
59
|
+
}
|
60
|
+
|
61
|
+
public String getMg1() {
|
62
|
+
return mg1;
|
63
|
+
}
|
64
|
+
|
65
|
+
public void setMg1(String mg1) {
|
66
|
+
this.mg1 = mg1;
|
67
|
+
}
|
68
|
+
|
69
|
+
public String getMg2() {
|
70
|
+
return mg2;
|
71
|
+
}
|
72
|
+
|
73
|
+
public void setMg2(String mg2) {
|
74
|
+
this.mg2 = mg2;
|
75
|
+
}
|
76
|
+
|
77
|
+
public String getMg3() {
|
78
|
+
return mg3;
|
79
|
+
}
|
80
|
+
|
81
|
+
public void setMg3(String mg3) {
|
82
|
+
this.mg3 = mg3;
|
83
|
+
}
|
84
|
+
|
85
|
+
public String getMg4() {
|
86
|
+
return mg4;
|
87
|
+
}
|
88
|
+
|
89
|
+
public void setMg4(String mg4) {
|
90
|
+
this.mg4 = mg4;
|
91
|
+
}
|
92
|
+
|
93
|
+
public String getMg5() {
|
94
|
+
return mg5;
|
95
|
+
}
|
96
|
+
|
97
|
+
public void setMg5(String mg5) {
|
98
|
+
this.mg5 = mg5;
|
99
|
+
}
|
100
|
+
/*変数の宣言とGetter,Setterの記述ここまで*/
|
101
|
+
|
102
|
+
public IiBean() {
|
103
|
+
/*MySQL(データベース:「mie」)に接続する処理*/
|
104
|
+
ResultSet rs=null;
|
105
|
+
Connection con = null;
|
106
|
+
PreparedStatement ps = null;
|
107
|
+
try {
|
108
|
+
Class.forName("com.mysql.jdbc.Driver");
|
109
|
+
|
110
|
+
con =DriverManager.getConnection("jdbc:mysql://localhost/mie","root","mysql");
|
111
|
+
/*MySQLに接続する処理ここまで*/
|
112
|
+
|
113
|
+
String sql="";
|
114
|
+
if (cntupBean.countup < 10 ) {
|
115
|
+
/*ここから変数「sql」にsql文を格納するコードを記述する*/
|
116
|
+
sql = "select mondaibun,mondaigun1,mondaigun2,mondaigun3,mondaigun4,mondaigun5 from kakomondai "
|
117
|
+
+ "where nendo_id="+IiBean.ii_nendo_id+" and kamoku_id=1 and mondai_id='"+IiBean.ii_mondai_id+"0"+cntupBean.countup+"'";
|
118
|
+
/*sql格納ここまで*/
|
119
|
+
} else if(cntupBean.countup <51) {
|
120
|
+
sql = "select mondaibun,mondaigun1,mondaigun2,mondaigun3,mondaigun4,mondaigun5 from kakomondai "
|
121
|
+
+ "where nendo_id="+IiBean.ii_nendo_id+" and kamoku_id=1 and mondai_id='"+IiBean.ii_mondai_id+""+cntupBean.countup+"'";
|
122
|
+
}
|
123
|
+
|
124
|
+
//ステートメントオブジェクトを生成
|
125
|
+
ps = con.prepareStatement(sql);
|
126
|
+
|
127
|
+
//クエリを実行して結果セットを取得
|
128
|
+
rs = ps.executeQuery();
|
129
|
+
|
130
|
+
//mondaiデータ取得
|
131
|
+
while(rs.next()){
|
132
|
+
this.mondaibun = rs.getString("mondaibun");
|
133
|
+
this.mg1 = rs.getString("mondaigun1");
|
134
|
+
this.mg2 = rs.getString("mondaigun2");
|
135
|
+
this.mg3 = rs.getString("mondaigun3");
|
136
|
+
this.mg4 = rs.getString("mondaigun4");
|
137
|
+
this.mg5 = rs.getString("mondaigun5");
|
138
|
+
System.out.println("●"+this.mondaibun);
|
139
|
+
System.out.println("●"+this.mg1);
|
140
|
+
System.out.println("●"+this.mg2);
|
141
|
+
System.out.println("●"+this.mg3);
|
142
|
+
System.out.println("●"+this.mg4);
|
143
|
+
System.out.println("●"+this.mg5);
|
144
|
+
}
|
145
|
+
} catch (SQLException ex) {
|
146
|
+
Logger.getLogger(IiBean.class.getName()).log(Level.SEVERE, null, ex);
|
147
|
+
} catch (ClassNotFoundException ex) {
|
148
|
+
Logger.getLogger(IiBean.class.getName()).log(Level.SEVERE, null, ex);
|
149
|
+
}finally{
|
150
|
+
try {
|
151
|
+
//close処理
|
152
|
+
if(ps != null) {
|
153
|
+
ps.close();
|
154
|
+
}
|
155
|
+
//close処理
|
156
|
+
if(con != null) {
|
157
|
+
con.close();
|
158
|
+
}
|
159
|
+
} catch (SQLException e) {
|
160
|
+
e.printStackTrace();
|
161
|
+
}
|
162
|
+
}
|
163
|
+
}
|
164
|
+
}
|
165
|
+
```
|
13
|
-
クリックしたとき
|
166
|
+
sidebarのselect optionの値をクリックしたとき、ページ遷移とともにバッキングビーンに値を渡したいと考えています。
|
167
|
+
ですが、最後のonclickしかイベントが発火していない状況です。
|
168
|
+
他に案、またなにか代替案はあるでしょうか、
|
169
|
+
|
14
|
-
|
170
|
+
*glassfish4.1です。
|
1
あ
title
CHANGED
File without changes
|
body
CHANGED
@@ -1,4 +1,4 @@
|
|
1
|
-
<p class="side-title"><b>
|
1
|
+
<p class="side-title"><b></b></p>
|
2
2
|
<select name="sort" onchange="dropsort()">
|
3
3
|
<option value="#">選択してください</option>
|
4
4
|
<option value="2011_Top.xhtml" onclick="#{iB.setIi_nendo_id(2011)};#{ijB.setIj_nendo_id(2011)};#{joB.setJo_nendo_id(2011)}">#{nendoBean.nendo}#{res.km}</option>
|