Foren: Offene Diskussion (Thread #21308)

java(web版) jspでiterateを使って一覧の表示について (2009-01-14 20:49 by Anonym #41201)

JSPのエラーメッセージの内容:
org.apache.jasper.JasperException: null という名前のbeanのプロパティ <bean:write name="roleId" property="id"/> に対するゲッターメソッドがありません

JSPのソース:
<logic:iterate id="roleId" name="roleIdList" scope="session" type="jp.mmcard.mmCampus.master.section.service.bean.CodeListBean">
<html:options property='<bean:write name="roleId" property="id"/>'
labelProperty='<bean:write name="roleId" property="name"/>' />
</logic:iterate>

Blogicは下記のようです。
CodeListBean[] roleId = _dao.executeForObjectArray("roleCodeList",
null, CodeListBean.class);
List<CodeListBean> roleIdList = new ArrayList<CodeListBean>();

// roleIdList.addAll(roleId);
for (int i = 0; i < roleId.length; i++) {
roleIdList.add(roleId[i]);
}

retMap.put("roleIdList", roleIdList);

CodeListBean.javaはDBから抽出した項目のBeanです。
Blogic返却したのはCodeListBeanのList.

でも、JSPを表示すると、上記のエラーメッセージが表示されました。

助けてください。

Reply to #41201×

You can not use Wiki syntax
You are not logged in. To discriminate your posts from the rest, you need to pick a nickname. (The uniqueness of nickname is not reserved. It is possible that someone else could use the exactly same nickname. If you want assurance of your identity, you are recommended to login before posting.) Anmelden

RE: java(web版) jspでiterateを使って一覧の表示について (2009-01-14 21:18 by kimuraku #41203)

JSPの解析時に、すでにセッションスコープにコレクション型で"
roleIdList"が存在しているのであれば、以下のコードで実現できないでしょうか。

<html:select name="…" property="…">
 <html:options collection="roleIdList" property="id" labelProperty="name"/>
</html:select>

ちなみに蛇足ですが、コードリスト取得のコードは下記の方がすっきりすると思います。

List<CodeListBean> roleIdList = _dao.executeForObjectList("roleCodeList", null);
Reply to #41201

Reply to #41203×

You can not use Wiki syntax
You are not logged in. To discriminate your posts from the rest, you need to pick a nickname. (The uniqueness of nickname is not reserved. It is possible that someone else could use the exactly same nickname. If you want assurance of your identity, you are recommended to login before posting.) Anmelden

RE: java(web版) jspでiterateを使って一覧の表示について (2009-01-14 21:24 by Anonym #41205)

ご説明ありがとうございます。

今回実現したいのは、DBにあるデータを追加したり、削除したり場合、画面で表示されたselectの内容もDBと同じく表示する機能ですから、
フレームワークに提供しているcodelistの機能は、サーバースタートする時、一度だけDBから抽出しているから、DBの内容は動的に反映できませんです。
Reply to #41201

Reply to #41205×

You can not use Wiki syntax
You are not logged in. To discriminate your posts from the rest, you need to pick a nickname. (The uniqueness of nickname is not reserved. It is possible that someone else could use the exactly same nickname. If you want assurance of your identity, you are recommended to login before posting.) Anmelden

RE: java(web版) jspでiterateを使って一覧の表示について (2009-01-14 21:48 by kimuraku #41208)

上記BLogic内で動的にDBのコードリストを取得した後、blogic-io経由で
セッションのアクションフォームに格納しているのでしょうか。

そうであれば、コードリスト機能を利用しなくてもBLogic実行後には
セッション上に動的に取得したコードリストが存在しているので、
<html:options>タグで取得できると思います。

ご提示のエラーメッセージは、Strutsが<html:options>タグを解析する際、
property属性が指定されているにも関わらず、collection属性が指定されていない場合に、
アイテムとなるBeanからpropertyが正常に取得できずに出力されるものです。

<html:options>タグを使ってセレクトボックスのアイテムを作成する場合は、
name属性+property属性+labelName属性+labelProperty属性の組合せか、
collection属性+property属性+labelProperty属性の組合せで
指定することになります。
その際、name属性とcollection属性の指定はしておくべきです。
(厳密には、collection属性が省略された場合はname属性からBeanが
探索され、name属性も省略されている場合は、"org.apache.struts.taglib.html.BEAN"
というキーでBeanが探索されます。)
Reply to #41205

Reply to #41208×

You can not use Wiki syntax
You are not logged in. To discriminate your posts from the rest, you need to pick a nickname. (The uniqueness of nickname is not reserved. It is possible that someone else could use the exactly same nickname. If you want assurance of your identity, you are recommended to login before posting.) Anmelden

RE: java(web版) jspでiterateを使って一覧の表示について (2009-01-14 21:49 by Anonym #41209)

前書いたソースのblogic-io.xmlに、
そのblogicを返却した内容はもうすでにsessionへ定義しました。
ソースの内容は下記のようです。
<blogic-result>
<set-property property="roleIdList" dest="session" />
</blogic-result>

どこか問題があったら、あるいは、どこか設定の漏れがあったら、ご説明してください。
Reply to #41201

Reply to #41209×

You can not use Wiki syntax
You are not logged in. To discriminate your posts from the rest, you need to pick a nickname. (The uniqueness of nickname is not reserved. It is possible that someone else could use the exactly same nickname. If you want assurance of your identity, you are recommended to login before posting.) Anmelden

RE: java(web版) jspでiterateを使って一覧の表示について (2009-01-14 21:54 by kimuraku #41210)

http://sourceforge.jp/forum/message.php?msg_id=41208

で返信しましたが、セッションに直接"roleIdList" を反映しているのであれば問題ありません。
<html:options>とcollection属性, property属性, labelProperty属性で表示できると思います。

ちなみに<html:options>タグはアイテムBeanの中身を全て表示するので、
<logic:iterate>タグは必要ありません。
Reply to #41209

Reply to #41210×

You can not use Wiki syntax
You are not logged in. To discriminate your posts from the rest, you need to pick a nickname. (The uniqueness of nickname is not reserved. It is possible that someone else could use the exactly same nickname. If you want assurance of your identity, you are recommended to login before posting.) Anmelden

RE: java(web版) jspでiterateを使って一覧の表示について (2009-01-14 22:03 by Anonym #41211)

お教えていただきまして、ありがとうございます。

<html:options>タグに、collection属性を追加しました。
前質問した問題が解消しましたが、新しいエラーが出てきました。エラーの内容は下記のようです。
org.apache.jasper.JasperException: jp.mmcard.mmCampus.master.section.service.bean.CodeListBean@e80317 に対応するイテレータを生成することが出来ません
org.apache.jasper.servlet.JspServletWrapper.handleJspException(JspServletWrapper.java:460)
org.apache.jasper.servlet.JspServletWrapper.service(JspServletWrapper.java:355)
org.apache.jasper.servlet.JspServlet.serviceJspFile(JspServlet.java:329)
org.apache.jasper.servlet.JspServlet.service(JspServlet.java:265)
javax.servlet.http.HttpServlet.service(HttpServlet.java:729)
org.apache.struts.action.RequestProcessor.doForward(RequestProcessor.java:1085)
org.apache.struts.action.RequestProcessor.processForwardConfig(RequestProcessor.java:398)


修正したJSPの内容は下記です。
<logic:iterate id="roleId" name="roleIdList" scope="session">
<html:options collection="roleId" property='<bean:write name="roleId" property="id"/>'
labelProperty='<bean:write name="roleId" property="name"/>' />
</logic:iterate>


どこかが悪いなら、ご説明ください。
Reply to #41201

Reply to #41211×

You can not use Wiki syntax
You are not logged in. To discriminate your posts from the rest, you need to pick a nickname. (The uniqueness of nickname is not reserved. It is possible that someone else could use the exactly same nickname. If you want assurance of your identity, you are recommended to login before posting.) Anmelden

RE: java(web版) jspでiterateを使って一覧の表示について (2009-01-14 22:21 by Anonym #41212)

ありがとうございます。
おっしゃった通りに修正しました、selectの問題は解消しました。

ご指導ありがとうございます。
Reply to #41201

Reply to #41212×

You can not use Wiki syntax
You are not logged in. To discriminate your posts from the rest, you need to pick a nickname. (The uniqueness of nickname is not reserved. It is possible that someone else could use the exactly same nickname. If you want assurance of your identity, you are recommended to login before posting.) Anmelden

RE: java(web版) jspでiterateを使って一覧の表示について (2009-01-15 10:59 by Anonym #41219)

関連する問題ですが、
<html:options>タグを使う時、抽出したBeanは必ずsessionへdestしますか。
scopeという属性がありませんですから。
Reply to #41201

Reply to #41219×

You can not use Wiki syntax
You are not logged in. To discriminate your posts from the rest, you need to pick a nickname. (The uniqueness of nickname is not reserved. It is possible that someone else could use the exactly same nickname. If you want assurance of your identity, you are recommended to login before posting.) Anmelden

RE: java(web版) jspでiterateを使って一覧の表示について (2009-01-15 11:55 by kimuraku #41221)

<html:options>タグを利用する場合、アイテムとして抽出するBeanは
collection属性もしくはname属性で指定します。

その際、StrutsのOptionsTagは、
TagUtils.getInstance().lookup(pageContext, "アイテムとなるBean名", null);
のコードにより、各種スコープからBeanを探索します。

探索対象のスコープは以下の順です。(J2EE仕様)
ページ→リクエスト→セッション→アプリケーション

従って、BLogicなどからBeanを返す際、session以外にdest=requestで
リクエストにセットしても問題なく画面に表示されます。

ただし、sessionやrequest内のActionFormにBeanをセットした場合(ネストさせた場合)は、
<html:options>の前に<bean:define>などで、ページ内変数としてBeanを定義しておく
必要があります。
Reply to #41219

Reply to #41221×

You can not use Wiki syntax
You are not logged in. To discriminate your posts from the rest, you need to pick a nickname. (The uniqueness of nickname is not reserved. It is possible that someone else could use the exactly same nickname. If you want assurance of your identity, you are recommended to login before posting.) Anmelden

RE: java(web版) jspでiterateを使って一覧の表示について (2009-01-15 13:07 by Anonym #41223)

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

実は、今回動的のcodelistが多いですから、sessionへdestしたら、混雑だと思います。
formへセットしたいです。
フォームの中に、List<CodeBean>という項目を定義して、Blogicの返却は直接フォームへセットしたいです。
Reply to #41201

Reply to #41223×

You can not use Wiki syntax
You are not logged in. To discriminate your posts from the rest, you need to pick a nickname. (The uniqueness of nickname is not reserved. It is possible that someone else could use the exactly same nickname. If you want assurance of your identity, you are recommended to login before posting.) Anmelden

RE: java(web版) jspでiterateを使って一覧の表示について (2009-01-17 14:30 by Anonym #41257)

続いて、ほかJSPでエラーが発生しまいました。
JSPでのエラーメッセージは下記のようです。
org.apache.jasper.JasperException: スコープ request にBean sectionList がありません
org.apache.jasper.servlet.JspServletWrapper.handleJspException(JspServletWrapper.java:460)
org.apache.jasper.servlet.JspServletWrapper.service(JspServletWrapper.java:355)
org.apache.jasper.servlet.JspServlet.serviceJspFile(JspServlet.java:329)

blogic-io.xmlにはこう書きました。
<blogic-result>
<set-property property="sectionList" dest="request" />
</blogic-result>
(List<SectionMstListBean>Beanのlistです)

JSPファイルにはこう書きました。
<bean:define id="sectionList" scope="request" name="sectionList"/>
<logic:iterate id="sectionList" name="sectionList">
<tr>
<td class="td002Dot" style="height:22px;">
<html:radio property="txtSectionCd" value='<bean:write name="sectionList" property="txtSectionCd"/>'></html:radio>
</td>
<td class="td002Dot">
<html:text property='<bean:write name="sectionList" property="txtSectionCd"/>' readonly="true"></html:text>
</td>
<td class="td002Dot">
<html:text property='<bean:write name="sectionList" property="txtSectionName"/>' readonly="true"></html:text>
</td>
</tr>
</logic:iterate>

チェックすべきところは全部チェックしました、
ほかのどこかチェックしていない点があれば、
教えていただけませんか。
Reply to #41201

Reply to #41257×

You can not use Wiki syntax
You are not logged in. To discriminate your posts from the rest, you need to pick a nickname. (The uniqueness of nickname is not reserved. It is possible that someone else could use the exactly same nickname. If you want assurance of your identity, you are recommended to login before posting.) Anmelden

RE: java(web版) jspでiterateを使って一覧の表示について (2009-01-19 15:31 by Anonym #41305)

ごめんなさい。
この問題はもう解消しました。
いつもお世話になって、ありがとうございました。
Reply to #41201

Reply to #41305×

You can not use Wiki syntax
You are not logged in. To discriminate your posts from the rest, you need to pick a nickname. (The uniqueness of nickname is not reserved. It is possible that someone else could use the exactly same nickname. If you want assurance of your identity, you are recommended to login before posting.) Anmelden