MalcolmDavis
22 Nov 2011, 2:44 PM
I have a BeanModel that I am displaying in a panel that I pass to a pop-up dialog for editing. If the user cancels the edit dialog I want the BeanModel to revert to its original state, but I am having trouble getting this to work.
Is there an example out there that implements this?
It seems that there are two possibilities.
First, what I thought should work was calling setUpdateOriginalValue(true) on my FormBinding object and then calling reset() on my FormPanel object when the dialog is cancelled. However, that doesn't seem to work for me. It doesn't appear that the reset() method on the field is firing the onChange event and mapping the reset value back into the BeanModel. So I suspect I'm doing something wrong. An example would really help.
The second option, would be to clone my BeanModel, pass the clone to the dialog and only copy the results back to the original BeanModel if the user clicked Save. However, I haven't found any examples of BeanModel cloning either. Assuming my POJO implements clone(), is this all I need to do?
BeanModel beanModelCopy = BeanModelLookup.get().getFactory(beanModel.getBean().getClass());
beanModelCopy.setBean(beanModel.getBean().clone());
I am interested in the answer to this question even if there is a way to make the first option work for this case.
Thanks,
Malcolm
Is there an example out there that implements this?
It seems that there are two possibilities.
First, what I thought should work was calling setUpdateOriginalValue(true) on my FormBinding object and then calling reset() on my FormPanel object when the dialog is cancelled. However, that doesn't seem to work for me. It doesn't appear that the reset() method on the field is firing the onChange event and mapping the reset value back into the BeanModel. So I suspect I'm doing something wrong. An example would really help.
The second option, would be to clone my BeanModel, pass the clone to the dialog and only copy the results back to the original BeanModel if the user clicked Save. However, I haven't found any examples of BeanModel cloning either. Assuming my POJO implements clone(), is this all I need to do?
BeanModel beanModelCopy = BeanModelLookup.get().getFactory(beanModel.getBean().getClass());
beanModelCopy.setBean(beanModel.getBean().clone());
I am interested in the answer to this question even if there is a way to make the first option work for this case.
Thanks,
Malcolm