MayaaとStrutsのlogicタグ
うーむ。うまくいかない。。。
logic:iterateタグは使えないのかなー
HTMLは
<tr id="loop"> <td> <input type="submit" id="goEdit" value="edit"/> <input type="submit" id="goDelete" value="delete"/> </td> <td><span id="id">10</span></td> <td><span id="name">dog</span></td> </tr>
こんな感じで、mayaaファイルは
<logic:iterate m:id="loop" replace="false" id="iterations" name="iterationListDto" property="iterations" indexId="i"> <m:doBody /> </logic:iterate> <s2struts:submit m:id="goEdit" action="#{iterationListAction.goEdit}" indexId="i"> <bean:message key="button.edit" /> </s2struts:submit> <s2struts:submit m:id="goDelete" action="#{iterationListAction.goDelete}" indexId="i"> <bean:message key="button.delete" /> </s2struts:submit> <m:with id="id"> <bean:write name="iterations" property="id" /> <html:hidden name="iterations" property="id" indexed="true" /> </m:with> <bean:write m:id="name" name="iterations" property="name" />
ってしてもうまくリストの内容が出力されていない。。。
どうしよう。。。と思ったら、
<m:forEach id="loop" replace="false" items="${ iterationListDto.getIterations() }" var="iterations" index="i" /> <s2struts:submit m:id="goEdit" action="#{iterationListAction.goEdit}" indexId="i"> <bean:message key="button.edit" /> </s2struts:submit> <s2struts:submit m:id="goDelete" action="#{iterationListAction.goDelete}" indexId="i"> <bean:message key="button.delete" /> </s2struts:submit> <m:with id="id"> <bean:write name="iterations" property="id" /> <input type="hidden" name="iterations[${ i }].id" value="${ iterations.id }" /> </m:with> <bean:write m:id="name" name="iterations" property="name" />
こうしたらうまくいった。良かった良かった。
forEachは便利だなー。
よく考えるとiterateタグの使い方が間違ってるの可能性もあるなー
ってことできちんと動作するかをJSPで確認。
<logic:iterate id="iterations" name="iterationListDto" property="iterations" indexId="i"> <tr> <td> <s2struts:submit action="#{iterationListAction.goEdit}" indexId="i">edit</s2struts:submit> <s2struts:submit action="#{iterationListAction.goDelete}" indexId="i">delete</s2struts:submit> </td> <td> <bean:write name="iterations" property="id"/> <html:hidden name="iterations" property="id" indexed="true"/> </td> <td><bean:write name="iterations" property="name"/></td> </tr> </logic:iterate>
うむうむ動いた。
iterateタグの使い方に問題はなさそう。
logic:iterateタグは利用できないってことかなー。
っというかMayaa自体をよく理解してないのが一番の問題か。。。
明日ドキュメントをきちんと読もうっと。