tdmcginley

QuestionListing.java

May 13th, 2011
109
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 2.18 KB | None | 0 0
  1. package actions.survey;
  2.  
  3.  
  4. import java.util.Iterator;
  5. import java.util.List;
  6. import data.Questions;
  7. import actions.base.BaseAction;
  8.  
  9. public class QuestionListing extends BaseAction {
  10. /**
  11. *
  12. */
  13. private static final long serialVersionUID = -296977415438052714L;
  14. private List<Questions> questions;
  15. private Questions currentQuestion;
  16. private Iterator questionsIter;
  17. private Long id;
  18. private Long formId;
  19. private Long currId;
  20.  
  21. public String execute() {
  22. currentQuestion = services.getQuestionById(getCurrId());
  23. return SUCCESS;
  24. }
  25.  
  26. public String display() {
  27. // setCurrentQuestion(services.getQuestionById(getId()));
  28. // setCurrentQuestion(services.getQuestionsByForm(getFormId()));
  29. // setQuestions(services.getQuestionsByForm(getFormId()));
  30. questions = services.getQuestionsByForm(getFormId());
  31. questionsIter = questions.iterator();
  32. // currentQuestion = getCurrentQuestion();
  33. return NONE;
  34. }
  35.  
  36. public void nextQuestion() {
  37. if (questionsIter.hasNext()) {
  38. currentQuestion = (Questions) questionsIter.next();
  39. } else {
  40. currentQuestion = null;
  41. }
  42. // return NONE;
  43. }
  44.  
  45. public Questions getCurrentQuestion() {
  46. nextQuestion();
  47. return currentQuestion;
  48. }
  49.  
  50. /**
  51. * @param currentQuestion the currentQuestion to set
  52. */
  53. public void setCurrentQuestion(Questions currentQuestion) {
  54. this.currentQuestion = currentQuestion;
  55. }
  56.  
  57. /**
  58. * @param id the id to set
  59. */
  60. public void setId(Long id) {
  61. this.id = id;
  62. }
  63.  
  64. /**
  65. * @return the id
  66. */
  67. public Long getId() {
  68. return id;
  69. }
  70.  
  71. /**
  72. * @param form_id the form_id to set
  73. */
  74. public void setFormId(Long formId) {
  75. this.formId = formId;
  76. }
  77.  
  78. /**
  79. * @return the form_id
  80. */
  81. public Long getFormId() {
  82. return formId;
  83. }
  84.  
  85. /**
  86. * @return the questions
  87. */
  88. public List<Questions> getQuestions() {
  89. return questions;
  90. }
  91.  
  92. /**
  93. * @param currId the currId to set
  94. */
  95. public void setCurrId(Long currId) {
  96. this.currId = currId;
  97. }
  98.  
  99. /**
  100. * @return the currId
  101. */
  102. public Long getCurrId() {
  103. return currId;
  104. }
  105.  
  106. /**
  107. * @return the currentQuestion
  108. */
  109. // public Questions getCurrentQuestion() {
  110. // return currentQuestion;
  111. // }
  112. }
Advertisement
Add Comment
Please, Sign In to add comment