PDA

View Full Version : Help, I need to "reset"/ "clear" BeanModel bound to form



chalu
27 Jul 2010, 6:07 AM
Hello pals, please I need a way to "clear" or "reset" a beanmodel that is bound to a form after the form is submitted. I noticed that if new data is been entered and a field that was filled in the previous entry is ommited, the previous entry (surely from the bound beanmodel) is what gets to the server. There has to be a way around this. Thanks

sven
27 Jul 2010, 6:08 AM
I dont understand what you mean, can you describe it more detailed please?

chalu
28 Jul 2010, 10:56 AM
Ok, I finally got around it, here is what I did :


Set<Map.Entry<String, Object>> props = beanModel.getProperties().entrySet();
for (Iterator<Map.Entry<String, Object>> it = props.iterator(); it.hasNext();) {
Map.Entry<String, Object> entry = it.next();
String key = entry.getKey();
beanModel.set(key, null);
}

this code is within the success handler of the aync callback used by the rpc service to send the form entries to the server, what I have done is to clear every property in the beanmodel so that subsequent submissions will not carry stale values. I had to do this because I had a form that had a non-mandatory email field, the first entry had a value for this field, but the second did not and inspite of that, when the second entries were submitted, the email that was entered with the first entries went with the second entry to the server. I suspected the "persistence" was in the beanmodel bound to the form since I was always reseting the form after submission. I hope this helps to clear things up, however if there is a better way I'll appreciate hints.