Hi Wicket Developers,
I have a few thoughts regarding component ids.
First, requiring the component to know, at constructor time, the
wicket:id of the tag it will be added to makes creating components
difficult and clumsy. What do you think about changing this pattern:
add(new MyComponent("theIdInMarkup"));
to this:
add("theIdInMarkup", new MyComponent());
This allows us to separate the construction of the components from the
populating of the markup. I can think of one downside,
Component#replaceWith() will need some re-working.
Second, regarding the request listener urls: Would it be feasible to
encode the IRequestListener URLs and form component names using the
output markup ids rather than the component ids? This would require all
all components to have a output markup id, but would not require all
components to actually output the output markup id. Reasoning: the
component ids are often much, much longer than the generated output
markup id. Also, component ids are like variable names - private and
internal to the application. I dont want to expose inner working and
terminology in the form of the component id name hierarchy to my
customers. I want the freedom to use all sorts of offensive language in
my component ids :-)
We could change urls like:
?5-1.ILinkListener-body-content-someMenu-menuItems-link-2
to
?5-1.ILinkListener-id1-id4-id6-id23-id30-id89
I assume (without looking at the code) that using the whole path in
these urls and form component names is to make finding the target
component more efficient. If it is not used to speed up finding the
target component, then we could simply set the URL to:
?5-1.ILinkListener-id89
Since the output markup id should always be unique in the page, which
the component id is only unique in the parent.
What do you think?
Thanks,
Jesse