On 9/18/06, Johan Compagner <[EMAIL PROTECTED]> wrote:
I find this extremely ugly..
And totallly unreadable, i really had to think about this one. My first reaction was that won't work

that hurt! i think it is rather clever! if i ever see any code by you using this trick i am kicking your ass!

But then i though ahh 2.0 so first you go to the init model.. getting the model from the parent
and then quickly set that model (which is then a Inheritable) as the root of the compound and setting
that compound again as the real model..

setmodel(new CompoundPropertyModel( getModel()));

hacky hacky.. And if you show that to an average wicket programmer he will not understand that at all.

not a lot of average programmers understand clever code, so whats your point? we are not imposing this style on anyone, its just there as an option.

besides do you think an average prorgrammer will have an easier time understanding the following which is the equivalent of that same one line of code but for 1.x ?

public AjaxEditableLabel(String id) {
  setModel(new CompoundPropertyModel(new PassThroughModel());
}

private final class PassThroughModel extends AbstractModel
    {
        public Object getObject(Component component)
        {
            return getModel().getObject(AjaxEditableLabel.this);
        }

        public void setObject(Component component, Object object)
        {
            getModel().setObject(AjaxEditableLabel.this, object);
        }
    }

 
i like it to be a bit more expliciet

Person person = new Person();
Form form=new Form(new CompoundPropertyModel(person));

new AddressEditor(form, "address", person.getAddress());

public AddressEditor(parent, id, Address address) {
   super(parent, id);
   setmodel(new CompoundPropertyModel(address));

much more readable and everybody exactly knows that the address panel really has.
And you don't depend on the parent that it just gives you something. Compile time it is save.

yeah thats nice, but you just lost the flexibility of where the address can come from (no imodel indirection - yeah you can make yet another constructor) and more importantly the short hand compound property model notation. if i can use the notation on a textfield why cant i use it on my editor panel?
 
-Igor


johan


On 9/19/06, Igor Vaynberg < [EMAIL PROTECTED]> wrote:

Person person = new Person();

CompoundPropertyModel personModel = new CompoundPropertyModel(person);
Component parent = new Component("personPanel", personModel);
Component child = new Component("addressPanel", new CompoundPropertyModel(new PropertyModel("address", personModel)));

i dont think this is bloated. the above exact code is sure, but when it plays out in components its not at all. the exact same chain can be created like this in 2.0

Form form=new Form(new CompoundPropertyModel(new Person());

new AddressEditor(form, "address");

the trick in 2.0 is ...
public AddressEditor(parent, id) {
   super(parent, id);
   setmodel(new CompoundPropertyModel(getModel()));
...


so in the above the chain is created for you and works like expected because getModel() in the constructor returns a compoundpropertymodel's "assigned" version that basically works like a property model for the "address" prop. so i dont think this situation is a result of bloated code at all, the compound->property->compound->property will be a common usecase imho.

-Igor


-------------------------------------------------------------------------
Take Surveys. Earn Cash. Influence the Future of IT
Join SourceForge.net's Techsay panel and you'll get the chance to share your
opinions on IT & business topics through brief surveys -- and earn cash
http://www.techsay.com/default.php?page=join.php&p=sourceforge&CID=DEVDEV

_______________________________________________


-------------------------------------------------------------------------
Take Surveys. Earn Cash. Influence the Future of IT
Join SourceForge.net's Techsay panel and you'll get the chance to share your
opinions on IT & business topics through brief surveys -- and earn cash
http://www.techsay.com/default.php?page=join.php&p=sourceforge&CID=DEVDEV

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



-------------------------------------------------------------------------
Take Surveys. Earn Cash. Influence the Future of IT
Join SourceForge.net's Techsay panel and you'll get the chance to share your
opinions on IT & business topics through brief surveys -- and earn cash
http://www.techsay.com/default.php?page=join.php&p=sourceforge&CID=DEVDEV
_______________________________________________
Wicket-user mailing list
Wicket-user@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/wicket-user

Reply via email to