Hello
How do I get the dirty values from a formmodel up on commit?
Maybe RCP-560 fixes it ?
But I can not figure how.
Hello
How do I get the dirty values from a formmodel up on commit?
Maybe RCP-560 fixes it ?
But I can not figure how.
This seems to work but does it not feel good. Are there any other way of doing this?
Code:@Override public void commit() { try { Field dirtyValueAndFormModelsField = AbstractFormModel.class .getDeclaredField("dirtyValueAndFormModels"); dirtyValueAndFormModelsField.setAccessible(true); HashSet dirtyValueAndFormModels = (HashSet) dirtyValueAndFormModelsField .get(this.getFormModel()); ValidatingFormModel formModel = getFormModel(); for (Object o : dirtyValueAndFormModels) { if (o instanceof FieldMetadata) { Set<String> fNames = formModel.getFieldNames(); for (String s : fNames) { if (o == formModel.getFieldMetadata(s)) { System.out.println("Changed " + s + " to " + formModel.getValueModel(s).getValue()); } } } } super.commit(); } catch (Exception e) { // log.error("",e); e.printStackTrace(); } }
Ok, I did NOT see that. That's really nasty code...
If you know which properties you need to monitor, you can add a listener on that property and monitor value changes.
Can you give me a use case when you'd want to use this 'feature'.
MSN: PM me please
Skype: doclo_lieven
Spring Rich Client Project Lead
I did try:
without luck. Teh cast to DirtyTrackingValueModel fails.Code:Set<String> fNames = formModel.getFieldNames(); for (String s : fNames) { DirtyTrackingValueModel v = (DirtyTrackingValueModel) formModel .getValueModel(s); if (v.isDirty()) { System.out.println("[Changed " + s + " to " + v.getValue() + "]"); } }
Use Case:
I'm trying to use spring rcp to produce a new front end to a legacy system that uses a protocol like this:
xttp://.../update?name1=value1&name2=value2...
the protocol requires/assumes that the client only sends values that has changed.
Being lazy I'm trying to come up with a generic way of doing this for all the forms I have to build.
Let's see... this might work...
Code:Set<String> fNames = formModel.getFieldNames(); for(String fName : fNames) { FieldMetaData fmd = formModel.getFieldMetaData(fName); if(fmd != null && fmd.isDirty()) { // do something } }
MSN: PM me please
Skype: doclo_lieven
Spring Rich Client Project Lead
Thanks, that did it.