Hi devs,
the "wicket:id" tag attribute is commonly used to identify Component's
instances and its markup, and IMO it should be reserved to this end for
clarity.
While fragment's markup is identified by the "associatedMarkupId" attribute
inside the Fragment class, its associated markup is identified by the tag
attribute "wicket:id" in the "wicket:fragment" tag. This new case of an
associated markup being identified for a type rather than an instance would
benefit from a new identifier name. Therefore some proposals.
1 - Without changing the Fragment class, a natural tag attribute identifier
would "wicket:markup-id", matching the class attribute name. Since the
identifier is already inside a markup, even more natural would be:
"wicket:id" (yeah, I know). Given that we are already inside a tag in
Wicket's namespace, a simpler identifier would be: "id".
So instead of the current fragment definition:
class MyFragment extends Fragment {
...
super(id, "myFragmentMarkupId", markupContainer);
...
}
<wicket:fragment wicket:id="myFragmentMarkupId">
We would have:
<wicket:fragment id="myFragment">
2 - To change Fragment's "associatedMarkupId" attribute to "typeName". Even
if the user chooses to not specialize the Fragment class by creating a
subclass of it, conceptually he is still specializing the markup container
when associating a markup to it. Following the same logic,"wicket:fragment"
tag's identifier attribute would be: "type-name". So we would have:
class MyFragment extends Fragment {
...
super(id, MyFragment.class.getSimpleName(), markupContainer);
...
}
<wicket:fragment type-name="MyFragment">
What are your thought?
Cheers
Pedro Santos