In order to see what's going on here, I added this line to my TestPage
class:

System.out.println("*** Form Test: " + user.getTest().toString());
add(new TestForm("testForm", new
CompoundPropertyModel(user.getTest())));

and then I went into FormComponent.java and added a similar line to
updateModel():

public void updateModel()
        {
                if (getConvertedInput() instanceof Answer) {
                        System.out.println("*** Updated Test: " +
this.getParent().getParent().getParent().getModelObject().toString());
                }
                
                setModelObject(getConvertedInput());
        }

I've found that most of the time, the toString() values are the same,
like this:

*** Form Test: edu.chemeketa.foodhandler.objects.t...@daa75c
*** Updated Test: edu.chemeketa.foodhandler.objects.t...@daa75c

But on the instances when the Form's onSubmit() gives null for its
object models, the Test addresses are different:

*** Form Test: edu.chemeketa.foodhandler.objects.t...@12979a1
*** Updated Test: edu.chemeketa.foodhandler.objects.t...@1ec9fdc

I'll keep working on it, but if anyone has any idea why the ModelObject
would change, please let me know.

-----Original Message-----
From: Dane Laverty [mailto:[email protected]] 
Sent: Tuesday, February 10, 2009 4:56 PM
To: [email protected]
Subject: Inconsistent Model Binding on Form Submit

I have a test form based on a CompoundPropertyModel. Usually it works
great, but for some users, their answers are lost when they submit the
form. The problem is user-dependent, i.e. it always breaks for certain
users and it never breaks for the other users. If a user calls us with
this problem, we haven't been able to find anyway to get around it. I
haven't been able to replicate the problem on my computer. I posted
about this a few months ago, thinking it was a session problem, but now
I see that the problem happens right when the test is submitted. This is
with Wicket 1.3.4. Any ideas what would cause the model to lose the
information for certain users?

 

public class TestPage

{

 

public TestPage() {

add(new TestForm("testForm", new
CompoundPropertyModel(getSession().getUser().getTest())));        

}

      

public TestForm(final String id, CompoundPropertyModel testModel) {

            super(id, testModel);

                  

            add(new ListView("questions") {

                        

                  @Override

                  public boolean getReuseItems() {

                        return true;

                  }

 

                  protected void populateItem(ListItem item) {

 

                    final Question question = (Question)
item.getModelObject();        

                          

                    FoodHandlerRadioChoice answersRadioChoice = new
FoodHandlerRadioChoice("answers", 

                                                      new
PropertyModel(question, "markedAnswer"), 

 
question.getAnswers());

                    answersRadioChoice.setRequired(true);


                    item.add(answersRadioChoice);       

       

                }                   

            });

      }

            

      protected void onSubmit() {

            // The following should return an object. Usually it does,
but sometimes

            // it just returns null. Oh why, oh why? 

 
getSession().getUser().getTest().getQuestions().get(0).getMarkedAnswer()
;

            setResponsePage(TestResultsPage.class);

      }

}     

            


---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]

Reply via email to