a couple of things to look into:

access to Session is not synchronized, so make sure you sync
everything yourself.

if you have a stateless page it will not store the session in
httpsession, you might have to do that manually by calling
session.bind()

-igor

On Mon, Nov 3, 2008 at 11:22 AM, Dane Laverty <[EMAIL PROTECTED]> wrote:
> My site has a form-based test on TestPage. Each question in the test has
> a Question object as its model. The Questions all sit in an ArrayList in
> a Test object. Each Question has a "markedAnswer" String, which stores
> the value of the selected answer. The problem is that, for some users,
> the "markedAnswer" fields are become null on the TestResultsPage after
> the test is submitted. This behavior is not consistent (I haven't been
> able to replicate it) but it happens dozens of times daily, so I know
> that it's a real problem.
>
>
>
> My question is, does anyone have any ideas why
> session.user.test.questions[i].markedAnswer becomes null for some users
> after they submit the test?
>
>
>
> Here's the relevant code. Important lines include:
>
> - TestPage, line 37. This inserts the test results into the database.
> Because this is happening correctly, I know that user.test.questions is
> still populated at this point.
>
> - TestResultsPage, line 12. This is where question.getMarkedAnswer()is
> null (and throws a NullPointerException).
>
>
>
> 1  public class TestPage extends...
>
> 2  {
>
> 3    private User user;
>
> 4
>
> 5    public TestPage()
>
> 6    {
>
> 7     user = getSession().getUser();
>
> 8    add(new TestForm("testForm"));
>
> 9    }
>
> 10
>
> 11    final class TestForm extends ApplicationForm
>
> 12    {
>
> 13          public TestForm(final String id) {
>
> 14                super(id);
>
> 15
>
> 16                add(new ListView("questions", new PropertyModel(user,
> "test.questions")) {
>
> 17
>
> 18                      protected void populateItem(ListItem item) {
>
> 19                        final Question question = (Question)
> item.getModelObject();
>
> 20
>
> 21                        // answersRadioGroup will be a group of radio
> buttons -- one for each possible answer (4, currently)
>
> 22                        RadioGroup answersRadioGroup = new
> RadioGroup("answers", new PropertyModel(question,
> "markedAnswerLetter"));
>
> 23
>
> 24                        // This loop will generate a radio button for
> letters A, B, C, and D. Those letter are hard-coded
>
> 25                        // into the database as answer selections, so
> we can't change them.
>
> 26                        for (char letter = 'A'; letter <= 'D';
> letter++) {
>
> 27                            Radio radio = new Radio(letter + "", new
> Model(letter + ""));
>
> 28                            answersRadioGroup.add(radio);
>
> 29                        }
>
> 30
>
> 31                        item.add(answersRadioGroup);
>
> 32                    }
>
> 33                });
>
> 34          }
>
> 35
>
> 36          protected void onSubmit() {
>
> 37                fhBD.uploadUserTestResults(user);
>
> 38                setResponsePage(TestResultsPage.class);
>
> 39          }
>
> 40    }
>
> 41 }
>
>
>
>
>
>
>
> 1  public class TestResultsPage extends...
>
> 2  {
>
> 3     private User user = getSession().getUser();
>
> 4
>
> 5      public TestResultsPage()
>
> 6      {
>
> 7       add(new ListView("resultsListView",
> user.getTest().getQuestions()) {
>
> 8
>
> 9                 protected void populateItem(ListItem item) {
>
> 10                  final Question question = (Question)
> item.getModelObject();
>
> 11
>
> 12                  Label answerText = new Label("answerText", new
> Model(question.getMarkedAnswer().toString()));
>
> 13                  answerText.setEscapeModelStrings(false);
>
> 14                  item.add(answerText);
>
> 15
>
> 16              }
>
> 17          });
>
> 18     }
>
> 19 }
>
>

---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]

Reply via email to