Hi,
I ran into some strange behavior with PropertyModels vs. "regular"
models. I set up a very simple example that demonstrates what works on
the one hand and what I would expect to work as well but does not. What
I'm doing is very basic: I'm population a list and when a user clicks on
an item in the link the details of that object are shown using ajax. The
following code works fine:
 
public class HomePage extends WebPage {
 @SpringBean
 private OrfDataService orfDataService;
 
 private OrfData selected = new OrfData();
 
 public HomePage(final PageParameters parameters) {
  // code block to be replaced  
  Model<String> testModel = new Model<String>() {
      public String getObject() {
       return selected.getProdNo();
      }
     };
  final Label testLabel = new Label("testLabel", testModel);
  // end of code block to be replaced
     
     testLabel.setOutputMarkupId(true);
        add(testLabel);
     
  add(new ListView<OrfData>("orfDataList", orfDataService.getOrfData())
{
 
   public void populateItem(final ListItem<OrfData> listItem) {
    // add all the listItem labels etc..
    
    listItem.add(new AjaxLink<OrfData>("selectLink") {
     @Override
     public void onClick(AjaxRequestTarget target) { 
      selected = getModelObject();
      
                  target.addComponent(testLabel);
     }
 
    });
   }
  });
    }
    
 public void setOrfDataService(OrfDataService orfDataService) {
  this.orfDataService = orfDataService;
 }
}

However, naturally I want to do the above using PropertyModel. But if I
replace the commented code block above with the following line:
final Label testLabel = new Label("testLabel", new
PropertyModel<String>(selected, "prodNo"));

The label no longer gets updated.
 
Any idea what I'm doing wrong here?
 
Thanks, Jonck
P.S. I know the usage of the orfDataService is not really all that great
here, it's just as an example

Reply via email to