If a FormComponent has raw input (FormComponent.hasRawInput() == true) then it 
will use that value when rendering instead of its model object.  I find that 
pretty often (or more likely always) have to call FormComponent.clearInput() 
when updating a component's model object during an ajax request so that it uses 
the model object instead of the raw input.  Too bad this isn't clearly 
documented in the FormComponent javadocs, or anywhere else that I can remember, 
instead I had to find this out the hard way by stepping through the wicket code.

Craig

-----Original Message-----
From: David Leangen [mailto:[email protected]]
Sent: Wednesday, August 05, 2009 6:20 AM
To: [email protected]
Subject: How do I update my model?


Hello!

I have a form in a panel like so:

public class MyPanel extends Panel
{
     Object someModelObject;

     public MyPanel( ... )
    {
         setModel( new Model( Object ) );
         ....

         add( new MyForm( ... ) );
    }

    private static MyForm extends Form
    {
         private final MyPanel panel;

         MyForm( ... )
         {
                 add( new TextField( "text", new PropertyModel( panel,
"someModelObject" );

                 add( new MyDropDownChoice( "dropdown" ..., new  
PropertyModel( panel, "someModelObject" );
         }
    }

}



I have MyDropDownChoice set to capture onChange, and in
onSelectionChanged I update the model object.

Problem is that the field is not getting updated upon refresh, even if
the model object is being changed (yes, the model is indeed changed,
and yes, they all refer to the same model).

Do I need to mark the model object as dirty or something for the other
components to refresh?

BTW, in onSelectionChanged, I tried:

   panel.modelChanged();

but that didn't help much.


Thanks!
=David




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




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

Reply via email to