Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- package actions.survey;
- import java.util.Iterator;
- import java.util.List;
- import data.Questions;
- import actions.base.BaseAction;
- public class QuestionListing extends BaseAction {
- /**
- *
- */
- private static final long serialVersionUID = -296977415438052714L;
- private List<Questions> questions;
- private Questions currentQuestion;
- private Iterator questionsIter;
- private Long id;
- private Long formId;
- private Long currId;
- public String execute() {
- currentQuestion = services.getQuestionById(getCurrId());
- return SUCCESS;
- }
- public String display() {
- // setCurrentQuestion(services.getQuestionById(getId()));
- // setCurrentQuestion(services.getQuestionsByForm(getFormId()));
- // setQuestions(services.getQuestionsByForm(getFormId()));
- questions = services.getQuestionsByForm(getFormId());
- questionsIter = questions.iterator();
- // currentQuestion = getCurrentQuestion();
- return NONE;
- }
- public void nextQuestion() {
- if (questionsIter.hasNext()) {
- currentQuestion = (Questions) questionsIter.next();
- } else {
- currentQuestion = null;
- }
- // return NONE;
- }
- public Questions getCurrentQuestion() {
- nextQuestion();
- return currentQuestion;
- }
- /**
- * @param currentQuestion the currentQuestion to set
- */
- public void setCurrentQuestion(Questions currentQuestion) {
- this.currentQuestion = currentQuestion;
- }
- /**
- * @param id the id to set
- */
- public void setId(Long id) {
- this.id = id;
- }
- /**
- * @return the id
- */
- public Long getId() {
- return id;
- }
- /**
- * @param form_id the form_id to set
- */
- public void setFormId(Long formId) {
- this.formId = formId;
- }
- /**
- * @return the form_id
- */
- public Long getFormId() {
- return formId;
- }
- /**
- * @return the questions
- */
- public List<Questions> getQuestions() {
- return questions;
- }
- /**
- * @param currId the currId to set
- */
- public void setCurrId(Long currId) {
- this.currId = currId;
- }
- /**
- * @return the currId
- */
- public Long getCurrId() {
- return currId;
- }
- /**
- * @return the currentQuestion
- */
- // public Questions getCurrentQuestion() {
- // return currentQuestion;
- // }
- }
Advertisement
Add Comment
Please, Sign In to add comment