Can you provide more code to clarify your use case? A quickstart would be helpful.
Without deeper insight into your project, I would simply implement a reusable panel like this: <wicket:panel> <!-- reusablepanel starts here --> <section class="card" aria-labelledby="sectionheader" wicket:id=" *webmarkupcontainer-providing-necessary-attributes*"> <div class="card-header"><h1 wicket:id="*for-example-this-could-be-a-label*" id="sectionheader">Lorem ipsum dolor sit amet</h1></div> <div class="card-content">Content ...</div> </section> </wicket:panel> <!-- reusablepanel ends here --> In java you could then use this as an one-line element along the lines of: new ReusablePanel("panel-id", "header-id"); ** Martin to 30. kesäk. 2022 klo 13.50 Daniel Radünz (ihmehlm...@gmx.de) kirjoitti: > Thank you kindly both for your suggestions. > > @Martin Terra > I'm not sure I quite undstand what you mean. My hope was that I don't have > to add any of the involved components to the Java code of every single > panel. The example I've given is just one of many. We have many different > constellation with completly different html fragments but each of them has > the same problem, that somewhere in there the html ID of one html tag has > to be put into the html attribute of another html tag. > > @Martin Grigorov > The problem I'm having with doing it on the client with javascript or with > the IResponseFilter is that by that time I can only work on the fully > assembled html. If a Wicket page includes the same panel multiple times > though, I would already have the same html ID and the same reference to it > multiple times in the final html without a (bullet proof) way to figure out > which two elements ultimatively belong together. > > That's why I was hoping there would be a way to do this on a panel level, > maybe with a custom attribute. Something like > <section wicket:aria-labelledby="sectionheader"> > <h1 wicket:auto-id="sectionheader"> > </section> > > If I'd then have a page which has the same panel twice in it, Wicket would > take care of assinging unique IDs and also putting these generated unique > IDs in the corresponding attributes that reference them, resulting in > something like this: > <section aria-labelledby="sectionheader1"> > <h1 id="sectionheader1"> > </section> > <section aria-labelledby="sectionheader2"> > <h1 id="sectionheader2"> > </section> > > If there is something like the IResponseFilter but on a per component base > which would allow me to inspect and modify only the html fragment of a > component/panel it might work. > > Kind regards, > Daniel > > > Gesendet: Mittwoch, 29. Juni 2022 um 15:40 Uhr > Von: "Martin Grigorov" <mgrigo...@apache.org> > An: users@wicket.apache.org > Betreff: Re: Automatically insert generated html IDs in other places in > html file > Hi, > > The easiest way I could imagine is with a short jQuery function that is > called on domready. > > If you need to do it on the server side then maybe with IResponseFilter. > > On Wed, Jun 29, 2022, 12:38 Daniel Radünz <ihmehlm...@gmx.de> wrote: > > > Hello everybody, > > > > I'm wondering if there is a way in Wicket to generate unique html IDs and > > to then add them in other places in the html, without having to write any > > boiler plate code in each panel that I have. > > > > For example in the following panel I need the ID of the h1 tag to be put > > into the aria-labelledby attribute in the section tag. > > <wicket:panel> > > <section class="card" aria-labelledby="sectionheader"> > > <div class="card-header"><h1 id="sectionheader">Lorem > > ipsum dolor sit amet</h1></div> > > <div class="card-content">Content ...</div> > > </section> > > </wicket:panel> > > > > Hardwiring it like in this example of course won't work if I use the same > > panel class multiple times within a page due to duplicate html IDs. > > > > While I know I could add WebMarkupContainers for the section and the h1 > to > > my Java code and manually wire them together with an AttributeModifier in > > Wicket, I woud prefer to have some application wide code which recognizes > > this constellation in the html file and automatically generates and > inserts > > the IDs. > > > > Maybe somebody can push me in the right direction, how I could accomplish > > this with Wicket, if it's possible at all. > > > > Kind regards, > > Daniel > > > > --------------------------------------------------------------------- > > 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 > >