I feel there is some misunderstanding on this thread now. Two things need to clear:
1. There is no need to call this convenience method on each wicket component. Nobody asks for that. 2. The method is there simply for the programmer to decide to use it or not and use it right. Without this method, it is still equally likely to have duplicate wicket ids due multiple use of the same panel. Just my 2 cents. Best. --- On Tue, 3/30/10, Jeremy Thomerson <jer...@wickettraining.com> wrote: > From: Jeremy Thomerson <jer...@wickettraining.com> > Subject: Re: better way setting up ID for a Wicket component? > To: users@wicket.apache.org > Date: Tuesday, March 30, 2010, 5:28 PM > That's the point of what he's > saying. It's easy to say that, but in > practice, you may create a component that you don't think > will ever be used > on the same page twice, and then it is. That's why > Wicket defaults to the > safest practice of generating an ID for you. I > typically > avoid programmatically setting the markup ID for this very > reason. There's > (almost) always a way around it. > > -- > Jeremy Thomerson > http://www.wickettraining.com > > > > On Tue, Mar 30, 2010 at 12:06 PM, David Chang <david_q_zh...@yahoo.com>wrote: > > > > > Craig, I really appreciate your input. If a panel is > reused more than one > > time on the same page, then the panel's components > should not use IDs in the > > first place. It would always violate valid HTML. > Correct? > > > > Regards. > > > > > > > > --- On Tue, 3/30/10, McIlwee, Craig <craig.mcil...@openroadsconsulting.com> > > wrote: > > > > > From: McIlwee, Craig <craig.mcil...@openroadsconsulting.com> > > > Subject: Re: better way setting up ID for a > Wicket component? > > > To: users@wicket.apache.org > > > Date: Tuesday, March 30, 2010, 7:49 AM > > > There's a good reason that markup ID > > > doesn't match wicket ID. If I have a panel > with a few > > > form components, and then put 2 of those panels > on the same > > > page, then your approach would break things like > > > document.getElementId(...) because there would be > more than > > > 1 element w/ same ID. > > > > > > Craig > > > > > > _____ > > > > > > From: David Chang [mailto:david_q_zh...@yahoo.com] > > > To: users@wicket.apache.org > > > Sent: Mon, 29 Mar 2010 21:03:46 -0400 > > > Subject: Re: better way setting up ID for a > Wicket > > > component? > > > > > > Not sure whether the help method will do the > trick of > > > one-liner code. > > > > > > I feel that it would be much > nice if Wicket could > > > have the following additional method for a > Componment: > > > > > > Component > setMarkupIdToWicketId(). > > > > > > Re-using a Wicket Id as markup > id as convention > > > should be best practice. Am I right? I am new in > wicket and > > > sorry if I am wrong. > > > > > > Best. > > > > > > > > > > > > --- On Mon, 3/29/10, James > Carman <jcar...@carmanconsulting.com> > > > wrote: > > > > > > > From: James Carman <jcar...@carmanconsulting.com> > > > > Subject: Re: better way > setting up ID for a > > > Wicket component? > > > > To: users@wicket.apache.org > > > > Date: Monday, March 29, > 2010, 7:16 PM > > > > helper method? > > > > > > > > protected <T extends > Component> T > > > setMarkupId(T > > > > component, String > markupId) > > > > { > > > > > > > > component.setMarkupId(markupId); > > > > return > component; > > > > } > > > > > > > > > > > > On Mon, Mar 29, 2010 at > 7:00 PM, David Chang > > > <david_q_zh...@yahoo.com>wrote: > > > > > > > > > Here is what I am > using the follow pattern > > > to set up > > > > ID for a wicket > > > > > component: > > > > > > > > > > Label abc = new > Label("abcd", > > > "abcdedfg"); > > > > > > > > > abc.setOutputMarkupId(true).setMarkupId(abc.getId()); > > > > > > > > > > It takes two lines to > do this. > > > > > > > > > > Can I do something > like > > > > > > > > > > Label abc = new > Label("abcd", > > > > > > > > > "abcdedfg").setOutputMarkupId(true).setMarkupId(???); > > > > > > > > > > Is this doable? If > yes, then what should > > > go to replace > > > > ??? > > > > > > > > > > Thanks! > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > --------------------------------------------------------------------- > > > > > To unsubscribe, > e-mail: users-unsubscr...@wicket.apache.org > > > > > For additional > commands, e-mail: users-h...@wicket.apache.org > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > --------------------------------------------------------------------- > > > To unsubscribe, e-mail: users-unsubscr...@wicket.apache.org > > > For additional commands, e-mail: > users-h...@wicket.apache.org > > > > > > > > > > > > > > > > > --------------------------------------------------------------------- > > To unsubscribe, e-mail: users-unsubscr...@wicket.apache.org > > For additional commands, e-mail: users-h...@wicket.apache.org > > > > > --------------------------------------------------------------------- To unsubscribe, e-mail: users-unsubscr...@wicket.apache.org For additional commands, e-mail: users-h...@wicket.apache.org