日期:2014-05-17 浏览次数:20647 次
public String surveyView(){
logger.debug("进入InvestigateAction surveyView 方法");
String surveyId = this.getRequest().getParameter("id");
if(surveyQuestion == null){
surveyQuestion = new SurveyQuestion();
surveyQuestion.setThemeId(Integer.parseInt(surveyId));
}
questionList = investigateService.getQuestionList(surveyQuestion);
for(int i=0;i<questionList.size();i++){
SurveyQuestion surveyQuestion=questionList.get(i);
logger.debug("---------------------------"+surveyQuestion.getQuestionId());
if(surveyQuestionAnswer == null){
surveyQuestionAnswer = new SurveyQuestionAnswer();
}
surveyQuestionAnswer.setQuestionId(surveyQuestion.getQuestionId());
int num = investigateService.getQuestionCount(surveyQuestionAnswer);
List<SurveyQuestionAnswer> anwerListTemp = new ArrayList<SurveyQuestionAnswer>();
anwerListTemp = investigateService.getAnswerList(surveyQuestionAnswer);
for(int j=0;j<anwerListTemp.size();j++){
SurveyQuestionAnswer surveyQuestionAnswer = anwerListTemp.get(j);
logger.debug("================="+surveyQuestionAnswer.getQuestionId());
int count = surveyQuestionAnswer.getAnswerCount();
if(num != 0){
int ratio = (count*100)/num;
surveyQuestionAnswer.setAnswerCountRadio(ratio);
}
}
answerList.addAll(anwerListTemp);
}
return "surveyView";
}
<ul data-role="listview" data-inset="true" data-split-theme="d">
<s:iterator value="questionList" id="question">
<li>
<h1><s:property value="#question.questionNum"/>,
<s:property value="#question.questionTitle"/>
<s:if test="#question.chooseType == 0">(单选)</s:if>
<s:else>(多选)</s:else>
</h1>
<fieldset data-role="controlgroup">
<s:iterator value="answerList" id="answer">
<s:if test="#question.questionId == #answer.questionId">
<s:if test="#question.chooseType == 0">
<input name="<s:property value="#question.questionId"/>" id="<s:property value="#answer.questionAnswerId"/>" type="radio">
<label for="<s:property value="#answer.questionAnswerId"/>"><s:property value="#answer.answerTitle"/></label>
</s:if>
<s:else>
<input name="<s:property value="#question.questionId"/>" id="<s:property value="#answer.questionAnswerId"/>" type="checkbox">
<label for="<s:property value="#answer.questionAnswerId"/>"><s:property value="#answer.answerTitle"/></label>
</s:else>
</s:if>
</s:iterator>
</fieldset>
</li>
</s:iterator>
</ul>