i think all this will do is add a buch of more checks into the core for the "ChildCompoundPropertyModel", or whatever it ends up being called. the internal implementation of it will be almost identical to new PropertyModel(compoundmode, "foo")

the problem is, as i said, that the model is so opaq from the outside, we really need a general solution for chained models.

-Igor


On 9/16/06, Erik Brakkee <[EMAIL PROTECTED]> wrote:
One of the things I was thinking of is actually sharing the same CompoundPropertyModel but then requesting a child model of the CompoundPropertyModel using a new API call, for instance:

   CompoundPropertyModel personModel = new CompoundPropertyModel(person);
   CompoundPropertyModel addressModel = personModel.createChildModel("address");
   AddressPanel addressPanel = new AddressPanel("address", addressModel);

So instead of passing the address part to the addresspanel, just pass an appropriate model. In this case, the propertyExpression() for a street text field of the address would get the property _expression_ from the person Model and prefix it with "address". So in other words, it would return "address.street" which is the correct _expression_ for navigating to the street from the Person object.  The child model in this case does not do any versioning but leaves this to the parent component.

In concrete, we might need to redesign CompoundPropertyModel to separate implementation from interface (because the child will have a quite different implementation.

For instance:

   abstract class AbstractCompoundPropertyModel extends .... implements ...{  // NEW!!!
       AbstractCompoundPropertyModel createChildModel(String aChildExpression);
       ... other methods
   }

   class CompoundPropertyModel extends AbstractCompoundPropertyModel {
       // current implementation with createChildModel() implementation added.
   }

   class ChildCompoundPropertyModel extends AbstractCompoundPropertyModel  {
        private AbstractCompoundPropertyModel _parent;  // parent to delegate to.
       
        ....
   }

I think something like this would be a clean solution to the problem. No problems with duplicates since the person object is stored in only one model and versioned by only one model instance. It would even work if multiple child models are created that refer to the same object. No interface changes required for custom components since they simply get passed an IModel implementation as done now.

In any case, I hope the idea is clear.

Cheers
  Erik

On 9/17/06, Johan Compagner < [EMAIL PROTECTED]> wrote:
Lets make an example then

CompoundPropertyModel modelParent = new CompoundPropertyModel(new Person());
Panel parent = new Panel("xx", modelParent);
CompoundPropertyModel modelChild = new CompoundPropertyModel(new PropertyModel("address",modelParent));
Panel child = new Panel("yy",modelChild);

now a change happens on both components:

parent.modelChanging()
parent.modelChanged()
child.modelChanging()
child.modelChanged()

1>   What is exactly the state of the 2 ModelChange undo's that are now created?

now an undo/rollback happens

2>   What exactly is set back into the parent and the child??


with <1>
for the parent object what do we have there. The byte array of the CompoundPropertyModel(new Person()); i guess?
Because it doesn't have any inner models nothing
for the child object what do we have also a byte array of the complete thing?

Then with <2>
I guess we set back on the parent the CompoundPropertyModel we got out of the byte array? So it now had a completely different instance
that doesn't have anything to do any more with the child, what ever the child does with its byte array.
So for the parent we have to keep the old compoundpropertymodel but we have to rollback the internal object (but how do we know that
what the internal object is for sure (we could build this in for know models...)) But how do we do that? i can restore the byte array
and then get the object from the model and set that to the old compound model? (again we have to know the kind of model that is used)

But then for the child? how are we going to do that?
The 2 wrapper models (The compound that is direct model is and the property model) dont matter to much if they were rollbacked
or the old once are kept. Because the are exactly the same.
But the deepest wrapped compound has to be the same and that is just the one we want to have a new one from (just like with the parent)
but that can't be because then we go out of sync again..

So the question is how can we keep the same deepest model instance but do replace its internalstate..
I don't know currently maybe in my sleep i will have something.. but:

protected Object resolveObject(Object obj) throws IOException of the ObjectInputStream
wont help use here..Because that would be called for the deepest CompountPropertyModel that is just deserialized
and if we just say ahh replace it with this one (that is the old one that we want to keep)
then nothing happens because then we just have the old object instance with all the values that has to be replaced.
Because resolveObject is called after the Object is fully reconstructed and then just before it gets assigned to the right
internal field of the Object(s) that was(where) refering to him, we can quickly replace it with an other object.

That is how we do it with not serializing components. We replace the reference with a string in the byte stream
then when we encounter that string again when deserializing we quickly return the real component so that all the references are
set to the component instance that we already had and didn't serialize.

johan



On 9/17/06, Igor Vaynberg < [EMAIL PROTECTED]> wrote:
On 9/16/06, Johan Compagner < [EMAIL PROTECTED] > wrote:
how i read his mail is a bit different
Does he reallyv do it with a inner model?

i think he does this:

AddressEditor(..., Address address) {
  super(...)
   setModel(new CompoundPropertyModel(address));

if you do the above then we cannot do much, maintaining object identity would require some serious hackery because in this case the object can be a property of any other object nested x levels deep. so i dont think we should support this usecase. what we should support is model chaining because it is such a common usecase.
 

Maybe your trick can work (going to the original model that is shared by all panels)
and clone that one. But that can only happen once (for all the panels for that page version) how are we going to know/do that?
And how are we going to set that back in? we can't say then component.setModel()
because it is an internal Model of more real models...



well, see what happens is that you wouldnt clone the model itself. if you encounter that the model is chaining to a model somewhere higher then what you would write replace it with a locator and its old value- so when deserializing you relink to it and push the old object. will that work? im not sure. that means modelchange has to keep the bytearray instead of the clone so on undo you deserialize.

and im sure there can be plenty cases where it wont work.

why would we need to keep track of what we already cloned and not cloned? we would do it for every model that was changed.

-Igor

 

On 9/16/06, Igor Vaynberg <[EMAIL PROTECTED]> wrote:
no, this is not what he means. i have these types of panels all the time in my app as well, it works like this

AddressEditor(..., IModel addressModel) {
  super(...)
   setModel(new CompoundPropertyModel(addressModel));

that setmodel is what breaks things. you wrap the model you get in a compoundpropertymodel so that your children can inherit.

so usually the model chain is like this

C1=CompoundPropertyModel(Person)
P=PropertyModel(C1, "address") <== this is the input to AddressEditor panel
C2=CompoundPropertyModel(P) <== AdressEditor wrapper

so the problem with this is that now ModelChange:79 will fail because C2!=C1

hope this clears some up, im gonna go pass out now for a while

-Igor




On 9/16/06, Eelco Hillenius < [EMAIL PROTECTED]> wrote:
public class AddressPanel extends Panel {

  public AddressPanel(MarkupContainer parent, String id,
IModel<Address> AddressModel) {
     ...
  }

new AddressPanel(this, "ap", new AddressModel(employeeModel));

new AddressPanel(this, "ap", new AddressModel(employerModel));

And all the other variations you may think of. In Wicket 1.x we don't
have strongly typed models (IModel<Type>), but you can force typing in
other ways if you want.

Basically, the point here is that you can nest IModel instances too.
As long as you do that, back button support should be fine.

Eelco


On 9/16/06, Erik Brakkee < [EMAIL PROTECTED]> wrote:
> Hi,
>
>
>  I am interesting in writing components for editing domain objects. An
> example of such an object is Employee which has and Address and several
> other attributes. Also, I have Employer, which also has an Address. Now, if
> I want to create a component for an address that provide a part of the form,
> then I would like to be able to write it independent of whether it is the
> Employer's address or the Employee's address. In other words, I want to see
> an HTML template of the form:
>
>       <tr> <td>Streeet:</td><td><input wicket:id="street"
> type="text"/></td></tr>
>       .... other fields in a similar way...
>
>  In other words, I don't want to write wicket:id="address.street" because
> that would mean that the Address always has to be obtained from a model
> object using getAddress(). In other words, I would lose the ability to edit
> an address on its own or edit addresses that are retrieved by a different
> getter.
>
>  A first solution to solve this is to construct my own AddresPanel (extends
> Panel) with a reference to an Address object. The panel also creates its own
> CompoundPropertyModel based on the address. I tried this, and it works, but
> then again, back button support will be broken because when an old version
> of the page is requested, the CompoundPropertyModel of the Employer/Employee
> and Address will have different objects since they made their own copies.
>
>  It there a way in wicket 1 to share models? I was looking through the
> wicket 2 code and there seems to be something about shared models there. So
> what would be the wicket 1 way and what would be the wicket 2 way for doing
> this properly?
>
>  Cheers
>    Erik
>
>
> -------------------------------------------------------------------------
> Using Tomcat but need to do more? Need to support web services, security?
> Get stuff done quickly with pre-integrated technology to make your job
> easier
> Download IBM WebSphere Application Server v.1.0.1 based on Apache Geronimo
> http://sel.as-us.falkag.net/sel?cmd=lnk&kid=120709&bid=263057&dat=121642
>
> _______________________________________________
> Wicket-user mailing list
> Wicket-user@lists.sourceforge.net
> https://lists.sourceforge.net/lists/listinfo/wicket-user
>
>
>

-------------------------------------------------------------------------
Using Tomcat but need to do more? Need to support web services, security?
Get stuff done quickly with pre-integrated technology to make your job easier
Download IBM WebSphere Application Server v.1.0.1 based on Apache Geronimo
http://sel.as-us.falkag.net/sel?cmd=lnk&kid=120709&bid=263057&dat=121642
_______________________________________________
Wicket-user mailing list
Wicket-user@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/wicket-user


-------------------------------------------------------------------------

Using Tomcat but need to do more? Need to support web services, security?
Get stuff done quickly with pre-integrated technology to make your job easier
Download IBM WebSphere Application Server v.1.0.1 based on Apache Geronimo
http://sel.as-us.falkag.net/sel?cmd=lnk&kid=120709&bid=263057&dat=121642

_______________________________________________
Wicket-user mailing list
Wicket-user@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/wicket-user




-------------------------------------------------------------------------

Using Tomcat but need to do more? Need to support web services, security?
Get stuff done quickly with pre-integrated technology to make your job easier
Download IBM WebSphere Application Server v.1.0.1 based on Apache Geronimo
http://sel.as-us.falkag.net/sel?cmd=lnk&kid=120709&bid=263057&dat=121642

_______________________________________________
Wicket-user mailing list
Wicket-user@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/wicket-user




-------------------------------------------------------------------------

Using Tomcat but need to do more? Need to support web services, security?
Get stuff done quickly with pre-integrated technology to make your job easier
Download IBM WebSphere Application Server v.1.0.1 based on Apache Geronimo
http://sel.as-us.falkag.net/sel?cmd=lnk&kid=120709&bid=263057&dat=121642

_______________________________________________
Wicket-user mailing list
Wicket-user@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/wicket-user




-------------------------------------------------------------------------

Using Tomcat but need to do more? Need to support web services, security?
Get stuff done quickly with pre-integrated technology to make your job easier
Download IBM WebSphere Application Server v.1.0.1 based on Apache Geronimo
http://sel.as-us.falkag.net/sel?cmd=lnk&kid=120709&bid=263057&dat=121642

_______________________________________________
Wicket-user mailing list
Wicket-user@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/wicket-user




-------------------------------------------------------------------------
Using Tomcat but need to do more? Need to support web services, security?
Get stuff done quickly with pre-integrated technology to make your job easier
Download IBM WebSphere Application Server v.1.0.1 based on Apache Geronimo
http://sel.as-us.falkag.net/sel?cmd=lnk&kid=120709&bid=263057&dat=121642

_______________________________________________
Wicket-user mailing list
Wicket-user@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/wicket-user



-------------------------------------------------------------------------
Using Tomcat but need to do more? Need to support web services, security?
Get stuff done quickly with pre-integrated technology to make your job easier
Download IBM WebSphere Application Server v.1.0.1 based on Apache Geronimo
http://sel.as-us.falkag.net/sel?cmd=lnk&kid=120709&bid=263057&dat=121642
_______________________________________________
Wicket-user mailing list
Wicket-user@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/wicket-user

Reply via email to