我正在使用 primefaces 布局组件并且在嵌入形式的组件方面遇到困难:
<p:selectOneRadio id="customRadio"
value="#{exams.examQuestions.currentQuestion.selectedAnswer}"
layout="custom">
<f:selectItem itemLabel="Option1"
itemValue="#{exams.examQuestions.currentQuestion.examentry.answer1}"
rendered="#{exams.examQuestions.currentQuestion.render_question1}"/>
<f:selectItem itemLabel="Option2"
itemValue="#{exams.examQuestions.currentQuestion.examentry.answer2}"
rendered="#{exams.examQuestions.currentQuestion.render_question2}"/>
<f:selectItem itemLabel="Option3"
itemValue="#{exams.examQuestions.currentQuestion.examentry.answer3}"
rendered="#{exams.examQuestions.currentQuestion.render_question3}"/>
<f:selectItem itemLabel="Option4"
itemValue="#{exams.examQuestions.currentQuestion.examentry.answer4}"
rendered="#{exams.examQuestions.currentQuestion.render_question4}"/>
<f:selectItem itemLabel="Option5"
itemValue="#{exams.examQuestions.currentQuestion.examentry.answer5}"
rendered="#{exams.examQuestions.currentQuestion.render_question5}"/>
<h:panelGrid columns="1">
<p:radioButton id="opt1"
for="customRadio"
itemIndex="0"
rendered="#{exams.examQuestions.currentQuestion.render_question1}"/>
<h:outputLabel for="opt1"
value="#{exams.examQuestions.currentQuestion.examentry.answer1}"
rendered="#{exams.examQuestions.currentQuestion.render_question1}"/>
<br/>
<p:radioButton id="opt2" for="customRadio"
itemIndex="1"
rendered="#{exams.examQuestions.currentQuestion.render_question2}"/>
<h:outputLabel for="opt2"
value="#{exams.examQuestions.currentQuestion.examentry.answer2}"
rendered="#{exams.examQuestions.currentQuestion.render_question2}"/>
<br/>
<p:radioButton id="opt3"
for="customRadio"
itemIndex="2"
rendered="#{exams.examQuestions.currentQuestion.render_question3}"/>
<h:outputLabel for="opt3"
value="#{exams.examQuestions.currentQuestion.examentry.answer3}"
rendered="#{exams.examQuestions.currentQuestion.render_question3}"/>
<br/>
<p:radioButton id="opt4"
for="customRadio"
itemIndex="3"
rendered="#{exams.examQuestions.currentQuestion.render_question4}"/>
<h:outputLabel for="opt4"
value="#{exams.examQuestions.currentQuestion.examentry.answer4}"
rendered="#{exams.examQuestions.currentQuestion.render_question4}"/>
<br/>
<p:radioButton id="opt5"
for="customRadio"
itemIndex="4"
rendered="#{exams.examQuestions.currentQuestion.render_question5}"/>
<h:outputLabel for="opt5"
value="#{exams.examQuestions.currentQuestion.examentry.answer5}"
rendered="#{exams.examQuestions.currentQuestion.render_question5}"/>
</p:selectOneRadio>
当我选择不同的项目时,支持 beanexams.examQuestions.currentQuestion.selectedAnswer 没有更新,怎么会?如果我从同一个表单调用此组件“customRadio”的更新,那么支持 bean 会自行更新,但是我无法在表单之外执行此操作。请帮忙!