On Sun, Mar 2, 2008 at 12:43 AM, John Patterson <[EMAIL PROTECTED]> wrote:
> On 2 Mar 2008, at 15:29, Igor Vaynberg wrote:
>
>  > a) components need to know their ids, they use them to generate
>  > markup id, etc.
>
>  it could be passed to child.render(id)

and to all the other 300 methods in Component that _may_ need it? it
doesnt scale...

it is also a huge api break without a huge gain...

>  > b) it is a space optimization. an array of components each with their
>  > own id is cheaper on ram/serialization space then a map.
>
>  The field would just move from child to parent.  Implementation could
>  be just as efficient e.g. still using a single array to hold children
>  but odd spaces are ids even spaces are children.

that will work

>  > im sure i could come up with a few more, what is really the advantage
>  > of having put(id,component) ?
>
>  The advantage is being able to use constructor injection to compose
>  pages

first you have to realize that this is a corner case. doing
constructor injection with actual component instances is pretty rare.

second, it is still possible. either using well known ids,
icomponentfactory { component create(string id);}, or wrapping passed
in components with something like:

class anypanel extends panel implements icomponentresolver {
        public boolean resolve(final MarkupContainer container, final
MarkupStream markupStream,
                        final ComponentTag tag) {
           if (container==this&&tag.getid().equals("_any_")) {
              Component c=iterator().next();
              c.render(markupStream);
              return true;
           }
           return false;
       }
}

<wicket:panel><div wicket:id="_any_"></div></wicket:panel>

then in your class

class mypage extends webpage {
   public webpage(Component c1, Component c2) {
      add(new anypanel("p1").add(c1));
      add(new anypanel("p2").add(c2));
   }
}

-igor


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

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

Reply via email to