我只有一个想法,即实现获取用户的答案。我决定使用List<String> questionsWithAnswers
,并将它放在这个列表中,如'1_1','1_2','1_3','2_1'。像这样的东西。但即使有这个想法,我有一个问题。同样重要的是我将使用web服务(这是使用map作为结构来保存问题和答案的限制)。调查问卷获得结果JSF
********我的豆********
public class TestBean implements Serializable{
private static final long serialVersionUID = 1L;
private List<Test> testList;
private List<Answer> answerList;
private List<Subject> subjectList;
private Map<Question, List<QuestionAnswer>> mapQestionsWithAnswers;
private List<String> questionAnswerList;
private Long subjectId = 0L;
private Test test;
//...
}
getTest.xhtml
<c:forEach items="#{test.testBean.mapQestionsWithAnswers}"
var="entry">
<h:inputHidden value="#{entry.key.questionId}" />
<h:outputText value="#{entry.key.question}" rendered="#{not empty entry.value}"/>
<h:selectManyCheckbox value="#{test.testBean.questionAnswerList}" layout="pageDirection">
<f:selectItems value="#{entry.value}" var="ans"
itemValue="#{fnc:concat(ans.answer.answerId, entry.key.questionId)}"
itemLabel="${ans.answer.answer}" />
</h:selectManyCheckbox>
</c:forEach>
<h:commandButton value="#{msgs['page.content.passtest']}" action="#{test.passTest}" />
对于concatination questionId与answerId我使用CONCAT。我觉得这是在Concatenate strings in JSF/JSP EL and Javascript
但我不能得到价值entry.key.questionId
内itemValue="#{fnc:concat(ans.answer.answerId, entry.key.questionId)}"
我不明白为什么。
我该在哪里犯错?我想问一些更多的逻辑来源和简单的决策类似的问题。谢谢
为什么areyou在JSF项目2使用JSTL?更好地使用jsf''标签 –
@SteveAtkinson,因为我阅读了有关jsf – Ray
中的输出Map的问题,使用ui地图或列表从未遇到过问题:重复。 JSTL标签的问题在于它们在生命周期的错误部分执行并导致意外的结果。见http://stackoverflow.com/questions/3342984/jstl-in-jsf2-facelets-makes-sense –