2014-11-21 67 views
0
final TextField<Double> regularPrice = new TextField<Double>("regular", new PropertyModel<Double>(listItem.getModel(), "price")) 
{ 
    private static final long serialVersionUID = 1L; 

    @Override 
    protected void onConfigure() 
    { 
    super.onConfigure();     
    setEnabled(cashflowStatus.compareTo(CashflowStatus.M_MANUAL) < 0); 
    } 
}; 
listItem.add(regularPrice); 



regularPrice.add(new AjaxFormComponentUpdatingBehavior("onChange") 
{ 
    private static final long serialVersionUID = 1L; 

    @Override 
    protected void onUpdate(AjaxRequestTarget target) 
    { 
     Double updatedValue = listItem.getModelObject().getPrice()); 
    }    
}); 

我希望在更改時獲得新的更新值,但我從模型中獲取舊值。模型沒有更新,它應該提供新的更新值。請讓我知道,上面的代碼中出現了什麼問題,以及如何獲取更新的值?如何從文本框/模型中獲取更新值

回答

0

你也應該重新渲染您的組件:)

@Override 
protected void onUpdate(AjaxRequestTarget target) 
{ 
    Double updatedValue = listItem.getModelObject().getPrice()); 
    target.add(this.getComponent()); 
} 
相關問題