In this code, do you think I am using the method
CompoundPropertyModel.bind properly?  See my example in Code2, below.
In my snippet Code1, the values for the propertymodel were lost when I
did an ajax onClick.
 
But in Code2, the values are retained...
 
 
Code1:
 
 
Panel {
   Panel() {  
      CompoundPropertyModel compoundPropertyModel = new
CompoundPropertyModel(someObject);
      Form f = new Form(compoundPropertyModel);
   
      f.add(new TextField("name"));  <---- This works fine, data able to
setObject and getObject on ajax and other cases
 
      f.add(new TextField("name", new PropertyModel(someObject); <--- ON
AJAX, VALUES LOST
 
      f.add(new AjaxLink() {
          onClick() { 
             target.add(form);
         }
      }
    
   }
}
 
...
...
 
Code2:
As a fix, I did the following:
 
        
        final PropertyModel pm = new
PropertyModel(compoundPropertyModel, "number") {
            @Override
            public Object getObject() {
                return ((CompoundPropertyModel)
form.getDefaultModel()).bind("number").getObject();
            }
            
            public void setObject(final Object obj) {
                ((CompoundPropertyModel)
billingForm.getDefaultModel()).bind("number").setObject(obj);
            }
        };

      f.add(new TextField("name"));  <---- This works fine, data able to
setObject and getObject on ajax and other cases
 
      f.add(new TextField("name", pm)<--- ON AJAX, NOW VALUES ARE
AVAILABLE, FIXED!
        
 
 
Berlin Brown
 

Reply via email to