[Seasar-user:18585] [SAStruts] forEach の中の値の取得方法

松山 大樹 [E-MAIL ADDRESS DELETED]
2009年 10月 6日 (火) 18:55:53 JST


松山です。

SAStruts で、簡単なアンケート画面を作成しているのですが、forEach の中の
値の取得方法がわからないため、質問させてください。

---------------------------------------------------------------------------
■dto
public class QuestionDto implements Serializable {

	//質問ID
	private Integer questionID = null;
	//質問
	private String questionText = null;
	//種類(text)
	private boolean text = false;
	//種類(radio)
	private boolean selectOne = false;
	//種類(checkbox)
	private boolean selectMany = false;
	//単数選択肢一覧
	private String selectOneAnswer = null;
	private List<SelectItemDto> selectOneAnswerItems = null;
	//複数選択肢一覧
	private String[] selectManyAnswer = null;
	private List<SelectItemDto> selectManyAnswerItems = null;
	//回答
	private String answerText = null;

   :
   :
 getter/setter

---------------------------------------------------------------------------
■form
public class RegistrationForm implements Serializable {
	public QuestionDto[] questionItems = null;
  :
   :
---------------------------------------------------------------------------
■jsp
<c:forEach var="question" items="${questionItems}">
・<span id="questionText">${f:h(question.questionText)}</span><br />
<c:if test="${question.text}">
<html:text property="answerText" size="20" /><br />
</c:if>
<c:if test="${question.selectMany}">
	<c:forEach var="answer" items="${question.selectManyAnswerItems}">
		<html:multibox property="selectManyAnswer"
value="${answer.value}"></html:multibox>${f:h(answer.label)}<br />
	</c:forEach>
</c:if>
<c:if test="${question.selectOne}">
	<c:forEach var="answer" items="${question.selectOneAnswerItems}">
		<html:radio property="selectOneAnswer" value="${answer.value}"></html:radio>${f:h(answer.label)}<br />
	</c:forEach>
</c:if>
<br />
</c:forEach>

---------------------------------------------------------------------------

画面に質問と回答が表示されるのですが、submit しても、値が取得できません。
根本的に書き方が違っているような気もするのですが。
property を、いろいろ変えてみたのですが、jsp のコンパイルすら通らないか、
実行時にエラーになるかどちらかで、お手上げ状態です。

正しく、値を取得するには、どのように記述すればいいのでしょう?





Seasar-user メーリングリストの案内