Thanks for your response. Your solution looks interesting and even
quite similar to mine, but... :)

My ObjectEditor interface is like your "Map editedValues, IModel
underlyingModel" coupled together. But underlyingModel in my solution
holds the whole object, not a single property:

Object getEditedObject() {
  return underlyingModel.getObject();
}

I have original object and edited values stored inside one
ObjectEditor instance (therefore in one model). I can have a different
implementations of this interface. In your solution you must have 2
models for each property (one overlay model and one underlyingModel).
Another thing is maybe less important, but EditorPropertyModel and
CompoundEditorPropertyModel works the same way like standard property
models when object passed to them is not an ObjectEditor.

According to your concept ObjectEditor could have a method:
  IModel getPropertyModel(String propertyExpression); // or maybe
createPropertyModel ?
instead of:
  Object getPropertyValue(String propertyExpression);
  void setPropertyValue(String propertyExpression, Object value);

Daniel

On Feb 6, 2008 5:20 PM, Maeder Thomas <[EMAIL PROTECTED]> wrote:
> If I understand this correctly, you're trying to keep an overlay while
> editing an object. Why not do this:
>
> class OverlayModel extends Model {
>         OverlayModel(Map editedValues, IModel underlyingModel, String
> propertyName) {
>                 ...remember the parameters in instance variables
>         }
>
>         public Object getObject() {
>                 if (editedValues.containsKey(propertyName)) {
>                         return editedValues.get(propertyName);
>                 } else {
>                         return underlyingModel.getObject();
>                 }
>         }
>
>         public abstract void setObject(Object obj) {
>                 if (isEquals(obj, getObject()) {
>                         editValues.put(obj);
>                 }
>         }
> }
>
> As underlying models, you would use PropertyModel instances. When you
> want to revert the values, you just clear the Map.
>
> Thomas
>
>
> > I try to better explain this. When editing object I don't
> > want to store changes directly to this object (eg. until form
> > submit), but these edited values are "cached" in special ObjectEditor:
> >
> > public interface ObjectEditor extends IClusterable {
> >   Object getEditedObject();
> >   Object getPropertyValue(String propertyExpression);
> >   void setPropertyValue(String propertyExpression, Object value);
> >   void commitChanges();
> >   void cancelChanges();
> > }
> >

---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]

Reply via email to