interface IComponentFactory {
  public Component createComponent(String id);
}

List<IComponentFactory> components = new ArrayList(....)

components.add(new IComponentFactory() {
  public Component createComponent(String id) {
     return new MyComponent(i);
  }
});

so instead of storing the component instances directly you just store
factories instances and you delay the actual component creation until
you know the id.

-Matej

On Sat, Apr 12, 2008 at 12:16 PM, Korbinian Bachl - privat
<[EMAIL PROTECTED]> wrote:
> Hi Matej,
>
>  sorry for this noobish question, but could you please give me an example of
> your "factories" idea?
>
>
>
>  Best,
>
>  Korbinian
>
>  Matej Knopp schrieb:
>
> > On Sat, Apr 12, 2008 at 10:24 AM, Korbinian Bachl - privat
> > <[EMAIL PROTECTED]> wrote:
> >
> > > Thanks for clear answer; In case i I add a feature request: would it
> even be
> > > possible to change the Id at a later time?
> > >
> > No.
> >
> > -Matej
> >
> > longer answer: There are many ways to get wicket to do what you want.
> > Changing the component id is the worst of them. It's dangerous and
> > unnecessary. Instead of storing wicket components you can just store
> > factories.
> >
> >
> > >  I catch me regularly to add Components like Links, Panels etc. to a
> > > List<Component> and have them rendered later on to different Markups in
> > > different ListViews - and that means I need to hold them in sync
> regarding
> > > their id;
> > >
> > >  And another feature request idea: would it be OK to add a synonym for
> > > wicket:id="" e.g.: w:id="" or even only :id="" ? Would be some less
> typing
> > > :)
> > >
> > >  Best,
> > >
> > >  Korbinian
> > >
> > >
> > >
> > >  Matej Knopp schrieb:
> > >
> > >
> > >
> > >
> > > >
> > > > >  short question: Why isn't it possible to have a setId(String id) on
> the
> > > > >
> > > >
> > > components?
> > >
> > > > short anwer:
> > > >
> > > >
> > > > > - Is it really necessary that they know their id at  creation-time?
> > > > >
> > > > >
> > > > yes
> > > >
> > > > -Matej
> > > >
> > > >
> > > > >  Regards,
> > > > >
> > > > >  Korbinian
> > > > >
> > > > >
> > > > >
> > > >
> > > >
> > > >
> > > >
> > >
> >
> >
> >
> >
>



-- 
Resizable and reorderable grid components.
http://www.inmethod.com

Reply via email to