ログインしてさらにmixiを楽しもう

コメントを投稿して情報交換!
更新通知を受け取って、最新情報をゲット!

Javaの課題丸投げコミュの子ウィンドウから親ウィンドウへの値のセット

  • mixiチェック
  • このエントリーをはてなブックマークに追加
お世話になっています。

現在、JAVA・JAVASCRIPTで親ウインドウにて参照ボタンを押下時に親ウィンドウの値を元にDBに検索し、
ACTION経由でstruts-config.xmlに記述のある子ウィンドウに結果を表示しております。
その後、子ウィンドウに表示してあるチェックボックスにチェックして、反映ボタン押下時に
チェックした値を親ウィンドウに引き渡したいと考えております。
現状、子ウィンドウに出力すところまではできたのですが、親ウィンドウに値をセットすることができません。
ご教授のほどよろしくお願いします。
以下ソース

******親ウィンドウ******
<html:html>
<head>
<!-- タイトル -->
<title>システム</title>
<SCRIPT Language="JavaScript">

//氏名参照ボタン押下時
function openWindow1() {
window.document.forms[0].stataus.value="2";
document.forms[0].target = "new";
document.forms[0].submit();
}
</SCRIPT>
</head>
<body onload="doOUTPUT();">
<% request.setCharacterEncoding("Windows-31J"); %>
<div align="center">
<!-- 見出し -->
<table class="PGHD_TBL" cellpadding="0" cellspacing="0">
<tr>
<th colspan="4">システム</th>
</tr>
<tr>
<th colspan="5" class="tdCellC" height="32">pg1</th>
</tr>
<tr>
<td colspan="5"></td>
</tr>
</table>
<!-- Actionクラス呼び出し -->
<html:form action="/submit" target="new">
<html:hidden name="AForm" property="stataus"/>
<table id="table1">
</table>
<table>
<tr>
<td>
<table>
<tbody>
<br>
<tr>
<th width="100">CD</th>
<td class="tdCellL" >
<html:text property="cd" />
<html:text property="nm"/>
</td>
</tr>
</tbody>
</table>
</td>
</tr>
</table>
<br>
<table width="900px">
<tr>
<td>
<!-- 入力項目 -->
<table width="0%" cellpadding="0" cellspacing="0">
<tbody>
<tr>
<th width="100" height="40" class="tdCellC">氏名<br><html:button property="sausyo"onclick="openWindow1()">参照</html:button></th>
<td class="tdCellL">
<html:text property="simei" tabindex="-1"/>
</td>
</tr>
</tbody>
</table>
</td>
</tr>
</table>
</html:form>
</div>
</body>
</html:html>


******ACTION******
Connection con = null;
//データベース接続処理
con = comm.DBSourceConnection.getDbConnection();
//Form作成
Form F = (Form)form;
//DAO作成
DAO D = new DAO();
PG1Model mdl = new PG1Model();
//データを取得する
List<PG1Model> List = D.Select(F.getCd());
// フォーム情報の初期化
Form F2 = new Form();
F2.setmdl(List);
//2) セッションにProductオブジェクトのリストを格納している
request.setAttribute("list1", F2);
//3)表示領域の設定
request.setAttribute("offset","0");
return mapping.findForward("sansyo");

******struts-config.xml******
<action-mappings>
<action path="/submit" name="Form" type="Action" scope="request" validate="true" input="/view/親ウィンドウ.jsp">
<forward name="sansyo" path="/view/子ウィンドウ.jsp"/>
</action>
</action-mappings>


******子ウィンドウ******
<html:html>
<head>
<!-- タイトル -->
<title>氏名照会</title>
<SCRIPT Language="JavaScript">
//更新ボタン押下時
function ExecCHK() {
--------ここで親ウィンドウに値を反映させたいと考えています---------
}
</SCRIPT>
</head>
<body onload="doOUTPUT();">
<div align="center">
<!-- Actionクラス呼び出し -->
<html:form action="/submit">
<!-- リクエスト時使用 -->
<html:hidden name="Form" property="stataus"/>
<table>
<tr>
<td class="tdCellR">
<html:button property="hanei"onclick="ExecCHK()">反映</html:button>
</td>
</tr>
</table>
<table >
<tr>
<td>
<!-- 表組の作成(題目) -->
<table width="100%" >
<thead>
<tbody>
<tr height="30">
<th class="tdCellC" width="20">区分</th>
<th class="tdCellC" width="100">氏名</th>
</tr>
</thead>
<logic:iterate id="list1" name="mdl" property="allMdl"type="PG1Model">
<tr>
<td class="tdCellC" width="20">
<html:checkbox name="mdl" property="kbn" onclick="boxChk(this)" />
</td>
<td class="tdCellC" width="100">
<html:text name="mdl" property="nm"/>
</td>
</tr>
</logic:iterate>
</tbody>
</table>
</div>
</td>
</tr>
</table>
</html:form>
</div>
</body>
</html:html>


※情報上変数名などを強制的に変更しておりますので、
 お見苦しいところがあるかもしれませんがよろしくお願いします。






コメント(2)

javascriptのparentってiframeとかじゃないと使えないんでしたっけ…
>いしかわさん

回答ありがとうございます。


悩んだ末、一画面で構成してhiddenで値の引き渡しをする仕様に変更しました。
parent、ifreameに関しては知らなかったので勉強になりました。
次回使えそうな時があったら試してみます。
ありがとうございました。

ログインすると、みんなのコメントがもっと見れるよ

mixiユーザー
ログインしてコメントしよう!

Javaの課題丸投げ 更新情報

Javaの課題丸投げのメンバーはこんなコミュニティにも参加しています

星印の数は、共通して参加しているメンバーが多いほど増えます。

人気コミュニティランキング