1 Reply Latest reply on Dec 22, 2009 1:00 AM by kragoth

    Old Data kept and displayed at times

    tazz786
      Hi

      We have an application which basically has a datatable (containing questions) that is populated from a volist (arraylist). There is some strange behaviour happening intermittently. if you add a question to that arraylist, through the application, there are times, when the volist no longer belongs to that entity with which we are dealing with. I brings data from previous sessions.

      For example, I went to edit survey a . The I saved and went to survey b. While adding questions to survey b, sometimes, the datatable now shows questions from survey a.

      I have attached a piece of code that is the getter for the volist...

      public ArrayList<QuestionVO> getQuestionVoList() {
                logger.info("getQuestionVoList():START");
                try {
                     
                     if(questionVoList != null && !questionVoList.isEmpty()) {
                          setShowQuestionVODatatable(true);
                     } else {
                          loadQuestionVOList();
                          if(questionVoList == null)
                               questionVoList = new ArrayList<QuestionVO>();
                          setShowQuestionVODatatable(false);
                     }
                     logger.info("getQuestionVoList():END");
                } catch (Exception
                          e) {
                     .
                       ......
                }
                return questionVoList;
           }


      private void loadQuestionVOList() {
                try {
                     if(userSession.getSelectedSurveyEntity() != null && (userSession.getSelectedSurveyEntity().getStatus().getStatusId().intValue() == 1 ||
                               userSession.getSelectedSurveyEntity().getStatus().getStatusId().intValue() == 4)) {
                          setQuestionVoList(surveyActionHelper.buildQuestionVOReassign(userSession
                                         .getSelectedSurveyEntity().getSurveyId()));
                     } else {
                          //load with the already assigned nextQuestionItemId
                          setQuestionVoList(surveyActionHelper.buildQuestionVO(userSession
                               .getSelectedSurveyEntity().getSurveyId()));
                          
                     }......

      Also, once you notice the questions are from another survey, then if you press CTRL F5, then the correct questions are loaded...

      Any ideas someone please...
        • 1. Re: Old Data kept and displayed at times
          kragoth

          Please post a bit more of you code. Including the definitions of your Seam bean so we can see what Scope they are in. We also need to see the full code that executes the page transistion that takes you to the page where you are seeing the problem.


          This is a bit of a shot in the dark based on the code that you have there already, but if I assume your loadQuestionVOList() method is the one that you are using to refresh your list then maybe your problem is that it is a void method.


          Take the time to understand what method return types of null and void mean in the JSF world. A void method essentially means that your component tree will not get rebuilt. For a really quick test to see if this is the actually problem try this.


          Change the method to something like this.


          private String loadQuestionVOList() {
              //do all your work loading the lists etc (the code that you have there already)
              
              return "/theUrlOfThePageYouAreOn.xhtml";
          }
          



          If this fixes your problem then now you know what to do. I think (can't remember for sure) that you can just return an empty string "" to stay on the same page but rebuild the component tree.... Need to check this.