yes in the end the current behaviour is just a develop time check
It has nothing to do with runtime or what ever. It is just a check to let
the developer know he did something wrong (better said maybe he did)

I find these kind of codes i have now a bit stupid:

if(get("component") != null)
{
    replace(component)
}
else
{
   add(component)
}

most of the time i know what i a m doing and i want  to replace it
We could also say replace shouldn't throw an exception when it doesn't replace anything....

johan

On 7/29/06, Eelco Hillenius < [EMAIL PROTECTED]> wrote:
As it uses the key of the component it is effectively a put, like in
Map#put. Which replaces the current instance if it is there.

I have come across several situations where it is rather tedious to
write some nice reusable components as you always have to be aware
whether you're adding or replacing. And for no good reason. Like Johan
said, it would be pretty bad practice to actually depend in add
throwing an exception if a component is already added. I became aware
that replacing is a better pattern that throwing an exception through
Wicket 2.0, where every-time you create a component with the same
parent and id, it replaces the previous one. When converting an
example for Wicket In Action from 1.2 code to 2.0, I felt this worked
mucho mejor.

Eelco


On 7/27/06, Martijn Dashorst <[EMAIL PROTECTED]> wrote:
> -1 for 1.2
> 0 for 1.3
>
> I'm not too keen to switch the semantics for add. Add != replace. If I
> add 2 euro to your account, then you don't want me to take 2 euro's
> out of your balance as well.
>
> The name is very clear and has good defined semantics. Also it will
> make the move from 1.2 to 1.3 less intuitive IMO. Especially if we
> remove 'replace'. For the 1.2 branch I'd like it to keep the semantics
> in place that are already there.
>
> Can you explain more why it is easier to have 'add or replace'
> semantics for the add method?
>
> Martijn
>
> On 7/26/06, Eelco Hillenius <[EMAIL PROTECTED]> wrote:
> > Hi all,
> >
> > For Wicket 2.0, you don't call add(component) anymore, but instead
> > create the component with the parent you create. A nice side effect is
> > that this does 'component replacement' too.
> >
> > E.g.
> >
> > TextField t1 = new TextField(this, "foo");
> > TextField t2 = new TextField(this, "foo");
> >
> > Here, t2 will be the current one, and nothing will happen with t1.
> >
> > In Wicket 1.2 (and before), if you do this:
> >
> > TextField t1 = new TextField("foo");
> > TextField t2 = new TextField("foo");
> > add(t1);
> > add(t2);
> >
> > You'll get an exception: "A child with id foo already exists".
> >
> > Though this can be helpful for debugging in those rare situations you
> > mess up, there's not a really that much of a reason to throw an
> > exception here. Actually, 2.0's behavior is much more convenient, as
> > you don't have to check whether you should add or replace; you just
> > call add, and if it exists, it'll be replaced.
> >
> > The main reason for wanting to change the semantics is that it'll make
> > it easier for us to backport components from 2.0 (like I'm doing with
> > Matej's tree right now). Additionally, it'll be an extra convenience
> > for all you fancy component developers.
> >
> > Can I have some votes on this please?
> > [  ] sure, go ahead
> > [  ] no, don't do that, as it will [ fill in the why here ... ]
> >
> > Mine's +1 for changing.
> >
> > Eelco
> >
> > -------------------------------------------------------------------------
> > 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-develop mailing list
> > Wicket-develop@lists.sourceforge.net
> > https://lists.sourceforge.net/lists/listinfo/wicket-develop
> >
>
>
> --
> Download Wicket 1.2 now! Write Ajax applications without touching _javascript_!
> -- http://wicketframework.org
>
> -------------------------------------------------------------------------
> 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-develop mailing list
> Wicket-develop@lists.sourceforge.net
> https://lists.sourceforge.net/lists/listinfo/wicket-develop
>

-------------------------------------------------------------------------
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-develop mailing list
Wicket-develop@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/wicket-develop

-------------------------------------------------------------------------
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-develop mailing list
Wicket-develop@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/wicket-develop

Reply via email to